// 实时数据
package controllers

import (
	"box-gm/models"

	"github.com/astaxie/beego"
)

type VersionController struct {
	beego.Controller
}

func (c *VersionController) Get() {
	channel, _ := c.GetInt64("channel")
	cp := models.GetHotfixInfoByChannel(channel)
	if cp == nil {
		c.Data["json"] = &map[string]interface{}{
			"code":   400,
			"msg":    "无此渠道配置"}
		c.ServeJSON()
		return
	}
	params := make(map[string]interface{})
	params["channel"] = channel
	params["version"] = cp.Version
	params["addr"] = cp.DowloadAddr
	params["filesize"] = cp.FileSize
	c.Data["json"] = &map[string]interface{}{
		"code":   200,
		"msg":    "成功",
		"data": &params}
	c.ServeJSON()
}
