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