News.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package controllers
  2. import (
  3. "ERP_user/conf"
  4. "ERP_user/models/Account"
  5. "ERP_user/models/System"
  6. beego "github.com/beego/beego/v2/server/web"
  7. "gogs.baozhida.cn/zoie/ERP_libs/lib"
  8. "math"
  9. )
  10. type NewsController struct {
  11. beego.Controller
  12. User Account.User
  13. }
  14. func (c *NewsController) Prepare() {
  15. c.User = *Account.User_r
  16. }
  17. // 列表 -
  18. func (c *NewsController) List() {
  19. // 分页参数 初始化
  20. page, _ := c.GetInt("page")
  21. if page < 1 {
  22. page = 1
  23. }
  24. page_z, _ := c.GetInt("page_z")
  25. if page_z < 1 {
  26. page_z = conf.Page_size
  27. }
  28. // 查询
  29. T_title := c.GetString("T_title")
  30. T_Tag, _ := c.GetInt("T_Tag")
  31. R_List, R_cnt := System.Read_News_List(c.User.T_uuid, T_title, T_Tag, page, page_z)
  32. var r_jsons lib.R_JSONS
  33. r_jsons.Num = R_cnt
  34. r_jsons.Data = R_List
  35. r_jsons.Page = page
  36. r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z)))
  37. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  38. c.ServeJSON()
  39. return
  40. }
  41. func (c *NewsController) See() {
  42. Id, _ := c.GetInt("Id")
  43. if Id == 0 {
  44. c.Data["json"] = lib.JSONS{Code: 201, Msg: "Id Err!"}
  45. c.ServeJSON()
  46. return
  47. }
  48. if err := System.Update_News_Tag(Id, c.User.T_uuid); err != nil {
  49. c.Data["json"] = lib.JSONS{Code: 200, Msg: "修改失败!"}
  50. c.ServeJSON()
  51. return
  52. }
  53. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  54. c.ServeJSON()
  55. return
  56. }