From 2b77ad0e1f407903d85c3b7bdaae0022c4ec9bc3 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期二, 08 九月 2020 14:54:00 +0800
Subject: [PATCH] fix push bug
---
controllers/sys.go | 48 +++++++++++++++++++++++++++++++++++++++---------
1 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/controllers/sys.go b/controllers/sys.go
index 133de75..1b2051d 100644
--- a/controllers/sys.go
+++ b/controllers/sys.go
@@ -2,6 +2,8 @@
import (
"car-service/models"
+ "car-service/vo"
+ "encoding/json"
"fmt"
"github.com/astaxie/beego"
"strconv"
@@ -15,22 +17,50 @@
// @Title 姣斿鐗堟湰鍙凤紝鐪嬫槸鍚︽湁鍗囩骇
// @Description 姣斿鐗堟湰鍙凤紝鐪嬫槸鍚︽湁鍗囩骇
// @Param curVersion query string true "褰撳墠鐗堟湰鍙�"
-// @Success 200 {object} models.SysVersion
+// @Success 200 {object} models.SysUpgrade
// @Failure 403 {string} json ""
// @router /version [get]
func (c *AppController) Version() {
curV := c.GetString("curVersion")
- latestV := beego.AppConfig.String("latestVersion")
- fmt.Println("curV:", curV, "latestV:", latestV)
- result := models.SysVersion{
- LatestVersion: latestV,
+ platform := c.GetString("platform")
+ fmt.Println("platform:",platform,"curV:", curV)
+ if platform == "" {
+ platform = "android"
}
- if shouldVersionBeUpgrade(curV, latestV) {
- result.IsUpgrade = true
- result.Url = beego.AppConfig.String("latestUrl")
+ pType := -1 //鏈煡鐨勫钩鍙�
+ if platform == "android" {
+ pType = models.PlatType_Android
+ } else if platform == "ios" {
+ pType = models.PlatType_Ios
+ }
+ result := vo.Upgrade{}
+ var sv models.SysUpgrade
+ err := sv.GetLatest(pType)
+ if err != nil {
+ result.Msg = []string{}
} else {
- result.IsUpgrade = false
+ latestV := sv.LatestVersion
+ if shouldVersionBeUpgrade(curV, latestV) {
+ result.IsUpgrade = true
+ result.Url = sv.Url
+ result.LatestVersion = sv.LatestVersion
+ result.Time = sv.Time
+ result.ForceUpgrade = sv.ForceUpgrade
+ var msgArr []string
+ if e1 := json.Unmarshal([]byte(sv.Msg), &msgArr);e1 ==nil {
+ result.Msg = msgArr
+ } else {
+ fmt.Println("unmarshal err:", e1)
+ result.Msg = []string{}
+ }
+ result.Size = sv.Size
+
+ } else {
+ result.IsUpgrade = false
+ result.Msg = []string{}
+ }
}
+
c.Data["json"] = result
c.ServeJSON()
}
--
Gitblit v1.8.0