noticeController.go 3.5 KB

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