| | |
| | | // @router /version [get] |
| | | func (c *AppController) Version() { |
| | | curV := c.GetString("curVersion") |
| | | fmt.Println("curV:", curV) |
| | | platform := c.GetString("platform") |
| | | fmt.Println("platform:",platform,"curV:", curV) |
| | | if platform == "" { |
| | | platform = "android" |
| | | } |
| | | pType := models.PlatType_Android |
| | | if platform != "android" { |
| | | pType = models.PlatType_Ios |
| | | } |
| | | result := vo.Upgrade{} |
| | | var sv models.SysUpgrade |
| | | err := sv.GetLatest() |
| | | err := sv.GetLatest(pType) |
| | | if err != nil { |
| | | result.Msg = []string{} |
| | | } else { |
| | |
| | | Time string `orm:"column(time)" json:"time"` |
| | | Msg string `orm:"column(msg)" json:"msg"` |
| | | Size string `orm:"column(size)" json:"size"` |
| | | |
| | | PlatType int `orm:"column(platType);default(0);" json:"platType"` //0:安卓平台,1:ios平台 |
| | | } |
| | | |
| | | const ( |
| | | PlatType_Android = 0 //安卓平台 |
| | | PlatType_Ios = 1 //ios |
| | | ) |
| | | |
| | | func (sv *SysUpgrade) TableName() string { |
| | | return "sys_upgrade" |
| | | } |
| | | |
| | | func (sv *SysUpgrade) GetLatest() error { |
| | | func (sv *SysUpgrade) GetLatest(pType int) error { |
| | | o := orm.NewOrm() |
| | | err := o.QueryTable(sv.TableName()).OrderBy("-time").One(sv) |
| | | err := o.QueryTable(sv.TableName()).Filter("platType", pType).OrderBy("-time").One(sv) |
| | | return err |
| | | } |
| | | |