package controllers import ( "ERP_user/conf" "ERP_user/models/Account" "ERP_user/models/System" beego "github.com/beego/beego/v2/server/web" "gogs.baozhida.cn/zoie/ERP_libs/lib" "math" ) type NewsController struct { beego.Controller User Account.User } func (c *NewsController) Prepare() { c.User = *Account.User_r } // 列表 - func (c *NewsController) List() { // 分页参数 初始化 page, _ := c.GetInt("page") if page < 1 { page = 1 } page_z, _ := c.GetInt("page_z") if page_z < 1 { page_z = conf.Page_size } // 查询 T_title := c.GetString("T_title") T_Tag, _ := c.GetInt("T_Tag") R_List, R_cnt := System.Read_News_List(c.User.T_uuid, T_title, T_Tag, page, page_z) var r_jsons lib.R_JSONS r_jsons.Num = R_cnt r_jsons.Data = R_List r_jsons.Page = page r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z))) c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons} c.ServeJSON() return } func (c *NewsController) See() { Id, _ := c.GetInt("Id") if Id == 0 { c.Data["json"] = lib.JSONS{Code: 201, Msg: "Id Err!"} c.ServeJSON() return } if err := System.Update_News_Tag(Id, c.User.T_uuid); err != nil { c.Data["json"] = lib.JSONS{Code: 200, Msg: "修改失败!"} c.ServeJSON() return } c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"} c.ServeJSON() return }