This commit is contained in:
wucongxing8150 2024-10-09 16:40:59 +08:00
parent f862bd28e1
commit a8e0d18794
3 changed files with 12 additions and 18 deletions

View File

@ -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)
}

View File

@ -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,
}

View File

@ -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:"排序"`
@ -111,6 +111,6 @@ type GetQuestionCount struct {
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"`
FirstLabelId string `json:"first_label_id" form:"first_label_id" label:"一级标签id"`
SecondLabelId string `json:"second_label_id" form:"second_label_id" label:"二级标签id"`
}