正在显示
5 个修改的文件
包含
71 行增加
和
0 行删除
@@ -39,6 +39,7 @@ func (this *BaseController)GenMessage(rsp interface{},err error)*mybeego.Message | @@ -39,6 +39,7 @@ func (this *BaseController)GenMessage(rsp interface{},err error)*mybeego.Message | ||
39 | msg.Data = rsp | 39 | msg.Data = rsp |
40 | return msg | 40 | return msg |
41 | } | 41 | } |
42 | + log.Error(err) | ||
42 | if e,ok :=err.(common.Error);ok{ | 43 | if e,ok :=err.(common.Error);ok{ |
43 | msg = mybeego.NewMessage(e.Code) | 44 | msg = mybeego.NewMessage(e.Code) |
44 | msg.Data = rsp | 45 | msg.Data = rsp |
@@ -18,6 +18,7 @@ func init(){ | @@ -18,6 +18,7 @@ func init(){ | ||
18 | err:= redis.InitWithDb(100,beego.AppConfig.String("redis_add_port"),beego.AppConfig.String("redis_auth"),"0") | 18 | err:= redis.InitWithDb(100,beego.AppConfig.String("redis_add_port"),beego.AppConfig.String("redis_auth"),"0") |
19 | if err!=nil{ | 19 | if err!=nil{ |
20 | log.Fatal(err) | 20 | log.Fatal(err) |
21 | + panic(err) | ||
21 | } | 22 | } |
22 | orm.NewBeeormEngine(config.Mysql{ | 23 | orm.NewBeeormEngine(config.Mysql{ |
23 | DataSource:beego.AppConfig.String("data_source"), | 24 | DataSource:beego.AppConfig.String("data_source"), |
@@ -162,3 +162,12 @@ func DeleteCfgAppVersion(id int) (err error) { | @@ -162,3 +162,12 @@ func DeleteCfgAppVersion(id int) (err error) { | ||
162 | } | 162 | } |
163 | return | 163 | return |
164 | } | 164 | } |
165 | + | ||
166 | +func GetCfgAppVersion(versionNo,channel int)(v *CfgAppVersion, err error) { | ||
167 | + o := orm.NewOrm() | ||
168 | + sql :=`select * from cfg_app_version where version_no =? and channel =? and enabled=1` | ||
169 | + if err = o.Raw(sql,versionNo,channel).QueryRow(&v); err == nil { | ||
170 | + return v, nil | ||
171 | + } | ||
172 | + return nil, err | ||
173 | +} |
protocol/version.go
0 → 100644
1 | +package protocol | ||
2 | + | ||
3 | +/*GetLatestVersionInfo */ | ||
4 | +type GetLatestVersionInfoRequest struct { | ||
5 | + VersionNo int `json:"versionNo" valid:"Require"` | ||
6 | + Channel int `json:"channel" valid:"Require"` | ||
7 | +} | ||
8 | +type GetLatestVersionInfoResponse struct { | ||
9 | + Version *VersionInfo `json:"version"` | ||
10 | + | ||
11 | +} | ||
12 | +type VersionInfo struct { | ||
13 | + VersionName string `json:"versionName"` | ||
14 | + VersionNo string `json:"versionNo"` | ||
15 | + Title string `json:"title"` | ||
16 | + Content string `json:"content"` | ||
17 | + DownloadPage string `json:"downloadPage"` //下载页面(android使用) | ||
18 | + DownloadFile string `json:"downloadFile"` //下载文件(android使用) | ||
19 | + UpdateType int8 `json:"UpdateType"` //0不需要更新 1是引导更新 2是强制更新 | ||
20 | +} | ||
21 | + | ||
22 | + |
services/version/version.go
0 → 100644
1 | +package version | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/mmm-go/ability/models" | ||
5 | + "gitlab.fjmaimaimai.com/mmm-go/ability/protocol" | ||
6 | + "strconv" | ||
7 | +) | ||
8 | + | ||
9 | +func GetLatestVersionInfo(request *protocol.GetLatestVersionInfoRequest)(rsp *protocol.GetLatestVersionInfoResponse,err error){ | ||
10 | + var ( | ||
11 | + versionInfo *protocol.VersionInfo | ||
12 | + ) | ||
13 | + versionInfo,err = GetVersionInfo(request.VersionNo,request.Channel) | ||
14 | + if err!=nil{ | ||
15 | + return | ||
16 | + } | ||
17 | + rsp =&protocol.GetLatestVersionInfoResponse{ | ||
18 | + Version:versionInfo, | ||
19 | + } | ||
20 | + return | ||
21 | +} | ||
22 | +//获取版本信息 | ||
23 | +func GetVersionInfo(versionNo,channel int)(v *protocol.VersionInfo,err error){ | ||
24 | + cfgAppVersion,err :=models.GetCfgAppVersion(versionNo,channel) | ||
25 | + if err!=nil{ | ||
26 | + return | ||
27 | + } | ||
28 | + v =&protocol.VersionInfo{ | ||
29 | + VersionName:cfgAppVersion.VersionName, | ||
30 | + VersionNo:strconv.Itoa(cfgAppVersion.VersionNo), | ||
31 | + Title:cfgAppVersion.Title, | ||
32 | + Content:cfgAppVersion.Content, | ||
33 | + DownloadPage:cfgAppVersion.DownloadPage, | ||
34 | + DownloadFile:cfgAppVersion.DownloadFile, | ||
35 | + UpdateType:cfgAppVersion.Type, | ||
36 | + } | ||
37 | + return | ||
38 | +} |
-
请 注册 或 登录 后发表评论