🎨 分类新增文章分类字段,优化查询接口

This commit is contained in:
2025-09-06 21:46:57 +08:00
parent 45a95be1d8
commit 90bd42d488
4 changed files with 27 additions and 3 deletions

View File

@@ -86,10 +86,20 @@ func (catService *CategoryService) GetCategoryPublic(ctx context.Context) {
}
func (catService *CategoryService) GetIndexCategoryList() (list []category.Category, err error) {
err = global.GVA_DB.Model(&category.Category{}).Where("categories.index = 1").Find(&list).Error
err = global.GVA_DB.Model(&category.Category{}).Where("categories.index = 1 and categories.is_article=0").Find(&list).Error
if err != nil {
global.GVA_LOG.Error("获取首页分类失败", zap.Error(err))
return nil, err
}
return
}
// GetArticleCategoryList 获取文章分类
func (catService *CategoryService) GetArticleCategoryList() (list []category.Category, err error) {
err = global.GVA_DB.Model(&category.Category{}).Where("categories.is_article = 1").Find(&list).Error
if err != nil {
global.GVA_LOG.Error("获取文章分类失败", zap.Error(err))
return
}
return
}