feat: 订阅列表和免费列表
This commit is contained in:
@@ -34,9 +34,26 @@ func (s *CategoryService) GetCategoryList(info radioReq.GetCategoryList) ([]radi
|
||||
return list, total, err
|
||||
}
|
||||
|
||||
// GetCategoryTree 返回带频道的分类树
|
||||
func (s *CategoryService) GetCategoryTree() ([]radio.RadioCategory, error) {
|
||||
var res []radio.RadioCategory
|
||||
|
||||
// 1. 查询分类并预加载关联的频道
|
||||
// Preload("Channels") 会自动根据 CategoryId 匹配
|
||||
// Preload("Icon") 和 Preload("Cover") 用于加载 OSS 信息
|
||||
err := global.DB.Model(&radio.RadioCategory{}).
|
||||
Preload("Channels", "status = ?", 1). // 只加载启用的频道
|
||||
Preload("Channels.Cover"). // 级联加载频道的封面
|
||||
Preload("Icon").
|
||||
Preload("Cover").
|
||||
Order("sort desc").
|
||||
Find(&res).Error
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (s *CategoryService) GetAllCategory() ([]radio.RadioCategory, error) {
|
||||
var res []radio.RadioCategory
|
||||
err := global.DB.Find(&res).Preload(":Icon").Preload("Cover").Error
|
||||
err := global.DB.Find(&res).Preload("Icon").Preload("Cover").Error
|
||||
return res, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user