|
|
@@ -1,17 +1,13 @@
|
|
|
package cn.reghao.tnb.content.app.vod.service.impl;
|
|
|
|
|
|
-import cn.reghao.tnb.common.db.GroupCount;
|
|
|
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.db.mapper.VideoPostMapper;
|
|
|
import cn.reghao.tnb.content.app.vod.model.po.VideoCategory;
|
|
|
import cn.reghao.tnb.content.app.vod.service.CategoryService;
|
|
|
-import cn.reghao.tnb.content.app.util.redis.ds.RedisOps;
|
|
|
import cn.reghao.tnb.content.app.util.redis.ds.RedisStringObject;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author reghao
|
|
|
@@ -20,26 +16,20 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class CategoryServiceImpl implements CategoryService {
|
|
|
private final VideoCategoryMapper videoCategoryMapper;
|
|
|
- private final VideoPostMapper videoPostMapper;
|
|
|
private final RedisStringObject redisStringObject;
|
|
|
- private final RedisOps redisOps;
|
|
|
|
|
|
- public CategoryServiceImpl(VideoCategoryMapper videoCategoryMapper, VideoPostMapper videoPostMapper,
|
|
|
- RedisStringObject redisStringObject, RedisOps redisOps) {
|
|
|
+ public CategoryServiceImpl(VideoCategoryMapper videoCategoryMapper, RedisStringObject redisStringObject) {
|
|
|
this.videoCategoryMapper = videoCategoryMapper;
|
|
|
- this.videoPostMapper = videoPostMapper;
|
|
|
this.redisStringObject = redisStringObject;
|
|
|
- this.redisOps = redisOps;
|
|
|
}
|
|
|
|
|
|
public List<VideoCategory> getAllCategory() {
|
|
|
List<VideoCategory> list = videoCategoryMapper.findAll();
|
|
|
- List<GroupCount> list1 = videoPostMapper.findGroupByCategoryId();
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public List<VideoRegion> getCategories(boolean vip) {
|
|
|
- List<VideoCategory> list = videoCategoryMapper.findAll();
|
|
|
+ List<VideoCategory> list = videoCategoryMapper.findCategories(vip);
|
|
|
setVideoCategory(list);
|
|
|
|
|
|
Map<Integer, VideoRegion> map = new HashMap<>(list.size());
|
|
|
@@ -57,10 +47,6 @@ public class CategoryServiceImpl implements CategoryService {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- if (!vip) {
|
|
|
- map.remove(11);
|
|
|
- }
|
|
|
-
|
|
|
List<VideoRegion> parents = new ArrayList<>(map.values());
|
|
|
parents.sort(Comparator.comparingInt(VideoRegion::getSort));
|
|
|
parents.forEach(videoRegion -> {
|
|
|
@@ -87,19 +73,4 @@ public class CategoryServiceImpl implements CategoryService {
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
- private List<VideoCategory> getVideoCategories() {
|
|
|
- String keyPrefix = "tnb:content:video:category:*";
|
|
|
- Set<String> keys = redisOps.keys(keyPrefix);
|
|
|
- return keys.stream()
|
|
|
- .map(key -> {
|
|
|
- Object value = redisStringObject.get(key);
|
|
|
- if (value instanceof VideoCategory) {
|
|
|
- return (VideoCategory) value;
|
|
|
- }
|
|
|
- return null;
|
|
|
- })
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .collect(Collectors.toList());
|
|
|
- }
|
|
|
}
|