go_dreamfactory/modules/notify/api_getlist.go
2023-06-06 11:08:14 +08:00

49 lines
1.3 KiB
Go

package notify
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
)
//参数校验
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.NotifyGetListReq) (errdata *pb.ErrorData) {
return
}
///获取系统公告
func (this *apiComp) GetList(session comm.IUserSession, req *pb.NotifyGetListReq) (errdata *pb.ErrorData) {
var (
err error
userexpand *pb.DBUserExpand
notify []*pb.DBSystemNotify
)
if notify, err = this.module.modelNotify.GetFullNotify(); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
if session.GetUserId() != "" {
if userexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
} else {
userexpand = &pb.DBUserExpand{}
}
//修改最后公告读取时间
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
"lastreadnotiftime": configure.Now().Unix(),
})
session.SendMsg(string(this.module.GetType()), "getlist", &pb.NotifyGetListResp{LastReadTime: userexpand.Lastreadnotiftime, SysNotify: notify})
return
}