noticeController.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * @Author: lilig
  3. * @Date: 2022-09-17 10:07:52
  4. * @LastEditors: lilifor
  5. * @LastEditTime: 2022-09-17 14:44:58
  6. * @FilePath: \SCD\controllers\wsController.go
  7. * @Description:
  8. *
  9. * Copyright (c) 2022 by lilig/jujutong, All Rights Reserved.
  10. */
  11. package controllers
  12. import (
  13. "scd_check_tools/models/bo"
  14. "strconv"
  15. )
  16. type NoticeController struct {
  17. BaseController
  18. }
  19. func init() {
  20. }
  21. /**
  22. * @description: 获取指定站的锁定签入签出流程记录列表
  23. * @Author: liling
  24. * @method: get
  25. * @parameter: stationid
  26. * @url: /list
  27. * @content-type: application/json
  28. * @return json格式
  29. */
  30. // @Summary 获取指定站的通知提醒列表
  31. // @Description 获取指定站的通知提醒列表
  32. // @Tags 通知提醒服务接口
  33. // @Accept x-www-form-urlencoded
  34. // @Produce json
  35. // @Param station_id query string true "变电站ID"
  36. // @Param pageno query int false "当前页码。默认为1"
  37. // @Param pagesize query int false "每页显示记录数。默认为20"
  38. // @Param isread query int false "是否已读。0 未读或1 已读"
  39. // @Success 200 {object} ResultOK 成功
  40. // @Failure 500 {object} ResultError 失败
  41. // @router /notice/list [get]
  42. func (c *NoticeController) GetNoticeList() {
  43. stationid, _ := c.GetInt32("station_id")
  44. pageno, _ := c.GetInt32("pageno", 1)
  45. pagesize, _ := c.GetInt32("pagesize", 20)
  46. isread, _ := c.GetInt32("isread", -1)
  47. flowObj := new(bo.NoticeMgr)
  48. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  49. uid, _ := strconv.Atoi(flowObj.GetUserId())
  50. list, cnt, err := flowObj.List(int32(uid), stationid, isread, c.GetString("caption"), c.GetString("type"), pageno, pagesize)
  51. if err != nil {
  52. c.Data["json"] = c.ResultError(err.Error())
  53. c.ServeJSON()
  54. return
  55. }
  56. c.Data["json"] = c.ResultOK(list, cnt)
  57. c.ServeJSON()
  58. }
  59. // @Summary 获取指定通知提醒详细信息
  60. // @Description 获取指定通知提醒详细信息
  61. // @Tags 通知提醒服务接口
  62. // @Accept x-www-form-urlencoded
  63. // @Produce json
  64. // @Param id query int true "通知提醒记录ID"
  65. // @Success 200 {object} ResultOK 成功
  66. // @Failure 500 {object} ResultError 失败
  67. // @router /notice/info [get]
  68. func (c *NoticeController) GetNoticeInfo() {
  69. id, _ := c.GetInt("id")
  70. if id == 0 {
  71. c.Data["json"] = c.ResultError("通知提醒编号不能为空!")
  72. c.ServeJSON()
  73. return
  74. }
  75. flowObj := new(bo.NoticeMgr)
  76. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  77. flowObj.Model = bo.T_base_notice{}
  78. flowObj.Model.Id = id
  79. list, err := flowObj.One()
  80. if err != nil {
  81. c.Data["json"] = c.ResultError(err.Error())
  82. c.ServeJSON()
  83. return
  84. }
  85. c.Data["json"] = c.ResultOK(list, 1)
  86. c.ServeJSON()
  87. }
  88. // @Summary 设置指定通知提醒为已读
  89. // @Description 设置指定通知提醒为已读
  90. // @Tags 通知提醒服务接口
  91. // @Accept x-www-form-urlencoded
  92. // @Produce json
  93. // @Param id formData int true "通知提醒记录ID"
  94. // @Success 200 {object} ResultOK 成功
  95. // @Failure 500 {object} ResultError 失败
  96. // @router /notice/read [post]
  97. func (c *NoticeController) SetNoticeRead() {
  98. id, _ := c.GetInt("id")
  99. if id == 0 {
  100. c.Data["json"] = c.ResultError("通知提醒编号不能为空!")
  101. c.ServeJSON()
  102. return
  103. }
  104. flowObj := new(bo.NoticeMgr)
  105. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  106. flowObj.Model = bo.T_base_notice{}
  107. flowObj.Model.Id = id
  108. err := flowObj.SetRead()
  109. if err != nil {
  110. c.Data["json"] = c.ResultError(err.Error())
  111. c.ServeJSON()
  112. return
  113. }
  114. c.Data["json"] = c.ResultOK("", 0)
  115. c.ServeJSON()
  116. }