|
@@ -98,13 +98,20 @@ func (s LearningQuestionService) List(ctx context.Context, req *learning.Learnin
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return 0, nil, err
|
|
return 0, nil, err
|
|
|
}
|
|
}
|
|
|
|
|
+ questions, err := ConvLearningQuestionGetRsp(ent)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return 0, nil, err
|
|
|
|
|
+ }
|
|
|
|
|
+ return total, questions, err
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
+func ConvLearningQuestionGetRsp(ent []*learning.LearningQuestion) ([]*learning.LearningQuestionGetRsp, error) {
|
|
|
var questions []*learning.LearningQuestionGetRsp
|
|
var questions []*learning.LearningQuestionGetRsp
|
|
|
for _, q := range ent {
|
|
for _, q := range ent {
|
|
|
content := []learning.LearningQuestionOption{}
|
|
content := []learning.LearningQuestionOption{}
|
|
|
- err = json.Unmarshal([]byte(q.Content), &content)
|
|
|
|
|
|
|
+ err := json.Unmarshal([]byte(q.Content), &content)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return 0, nil, err
|
|
|
|
|
|
|
+ return nil, err
|
|
|
}
|
|
}
|
|
|
answer := []string{}
|
|
answer := []string{}
|
|
|
for _, item := range content {
|
|
for _, item := range content {
|
|
@@ -118,7 +125,7 @@ func (s LearningQuestionService) List(ctx context.Context, req *learning.Learnin
|
|
|
Content: content,
|
|
Content: content,
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
- return total, questions, err
|
|
|
|
|
|
|
+ return questions, nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (s LearningQuestionService) Add(ctx context.Context, req *learning.LearningQuestionAddReq) (int, error) {
|
|
func (s LearningQuestionService) Add(ctx context.Context, req *learning.LearningQuestionAddReq) (int, error) {
|