67 lines
1.6 KiB
Go
67 lines
1.6 KiB
Go
package warorder
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.WarorderInfoReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取系统公告
|
|
func (this *apiComp) Info(session comm.IUserSession, req *pb.WarorderInfoReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
warorders *pb.DBWarorders
|
|
info *pb.Warorder
|
|
otime int64
|
|
err error
|
|
ok bool
|
|
)
|
|
if errdata = this.InfoCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if warorders, err = this.module.modelWarorder.getUserWarorders(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if otime, ok = this.module.modelWarorder.getopentime(req.Rtype); !ok {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_WarorderNoOpen,
|
|
Title: pb.ErrorCode_WarorderNoOpen.ToString(),
|
|
Message: fmt.Sprintf("Activity:%d no open", req.Rtype),
|
|
}
|
|
return
|
|
}
|
|
|
|
if info, ok = warorders.Items[req.Rtype]; !ok {
|
|
info = &pb.Warorder{}
|
|
warorders.Items[req.Rtype] = info
|
|
}
|
|
|
|
if info.Opentime != otime {
|
|
info.Opentime = otime
|
|
info.Freeprogress = 0
|
|
info.Payprogress = 0
|
|
if err = this.module.modelWarorder.updateUserWarorders(session.GetUserId(), warorders); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "info", &pb.WarorderInfoResp{Info: info})
|
|
return
|
|
}
|