go_dreamfactory/modules/library/api_getfetterlist.go
2023-06-06 09:52:44 +08:00

41 lines
1.1 KiB
Go

package library
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
)
//参数校验
func (this *apiComp) GetFetterListCheck(session comm.IUserSession, req *pb.LibraryGetFetterListReq) (errdata *pb.ErrorData) {
return
}
func (this *apiComp) GetFetterList(session comm.IUserSession, req *pb.LibraryGetFetterListReq) (errdata *pb.ErrorData) {
if code = this.GetFetterListCheck(session, req); code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}
rsp := &pb.LibraryGetFetterListResp{}
rsp.Data = this.module.GetHeroFetterList(session.GetUserId())
for _, v := range rsp.Data {
if !utils.IsToday(v.Ctime) {
update := map[string]interface{}{}
v.Ctime = configure.Now().Unix()
v.Givecount = 0
update["givecount"] = 0
update["ctime"] = v.Ctime
if err := this.module.modelFetter.ChangeList(session.GetUserId(), v.Id, update); err != nil {
this.module.Errorf("modelFetter ChangeList error: %v", err)
}
}
}
session.SendMsg(string(this.module.GetType()), LibraryGetFetterListResp, rsp)
return
}