55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package guidance
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) CompleteCheck(session comm.IUserSession, req *pb.GuidanceCompleteReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// 获取引导信息
|
|
func (this *apiComp) Complete(session comm.IUserSession, req *pb.GuidanceCompleteReq) (errdata *pb.ErrorData) {
|
|
if errdata = this.CompleteCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
var (
|
|
gourmet *pb.DBGuidance
|
|
err error
|
|
ok bool
|
|
)
|
|
if gourmet, err = this.module.modelGuidance.getUserGourmet(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
for _, v := range gourmet.Complete {
|
|
if req.Gid == v {
|
|
ok = true
|
|
}
|
|
}
|
|
|
|
if !ok {
|
|
gourmet.Complete = append(gourmet.Complete, req.Gid)
|
|
}
|
|
|
|
if err = this.module.modelGuidance.Change(session.GetUserId(), map[string]interface{}{
|
|
"complete": gourmet.Complete,
|
|
}); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "complete", &pb.GuidanceCompleteResp{Gid: req.Gid})
|
|
return
|
|
}
|