🎨 一堆杂七杂八的优化
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user