This commit is contained in:
meixiongfeng 2023-07-25 11:38:13 +08:00
commit 445d2cf1ea
3 changed files with 35 additions and 15 deletions

View File

@ -48,6 +48,7 @@ func (this *apiComp) Answer(session comm.IUserSession, req *pb.QuestionnaireAnsw
} }
finish = true finish = true
correct = make([]int32, 0) correct = make([]int32, 0)
asks = make([]*cfg.GameAskLibraryData, len(group.Questions))
for i, v := range group.Questions { for i, v := range group.Questions {
if asks[i], err = this.module.configure.getGameAskLibraryDataById(v); err != nil { if asks[i], err = this.module.configure.getGameAskLibraryDataById(v); err != nil {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{
@ -96,7 +97,14 @@ func (this *apiComp) Answer(session comm.IUserSession, req *pb.QuestionnaireAnsw
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype204, 1)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype204, 1))
go this.module.ModuleBuried.TriggerBuried(session.Clone(), tasks...) go this.module.ModuleBuried.TriggerBuried(session.Clone(), tasks...)
} }
if err = this.module.modelQuestionnaire.updateUserQuestionnaire(session.GetUserId(), info); err != nil {
session.SendMsg(string(this.module.GetType()), "answer", &pb.QuestionnaireAnswerResp{Info: info.Group[req.Group], Group: req.Group, Award: award}) errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
session.SendMsg(string(this.module.GetType()), "answer", &pb.QuestionnaireAnswerResp{Info: info.Group[req.Group], Group: req.Group, Complete: finish, Award: award})
return return
} }

View File

@ -30,7 +30,9 @@ func (this *ModelQuestionnaire) Init(service core.IService, module core.IModule,
// 获取用户全部的埋点数据 // 获取用户全部的埋点数据
func (this *ModelQuestionnaire) getUserQuestionnaire(uid string) (results *pb.DBQuestionnaire, err error) { func (this *ModelQuestionnaire) getUserQuestionnaire(uid string) (results *pb.DBQuestionnaire, err error) {
results = &pb.DBQuestionnaire{} results = &pb.DBQuestionnaire{
Group: make(map[int32]*pb.DBQuestionGroup),
}
if err = this.Get(uid, results); err != nil && err != mgo.MongodbNil { if err = this.Get(uid, results); err != nil && err != mgo.MongodbNil {
this.module.Errorln(err) this.module.Errorln(err)
return return

View File

@ -193,9 +193,10 @@ type QuestionnaireAnswerResp struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Group int32 `protobuf:"varint,1,opt,name=group,proto3" json:"group"` Group int32 `protobuf:"varint,1,opt,name=group,proto3" json:"group"`
Info *DBQuestionGroup `protobuf:"bytes,2,opt,name=info,proto3" json:"info"` Info *DBQuestionGroup `protobuf:"bytes,2,opt,name=info,proto3" json:"info"`
Award []*UserAssets `protobuf:"bytes,3,rep,name=award,proto3" json:"award"` //奖励 Complete bool `protobuf:"varint,3,opt,name=complete,proto3" json:"complete"` //是否已完成
Award []*UserAssets `protobuf:"bytes,4,rep,name=award,proto3" json:"award"` //奖励
} }
func (x *QuestionnaireAnswerResp) Reset() { func (x *QuestionnaireAnswerResp) Reset() {
@ -244,6 +245,13 @@ func (x *QuestionnaireAnswerResp) GetInfo() *DBQuestionGroup {
return nil return nil
} }
func (x *QuestionnaireAnswerResp) GetComplete() bool {
if x != nil {
return x.Complete
}
return false
}
func (x *QuestionnaireAnswerResp) GetAward() []*UserAssets { func (x *QuestionnaireAnswerResp) GetAward() []*UserAssets {
if x != nil { if x != nil {
return x.Award return x.Award
@ -273,15 +281,17 @@ var file_questionnaire_questionnaire_msg_proto_rawDesc = []byte{
0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x10, 0x0a, 0x03,
0x71, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x71, 0x69, 0x64, 0x12, 0x16, 0x71, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x71, 0x69, 0x64, 0x12, 0x16,
0x0a, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x0a, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06,
0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x22, 0x78, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x22, 0x94, 0x01, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x73, 0x74,
0x6f, 0x6e, 0x6e, 0x61, 0x69, 0x72, 0x65, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x52, 0x65, 0x73, 0x69, 0x6f, 0x6e, 0x6e, 0x61, 0x69, 0x72, 0x65, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x52, 0x65,
0x70, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28,
0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x24, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x05, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x24, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f,
0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x44, 0x42, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x44, 0x42, 0x51, 0x75, 0x65, 0x73, 0x74,
0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x21, 0x0a, 0x69, 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x1a,
0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08,
0x73, 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x21, 0x0a, 0x05, 0x61, 0x77,
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x61, 0x72, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72,
0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (