123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package controllers
- import (
- "ERP_user/conf"
- "ERP_user/models/Account"
- "ERP_user/models/System"
- "git.baozhida.cn/ERP_libs/lib"
- beego "github.com/beego/beego/v2/server/web"
- "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
- }
|