44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package dispatch
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
"go_dreamfactory/utils"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// 公告板信息
|
|
|
|
func (a *apiComp) NoticeCheck(session comm.IUserSession, req *pb.DispatchNoticeReq) (code pb.ErrorCode) {
|
|
return
|
|
}
|
|
|
|
func (a *apiComp) Notice(session comm.IUserSession, req *pb.DispatchNoticeReq) (code pb.ErrorCode, data proto.Message) {
|
|
d := a.module.modelDispatch.getDBDispatch(session.GetUserId())
|
|
if d == nil {
|
|
code = pb.ErrorCode_DataNotFound
|
|
return
|
|
}
|
|
rsp := &pb.DispatchNoticeResp{}
|
|
|
|
if len(d.Nb.Tasks) == 0 {
|
|
rsp.Dispatch = a.module.modelDispatch.initDispatch(session.GetUserId(), d)
|
|
} else {
|
|
//周任务重置
|
|
n := utils.DiffDays(d.Nb.CreateTime, configure.Now().Unix())
|
|
day := a.module.configure.GetGlobalConf().DispatchWeektaskcheck
|
|
if int32(n) >= day {
|
|
d.Nb.WeekCount = 0
|
|
d.Nb.WeekReceived = []int32{}
|
|
}
|
|
|
|
a.module.modelDispatch.updateNotice(session.GetUserId(), d)
|
|
rsp.Dispatch = d.Nb
|
|
}
|
|
|
|
session.SendMsg(string(a.module.GetType()), "notice", rsp)
|
|
return
|
|
}
|