/* * @Description: In User Settings Edit * @Author: your name * @Date: 2019-08-28 19:44:56 * @LastEditTime: 2019-08-29 15:24:34 * @LastEditors: Please set LastEditors */ package versionctrl import ( "91porn-server/app/service/versionser" "91porn-server/common" "91porn-server/common/stderr" "91porn-server/models/v/versionmod" "github.com/gin-gonic/gin" ) // GetVersion doc // @Summary 平台信息 获取最新版本号 // @Description 平台信息 获取最新版本号 // @Tags 平台信息 // @Accept mpfd,json // @Produce json,html // @Param platform query string false "选择平台:Android/Ios" Enums(android,ios) // @Success 200 {string} json "{"msg": "操作成功"}" // @Failure 400 {string} json "{"msg": "操作失败"}" // @Router /mine/ver [get] func GetVersion(ctx *gin.Context) { p := ctx.Query("platform") ua, err := common.GetUA(ctx) var ver versionmod.VersionBody var returnVerList []*versionmod.VersionBody if p != "" && err == nil && ua.BuildID != "" { returnVerList = versionser.CheckVersionBaseOnBuildId(ua.Ver, p, ua.BuildID) if len(returnVerList) > 0 { ver = *returnVerList[0] common.ServeJSON(ctx, stderr.Success, ver) return } } version, err := versionmod.FindVersion(p) if err != nil { common.ServeJSON(ctx, stderr.Success, nil) return } ver.Code = version.Code ver.URL = version.URL ver.VersionName = version.VersionName ver.Platform = version.Platform ver.Description = version.Description ver.ForcedUpdate = version.ForcedUpdate common.ServeJSON(ctx, stderr.Success, ver) }