123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- package controllers
- import (
- "eta/eta_mini_crm/models"
- "eta/eta_mini_crm/models/response"
- "eta/eta_mini_crm/utils"
- "github.com/rdlucklib/rdluck_tools/paging"
- )
- type SysMessageReportController struct {
- BaseAuthController
- }
- // @Title 阅读消息
- // @Description 阅读消息
- // @Param request body system.SysRoleDeleteReq true "type json string"
- // @Success 200 查看成功
- // @router /read [post]
- func (this *SysMessageReportController) Read() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- err := models.UpdateReadSysMessageReportByUserId(this.SysUser.SysUserId)
- if err != nil {
- br.Msg = "更新消息状态失败"
- br.ErrMsg = "更新消息状态失败,系统错误,Err:" + err.Error()
- return
- }
- br.Msg = "查看成功"
- br.Success = true
- br.Ret = 200
- }
- // List
- // @Title 系统消息列表
- // @Description 系统消息列表
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} response.SysRoleListResp
- // @router /list [get]
- func (this *SysMessageReportController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- total, err := models.GetSysMessageReportCountBySysUserId(this.SysUser.SysUserId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- list, err := models.GetSysMessageReportBySysUserId(this.SysUser.SysUserId, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- messageList := make([]*models.SysMessageReportView, 0)
- for _, v := range list {
- messageList = append(messageList, &models.SysMessageReportView{
- SysMessageReportId: v.SysMessageReportId,
- UserId: v.UserId,
- ReceiveSysUserId: v.ReceiveSysUserId,
- MessageType: v.MessageType,
- Content: v.Content,
- Remark: v.Remark,
- IsRead: v.IsRead,
- CreateTime: v.CreateTime.Format(utils.FormatDateTime),
- ModifyTime: v.ModifyTime.Format(utils.FormatDateTime),
- })
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(response.SysMessageListResp)
- resp.List = messageList
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|