|
|
@@ -2,6 +2,7 @@ package learning
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
+ "database/sql"
|
|
|
"fmt"
|
|
|
"lims_adapter/dao/learning"
|
|
|
"lims_adapter/model/learning"
|
|
|
@@ -66,19 +67,25 @@ func (s LearningTestpaperService) Get(ctx context.Context, req *learning.Learnin
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- bind, err := s.QuestionTestpaperDao.Where("TestpaperId", req.Id).All()
|
|
|
- if err != nil {
|
|
|
+
|
|
|
+ questionEnt := []*learning.LearningQuestion{}
|
|
|
+ err = s.QuestionTestpaperDao.
|
|
|
+ LeftJoin("learning_question",
|
|
|
+ "learning_question_testpaper.QuestionId=learning_question.Id").
|
|
|
+ Where("learning_question_testpaper.TestpaperId", req.Id).
|
|
|
+ Fields("learning_question.*").Structs(&questionEnt)
|
|
|
+ if err != nil && err != sql.ErrNoRows {
|
|
|
return nil, err
|
|
|
}
|
|
|
- question := []int{}
|
|
|
- for _, b := range bind {
|
|
|
- question = append(question, b.QuestionId)
|
|
|
+ quesitons, err := ConvLearningQuestionGetRsp(questionEnt)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
}
|
|
|
|
|
|
return &learning.LearningTestpaperGetRsp{
|
|
|
LearningTestpaper: *tp,
|
|
|
ExamRecord: record,
|
|
|
- Question: question,
|
|
|
+ Question: quesitons,
|
|
|
}, nil
|
|
|
}
|
|
|
|