From d74af2c693bb87c52e9571f8a8703f059f43f37a Mon Sep 17 00:00:00 2001 From: Leufolium Date: Wed, 24 Jul 2024 14:14:26 +0800 Subject: [PATCH] By Robin at 20240724 --- api/proto/Raven_IQ_test/proto/Raven_IQ_test_vo_api.go | 3 ++- apollostruct/RavenIQtest.go | 10 ++++++++-- app/mix/service/apiservice.go | 3 ++- dbstruct/RavenIQTest.go | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/api/proto/Raven_IQ_test/proto/Raven_IQ_test_vo_api.go b/api/proto/Raven_IQ_test/proto/Raven_IQ_test_vo_api.go index d481f205..b3581490 100644 --- a/api/proto/Raven_IQ_test/proto/Raven_IQ_test_vo_api.go +++ b/api/proto/Raven_IQ_test/proto/Raven_IQ_test_vo_api.go @@ -17,6 +17,7 @@ type ApiListVO struct { type ApiClassScoreVO struct { ClassBlockId int64 `json:"class_block_id"` // 大类得分key Score int64 `json:"score"` // 总分 + *apollostruct.ClassInfo *apollostruct.ClassResult } @@ -35,7 +36,7 @@ func (vo *ApiListVO) CopyRavenIQTest(test *dbstruct.RavenIQTest) *ApiListVO { vo.ClassScoreList = append(vo.ClassScoreList, &ApiClassScoreVO{ ClassBlockId: score.GetClassBlockId(), Score: score.GetScore(), - ClassResult: &apollostruct.ClassResult{ + ClassInfo: &apollostruct.ClassInfo{ ClassId: score.GetClassId(), }, }) diff --git a/apollostruct/RavenIQtest.go b/apollostruct/RavenIQtest.go index d1641058..402ab644 100644 --- a/apollostruct/RavenIQtest.go +++ b/apollostruct/RavenIQtest.go @@ -13,6 +13,7 @@ type RavenIQTestQuestion struct { type IQResult struct { IQBlockId int64 `json:"IQ_Block_Id"` // IQ分段id + IQGrade string `json:"IQ_grade"` // 智商等级 Percentile int64 `json:"percentile"` // 百分位 Description string `json:"description"` // 描述 Suggestions []string `json:"suggestions"` // 建议 @@ -33,12 +34,16 @@ type IQResultMapCfg struct { } type ClassResult struct { - ClassId int64 `json:"class_id"` // 大类id Description string `json:"description"` // 描述 Analysis string `json:"analysis"` // 成绩分析 Suggestions []*Suggestion `json:"suggestions"` // 建议 } +type ClassInfo struct { + ClassId int64 `json:"class_id"` // 大类id + ClassName string `json:"class_name"` // 大类名称 +} + type Suggestion struct { Title string `json:"title"` Tips []*Tip `json:"tips"` @@ -50,5 +55,6 @@ type Tip struct { } type ClassResultMapCfg struct { - Map map[int64]*ClassResult `json:"map"` + Map map[int64]*ClassResult `json:"map"` + ClassInfoMap map[int64]*ClassInfo `json:"class_info_map"` } diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 568e5b08..87700918 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -3627,7 +3627,7 @@ func (s *Service) ApiCreateRavenIQTest(ctx *gin.Context, req *Raven_IQ_testproto return -1, errcode.ErrCodeRavenIQTestQuestionNotExist } if answer.GetSelectedOption() == question.CorrectOption { - classScoreMap[answer.GetQuestionId()] += 1 + classScoreMap[question.ClassId] += 1 } } @@ -3710,6 +3710,7 @@ func (s *Service) ApiGetRavenIQTestList(ctx *gin.Context, req *Raven_IQ_testprot for _, classScore := range vo.ClassScoreList { classScore.ClassResult = classResultMpCfg.Map[classScore.ClassBlockId] + classScore.ClassInfo = classResultMpCfg.ClassInfoMap[classScore.ClassInfo.ClassId] } return diff --git a/dbstruct/RavenIQTest.go b/dbstruct/RavenIQTest.go index 3747d123..84620a5f 100644 --- a/dbstruct/RavenIQTest.go +++ b/dbstruct/RavenIQTest.go @@ -39,7 +39,7 @@ func (p *RavenIQTest) GetUserId() int64 { } func (p *RavenIQTest) GetAge() int64 { - if p == nil || p.UserId == nil { + if p == nil || p.Age == nil { return 0 } return *p.Age