|
|
@@ -1,8 +1,10 @@
|
|
|
package cn.reghao.tnb.content.app.vod.service.impl;
|
|
|
|
|
|
+import cn.reghao.jutil.jdk.db.Page;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoRegion;
|
|
|
import cn.reghao.tnb.content.app.vod.db.mapper.VideoCategoryMapper;
|
|
|
import cn.reghao.tnb.content.app.vod.model.po.VideoCategory;
|
|
|
+import cn.reghao.tnb.content.app.vod.model.query.CategoryQuery;
|
|
|
import cn.reghao.tnb.content.app.vod.service.CategoryService;
|
|
|
import cn.reghao.tnb.content.app.util.redis.ds.RedisStringObject;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -24,16 +26,22 @@ public class CategoryServiceImpl implements CategoryService {
|
|
|
}
|
|
|
|
|
|
public List<VideoCategory> getAllCategory() {
|
|
|
- List<VideoCategory> list = videoCategoryMapper.findAll();
|
|
|
+ CategoryQuery categoryQuery = new CategoryQuery.Builder().build();
|
|
|
+ List<VideoCategory> list = getVideoCategories(categoryQuery);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public List<VideoRegion> getCategories(boolean vip) {
|
|
|
- List<VideoCategory> list = videoCategoryMapper.findCategories(vip);
|
|
|
+ CategoryQuery categoryQuery = new CategoryQuery.Builder().build();
|
|
|
+ List<VideoCategory> list = getVideoCategories(categoryQuery);
|
|
|
setVideoCategory(list);
|
|
|
|
|
|
Map<Integer, VideoRegion> map = new HashMap<>(list.size());
|
|
|
- list.forEach(category -> {
|
|
|
+ for (VideoCategory category : list) {
|
|
|
+ if (category.isVip() && !vip) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
int pid = category.getPid();
|
|
|
int id = category.getId();
|
|
|
String name = category.getName();
|
|
|
@@ -45,7 +53,7 @@ public class CategoryServiceImpl implements CategoryService {
|
|
|
} else {
|
|
|
map.get(pid).getChildren().add(new VideoRegion(pid, regionId, id, name, icon, sort));
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
|
|
|
List<VideoRegion> parents = new ArrayList<>(map.values());
|
|
|
parents.sort(Comparator.comparingInt(VideoRegion::getSort));
|
|
|
@@ -55,6 +63,14 @@ public class CategoryServiceImpl implements CategoryService {
|
|
|
return parents;
|
|
|
}
|
|
|
|
|
|
+ public List<VideoCategory> getVideoCategories(CategoryQuery categoryQuery) {
|
|
|
+ int pageNumber = 1;
|
|
|
+ int pageSize = 1000;
|
|
|
+ Page page = new Page(pageNumber, pageSize);
|
|
|
+ List<VideoCategory> list = videoCategoryMapper.findVideoCategoryByPage(page, categoryQuery);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
private void setVideoCategory(List<VideoCategory> list) {
|
|
|
String keyPrefix = "tnb:content:video:category";
|
|
|
list.forEach(videoCategory -> {
|