This commit is contained in:
parent
c3ff7fae4a
commit
6b800705c5
|
@ -12,6 +12,7 @@ type ApiCreateReq struct {
|
|||
}
|
||||
|
||||
type ApiCreateData struct {
|
||||
Id int64 `json:"id"`
|
||||
}
|
||||
|
||||
type ApiCreateResp struct {
|
||||
|
|
|
@ -12,14 +12,17 @@ import (
|
|||
|
||||
func ApiCreateRavenIQTest(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*Raven_IQ_testproto.ApiCreateReq)
|
||||
ec := service.DefaultService.ApiCreateRavenIQTest(ctx, req)
|
||||
id, ec := service.DefaultService.ApiCreateRavenIQTest(ctx, req)
|
||||
if ec != errcode.ErrCodeRavenIQTestSrvOk {
|
||||
logger.Error("ApiCreateRavenIQTest fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrorMsg(ctx, "server error")
|
||||
return
|
||||
}
|
||||
|
||||
ReplyOk(ctx, nil)
|
||||
data := &Raven_IQ_testproto.ApiCreateData{
|
||||
Id: id,
|
||||
}
|
||||
ReplyOk(ctx, data)
|
||||
}
|
||||
|
||||
func ApiGetRavenIQTestList(ctx *gin.Context) {
|
||||
|
|
|
@ -3589,7 +3589,7 @@ func (s *Service) ApiHvyogoWorkerUpdate(ctx *gin.Context, req *hvyogoproto.ApiWo
|
|||
}
|
||||
|
||||
// RavenIQTest
|
||||
func (s *Service) ApiCreateRavenIQTest(ctx *gin.Context, req *Raven_IQ_testproto.ApiCreateReq) (ec errcode.ErrCode) {
|
||||
func (s *Service) ApiCreateRavenIQTest(ctx *gin.Context, req *Raven_IQ_testproto.ApiCreateReq) (id int64, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeRavenIQTestSrvOk
|
||||
|
||||
// 缓存数据准备
|
||||
|
@ -3597,7 +3597,7 @@ func (s *Service) ApiCreateRavenIQTest(ctx *gin.Context, req *Raven_IQ_testproto
|
|||
err := apollo.GetJson(consts.QuestionMapKey, &questionMapcfg, apollo.ApolloOpts().SetNamespace("Raven_IQ_test"))
|
||||
if err != nil {
|
||||
logger.Error("Apollo read failed : %v", err)
|
||||
return errcode.ErrCodeApolloReadFail
|
||||
return -1, errcode.ErrCodeApolloReadFail
|
||||
}
|
||||
|
||||
ageScore2IQResultMapCfg := apollostruct.AgeScore2IQResultMapCfg{}
|
||||
|
@ -3624,7 +3624,7 @@ func (s *Service) ApiCreateRavenIQTest(ctx *gin.Context, req *Raven_IQ_testproto
|
|||
for _, answer := range req.AnswerList {
|
||||
question, ok := questionMapcfg.Map[answer.GetQuestionId()]
|
||||
if !ok {
|
||||
return errcode.ErrCodeRavenIQTestQuestionNotExist
|
||||
return -1, errcode.ErrCodeRavenIQTestQuestionNotExist
|
||||
}
|
||||
if answer.GetSelectedOption() == question.CorrectOption {
|
||||
classScoreMap[answer.GetQuestionId()] += 1
|
||||
|
@ -3665,6 +3665,8 @@ func (s *Service) ApiCreateRavenIQTest(ctx *gin.Context, req *Raven_IQ_testproto
|
|||
ec = errcode.ErrCodeRavenIQTestSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
id = req.RavenIQTest.GetId()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue