123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- /*
- * @Author: lilig
- * @Date: 2022-09-17 10:07:52
- * @LastEditors: lilifor
- * @LastEditTime: 2022-09-17 14:44:58
- * @FilePath: \SCD\controllers\wsController.go
- * @Description:
- *
- * Copyright (c) 2022 by lilig/jujutong, All Rights Reserved.
- */
- package controllers
- import (
- "scd_check_tools/models/bo"
- "strconv"
- )
- //通知提醒服务
- type NoticeController struct {
- BaseController
- }
- func init() {
- }
- /**
- * @description: 获取指定站的锁定签入签出流程记录列表
- * @Author: liling
- * @method: get
- * @parameter: stationid
- * @url: /list
- * @content-type: application/json
- * @return json格式
- */
- // @Summary 获取指定站的通知提醒列表
- // @Description 获取指定站的通知提醒列表
- // @Tags 通知提醒服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param station_id query string true "变电站ID"
- // @Param pageno query int false "当前页码。默认为1"
- // @Param pagesize query int false "每页显示记录数。默认为20"
- // @Param isread query int false "是否已读。0 未读或1 已读"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 {object} ResultError 失败
- // @router /notice/list [get]
- func (c *NoticeController) GetNoticeList() {
- stationid, _ := c.GetInt32("station_id")
- pageno, _ := c.GetInt32("pageno", 1)
- pagesize, _ := c.GetInt32("pagesize", 20)
- isread, _ := c.GetInt32("isread", -1)
- flowObj := new(bo.NoticeMgr)
- flowObj.SetUserInfo(c.GetCurrentUserInfo())
- uid, _ := strconv.Atoi(flowObj.GetUserId())
- list, cnt, err := flowObj.List(int32(uid), stationid, isread, c.GetString("caption"), c.GetString("type"), pageno, pagesize)
- if err != nil {
- c.Data["json"] = c.ResultError(err.Error())
- c.ServeJSON()
- return
- }
- c.Data["json"] = c.ResultOK(list, cnt)
- c.ServeJSON()
- }
- // @Summary 获取指定通知提醒详细信息
- // @Description 获取指定通知提醒详细信息
- // @Tags 通知提醒服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param id query int true "通知提醒记录ID"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 {object} ResultError 失败
- // @router /notice/info [get]
- func (c *NoticeController) GetNoticeInfo() {
- id, _ := c.GetInt("id")
- if id == 0 {
- c.Data["json"] = c.ResultError("通知提醒编号不能为空!")
- c.ServeJSON()
- return
- }
- flowObj := new(bo.NoticeMgr)
- flowObj.SetUserInfo(c.GetCurrentUserInfo())
- flowObj.Model = bo.T_base_notice{}
- flowObj.Model.Id = id
- list, err := flowObj.One()
- if err != nil {
- c.Data["json"] = c.ResultError(err.Error())
- c.ServeJSON()
- return
- }
- c.Data["json"] = c.ResultOK(list, 1)
- c.ServeJSON()
- }
- // @Summary 设置指定通知提醒为已读
- // @Description 设置指定通知提醒为已读
- // @Tags 通知提醒服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param id formData int true "通知提醒记录ID"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 {object} ResultError 失败
- // @router /notice/read [post]
- func (c *NoticeController) SetNoticeRead() {
- id, _ := c.GetInt("id")
- if id == 0 {
- c.Data["json"] = c.ResultError("通知提醒编号不能为空!")
- c.ServeJSON()
- return
- }
- flowObj := new(bo.NoticeMgr)
- flowObj.SetUserInfo(c.GetCurrentUserInfo())
- flowObj.Model = bo.T_base_notice{}
- flowObj.Model.Id = id
- err := flowObj.SetRead()
- if err != nil {
- c.Data["json"] = c.ResultError(err.Error())
- c.ServeJSON()
- return
- }
- c.Data["json"] = c.ResultOK("", 0)
- c.ServeJSON()
- }
|