🎨 优化model

This commit is contained in:
2022-05-26 15:40:21 +08:00
parent 2d467c710f
commit 8c5fa60081
8 changed files with 33 additions and 28 deletions

View File

@@ -19,6 +19,10 @@ func (problemService) GetList(p param.GetProblemList) (records entity.Problem, c
if p.Keyword != "" {
sel.Where("title LIKE ? OR content like ?", "%"+p.Keyword+"%", "%"+p.Keyword+"%")
}
if p.CategoryIdentity != "" {
sel.Joins("RIGHT JOINN problem_category pc on pc.problem_id = problem.id").
Where("pc.category_id= (SELECT cb.id FROM category cb WHERE cb.identity = ?)", p.CategoryIdentity)
}
err = sel.Order("updated_at DESC").Find(&records).Offset(-1).Limit(-1).Count(&count).Error
return