package commod type SortType int // 1、最新,2、最热/推荐,3、最多播放,4、十分钟以上视频, 5、精华/精选,6、视频 7-最多收藏 8、解锁次数 9、最新热评 const ( New SortType = 1 // 最新上架 MostHot SortType = 2 // 热门推荐 MostWatch SortType = 3 // 最多观看 MostCollect SortType = 7 // 最多收藏 HotComment SortType = 9 // 最新热评 ) var nameMap = map[SortType]string{ New: "最新上架", MostHot: "热门推荐", MostWatch: "最多观看", HotComment: "最新热评", MostCollect: "最多收藏", } func (s SortType) Name() string { name, ok := nameMap[s] if !ok { return "未知排序" } return name } func (s SortType) Item() SortItemData { item := SortItemData{ Value: s, Name: "未知排序", } name, ok := nameMap[s] if !ok { return item } item.Name = name return item } type SortItemData struct { Value SortType `json:"value"` Name string `json:"name"` } // WebSortRules 后台支持修改的排序规则 var WebSortRules = map[string][]SortItemData{ "acgSort": { New.Item(), MostHot.Item(), MostWatch.Item(), MostCollect.Item(), HotComment.Item(), }, "videoSort": { New.Item(), MostHot.Item(), MostWatch.Item(), MostCollect.Item(), HotComment.Item(), }, }