zhangzengfei
2023-09-04 e8e536d1cb52d2126c8c7ce2ba1c7a76f7208678
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package controller
 
import (
    "net/http"
    "vamicro/version-control/service"
 
    "basic.com/valib/bhomeclient.git"
)
 
type VersionController struct {
}
 
//在系统配置app中,给页面调用,判断提醒有没有程序是否需要升级
func (vc VersionController) VersionCheck(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
    _, version, intro := service.CheckVersion()
    curVersion := service.GetCurVersion()
    hasNewVersion := version != curVersion
    if version == "" {
        hasNewVersion = false
        version = curVersion
    }
    return &bhomeclient.Reply{Success: true, Data: map[string]interface{}{
        "hasNewVersion":  hasNewVersion,
        "newVersion":     version,
        "newVersionInfo": intro,
        "curVersion":     curVersion,
        "curVersionPath": curVersion,
    }}
}
 
func (vc VersionController) UpgradeVersion(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
    apps, err := service.OnlineUpgrade()
    if nil != err {
        return &bhomeclient.Reply{Success: true, Data: map[string]interface{}{
            "code": http.StatusOK,
            "msg":  err.Error(),
            "data": apps,
        }}
 
    } else {
        killApp(apps)
        return &bhomeclient.Reply{Success: true, Data: map[string]interface{}{
            "code": http.StatusOK,
            "msg":  "ok",
            "data": apps,
        }}
    }
}
 
func (vc VersionController) SnWithBus(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
    data := sn()
    return &bhomeclient.Reply{
        Data:    data,
        Success: true,
    }
}