From a8e0d187947492a7ed5df5a0bf39df1e5592960e Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 9 Oct 2024 16:40:59 +0800 Subject: [PATCH] 1 --- api/dao/Question.go | 8 ++++---- api/dto/Question.go | 6 ------ api/requests/Question.go | 16 ++++++++-------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/api/dao/Question.go b/api/dao/Question.go index 544dd64..1e9545d 100644 --- a/api/dao/Question.go +++ b/api/dao/Question.go @@ -155,12 +155,12 @@ func (r *QuestionDao) GetQuestionPageSearch(req requests.GetQuestionPage, page, query = query.Where("question_source = ?", req.QuestionSource) // 一级标签id - if req.FirstLabelId != nil { + if req.FirstLabelId != "" { query = query.Where("first_label_id = ?", req.FirstLabelId) } // 二级标签id - if req.SecondLabelId != nil { + if req.SecondLabelId != "" { query = query.Where("second_label_id = ?", req.SecondLabelId) } @@ -242,12 +242,12 @@ func (r *QuestionDao) GetQuestionCountSearch(req requests.GetQuestionCount) (tot } // 一级标签id - if req.FirstLabelId != nil { + if req.FirstLabelId != "" { query = query.Where("first_label_id = ?", req.FirstLabelId) } // 二级标签id - if req.SecondLabelId != nil { + if req.SecondLabelId != "" { query = query.Where("second_label_id = ?", req.SecondLabelId) } diff --git a/api/dto/Question.go b/api/dto/Question.go index ea7c726..0fc4014 100644 --- a/api/dto/Question.go +++ b/api/dto/Question.go @@ -19,8 +19,6 @@ type QuestionDto struct { QuestionAnswer []string `json:"question_answer"` // 答案 QuestionAnalysis string `json:"question_analysis"` // 解析 Difficulty int `json:"difficulty"` // 难度(0:未知 1:低 2:中 3:高) - FirstLabelId string `json:"first_label_id"` // 一级标签id - SecondLabelId string `json:"second_label_id"` // 二级标签id CreatedAt model.LocalTime `json:"created_at"` // 创建时间 UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 FirstLabel *LabelDto `json:"first_label"` // 一级标签 @@ -41,8 +39,6 @@ func GetQuestionDto(m *model.Question) *QuestionDto { QuestionAnswer: []string{}, QuestionAnalysis: m.QuestionAnalysis, Difficulty: m.Difficulty, - FirstLabelId: fmt.Sprintf("%d", *m.FirstLabelId), - SecondLabelId: fmt.Sprintf("%d", *m.SecondLabelId), CreatedAt: m.CreatedAt, UpdatedAt: m.UpdatedAt, } @@ -66,8 +62,6 @@ func GetQuestionListDto(m []*model.Question) []*QuestionDto { QuestionAnswer: []string{}, QuestionAnalysis: v.QuestionAnalysis, Difficulty: v.Difficulty, - FirstLabelId: fmt.Sprintf("%d", *v.FirstLabelId), - SecondLabelId: fmt.Sprintf("%d", *v.SecondLabelId), CreatedAt: v.CreatedAt, UpdatedAt: v.UpdatedAt, } diff --git a/api/requests/Question.go b/api/requests/Question.go index 528380e..807875e 100644 --- a/api/requests/Question.go +++ b/api/requests/Question.go @@ -20,8 +20,8 @@ type GetQuestionPage struct { QuestionStatus *int `json:"question_status" form:"question_status" label:"状态"` QuestionSource int `json:"question_source" form:"question_source" validate:"required,oneof=1 2" label:"题目来源"` // 题目来源(1:本题库 2:外部数据) Difficulty *int `json:"difficulty" form:"difficulty" label:"难度"` - FirstLabelId *string `json:"first_label_id" form:"first_label_id" label:"一级标签id"` - SecondLabelId *string `json:"second_label_id" form:"second_label_id" label:"二级标签id"` + FirstLabelId string `json:"first_label_id" form:"first_label_id" label:"一级标签id"` + SecondLabelId string `json:"second_label_id" form:"second_label_id" label:"二级标签id"` CreatedAt string `json:"created_at" form:"created_at" label:"创建时间"` UpdatedAt string `json:"updated_at" form:"updated_at" label:"修改时间"` Order *GetQuestionPageOrder `json:"order" form:"order" label:"排序"` @@ -107,10 +107,10 @@ type DeleteQuestion struct { // GetQuestionCount 获取题目数量 type GetQuestionCount struct { - QuestionType *int `json:"question_type" form:"question_type" validate:"omitempty,oneof=1 2 3 4" label:"题目类型"` // 题目类型(1:单选 2:多选 3:问答 4:判断) - QuestionStatus *int `json:"question_status" form:"question_status" label:"状态"` - QuestionSource *int `json:"question_source" form:"question_source" validate:"omitempty,oneof=1 2" label:"题目来源"` // 题目来源(1:本题库 2:外部数据) - Difficulty *int `json:"difficulty" form:"difficulty" label:"难度"` - FirstLabelId *string `json:"first_label_id" form:"first_label_id" label:"一级标签id"` - SecondLabelId *string `json:"second_label_id" form:"second_label_id" label:"二级标签id"` + QuestionType *int `json:"question_type" form:"question_type" validate:"omitempty,oneof=1 2 3 4" label:"题目类型"` // 题目类型(1:单选 2:多选 3:问答 4:判断) + QuestionStatus *int `json:"question_status" form:"question_status" label:"状态"` + QuestionSource *int `json:"question_source" form:"question_source" validate:"omitempty,oneof=1 2" label:"题目来源"` // 题目来源(1:本题库 2:外部数据) + Difficulty *int `json:"difficulty" form:"difficulty" label:"难度"` + FirstLabelId string `json:"first_label_id" form:"first_label_id" label:"一级标签id"` + SecondLabelId string `json:"second_label_id" form:"second_label_id" label:"二级标签id"` }