|
|
@@ -6,7 +6,7 @@ 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.VideoCategoryPostMapper;
|
|
|
import cn.reghao.tnb.content.app.vod.model.dto.CategoryAdd;
|
|
|
-import cn.reghao.tnb.content.app.vod.model.po.VideoCategory;
|
|
|
+import cn.reghao.tnb.content.app.vod.model.po.PostCategory;
|
|
|
import cn.reghao.tnb.content.app.vod.model.po.VideoCategoryPost;
|
|
|
import cn.reghao.tnb.content.app.vod.model.po.VideoPost;
|
|
|
import cn.reghao.tnb.content.app.vod.model.query.CategoryQuery;
|
|
|
@@ -38,11 +38,11 @@ public class CategoryServiceImpl implements CategoryService {
|
|
|
@Override
|
|
|
public List<VideoRegion> getCategories(boolean vip) {
|
|
|
CategoryQuery categoryQuery = new CategoryQuery.Builder().build();
|
|
|
- List<VideoCategory> list = getVideoCategories(categoryQuery);
|
|
|
+ List<PostCategory> list = getVideoCategories(categoryQuery);
|
|
|
setVideoCategory(list);
|
|
|
|
|
|
Map<Integer, VideoRegion> map = new HashMap<>(list.size());
|
|
|
- for (VideoCategory category : list) {
|
|
|
+ for (PostCategory category : list) {
|
|
|
if (category.isVip() && !vip) {
|
|
|
continue;
|
|
|
}
|
|
|
@@ -70,11 +70,11 @@ public class CategoryServiceImpl implements CategoryService {
|
|
|
return parents;
|
|
|
}
|
|
|
|
|
|
- private List<VideoCategory> getVideoCategories(CategoryQuery categoryQuery) {
|
|
|
+ private List<PostCategory> getVideoCategories(CategoryQuery categoryQuery) {
|
|
|
int pageNumber = 1;
|
|
|
int pageSize = 1000;
|
|
|
Page page = new Page(pageNumber, pageSize);
|
|
|
- List<VideoCategory> list = videoCategoryMapper.findVideoCategoryByPage(page, categoryQuery);
|
|
|
+ List<PostCategory> list = videoCategoryMapper.findVideoCategoryByPage(page, categoryQuery);
|
|
|
if (list.isEmpty()) {
|
|
|
initVideoCategory();
|
|
|
}
|
|
|
@@ -83,15 +83,15 @@ public class CategoryServiceImpl implements CategoryService {
|
|
|
}
|
|
|
|
|
|
private void initVideoCategory() {
|
|
|
- VideoCategory videoCategory1 = new VideoCategory(0, "大杂烩");
|
|
|
- videoCategoryMapper.save(videoCategory1);
|
|
|
+ PostCategory postCategory1 = new PostCategory(0, "大杂烩");
|
|
|
+ videoCategoryMapper.save(postCategory1);
|
|
|
|
|
|
- int pid = videoCategory1.getId();
|
|
|
- VideoCategory videoCategory2 = new VideoCategory(pid, "杂");
|
|
|
- videoCategoryMapper.save(videoCategory2);
|
|
|
+ int pid = postCategory1.getId();
|
|
|
+ PostCategory postCategory2 = new PostCategory(pid, "杂");
|
|
|
+ videoCategoryMapper.save(postCategory2);
|
|
|
}
|
|
|
|
|
|
- private void setVideoCategory(List<VideoCategory> list) {
|
|
|
+ private void setVideoCategory(List<PostCategory> list) {
|
|
|
String keyPrefix = "tnb:content:video:category";
|
|
|
list.forEach(videoCategory -> {
|
|
|
int id = videoCategory.getId();
|
|
|
@@ -101,11 +101,11 @@ public class CategoryServiceImpl implements CategoryService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public VideoCategory getVideoCategory(int id) {
|
|
|
+ public PostCategory getVideoCategory(int id) {
|
|
|
String key = String.format("tnb:content:video:category:%s", id);
|
|
|
Object value = redisStringObject.get(key);
|
|
|
- if (value instanceof VideoCategory) {
|
|
|
- return (VideoCategory) value;
|
|
|
+ if (value instanceof PostCategory) {
|
|
|
+ return (PostCategory) value;
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
@@ -113,8 +113,8 @@ public class CategoryServiceImpl implements CategoryService {
|
|
|
|
|
|
@Override
|
|
|
public void addVideoCategory(CategoryAdd categoryAdd) {
|
|
|
- VideoCategory videoCategory1 = new VideoCategory(categoryAdd);
|
|
|
- List<VideoCategory> list = List.of(videoCategory1);
|
|
|
+ PostCategory postCategory1 = new PostCategory(categoryAdd);
|
|
|
+ List<PostCategory> list = List.of(postCategory1);
|
|
|
videoCategoryMapper.saveAll(list);
|
|
|
}
|
|
|
|