🎨 一堆杂七杂八的优化

This commit is contained in:
2025-09-01 21:30:10 +08:00
parent 3beb54c12c
commit 80decc222f
7 changed files with 71 additions and 17 deletions

View File

@@ -35,6 +35,17 @@ func (ArticleService) GetArticleList(pageInfo request.GetList) (list []article.A
offset := pageInfo.PageSize * (pageInfo.Page - 1)
// 创建db
db := global.GVA_DB.Model(&article.Article{})
if pageInfo.Title != "" {
db = db.Where("title LIKE ?", "%"+pageInfo.Title+"%")
}
if pageInfo.CategoryId != 0 {
db = db.Where("category_id = ?", pageInfo.CategoryId)
}
if pageInfo.TeacherId != 0 {
db = db.Where("teacher_id = ?", pageInfo.TeacherId)
}
err = db.Count(&total).Error
if err != nil {
return