1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package com.tanpu.community.manager;
import com.tanpu.community.api.constants.BlockTypeEnum;
import com.tanpu.community.api.constants.CollectionTypeEnum;
import com.tanpu.community.api.constants.CommentTypeEnum;
import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class ThemeManager {
@Resource
private ThemeService themeService;
@Autowired
private CollectionService collectionService;
@Autowired
private CommentService commentService;
@Autowired
private FansRelService fansRelService;
@Autowired
private BlackListService blackListService;
//返回推荐主题文章
public List<ThemeEntity> selectHotThemes(){
//TOTO:根据算法计算推荐主题
return null;
}
//返回关注主题
public List<ThemeEntity> selectInterestThemes(String userId){
List<String> fansRelEntities = fansRelService.queryFansByFollowerId(userId).stream().map(FansRelEntity::getIdolId).collect(Collectors.toList());
return null;
}
//点赞
public void like(String themeId, String userId) {
CollectionEntity collectionEntity = new CollectionEntity();
collectionEntity.setCollectionType(CollectionTypeEnum.LIKE.getCode());
collectionEntity.setAuthorId(userId);
collectionEntity.setTargetId(themeId);
collectionEntity.setCreateBy(userId);
collectionEntity.setCreateTime(LocalDateTime.now());
collectionService.insertCollection(collectionEntity);
}
//评论
public void comment(String themeId, String userId,String comment) {
CommentEntity commentEntity = new CommentEntity();
commentEntity.setTargetId(themeId);
commentEntity.setAuthorId(userId);
commentEntity.setCommentType(CommentTypeEnum.TEXT.getCode());
commentEntity.setContent(comment);
commentService.insertComment(commentEntity);
}
//转发
public void forward(String themeId, String user) {
}
//分享
public void share(String themeId, String user) {
}
//收藏
public void book(String themeId, String userId) {
CollectionEntity collectionEntity = new CollectionEntity();
collectionEntity.setCollectionType(CollectionTypeEnum.BOOK.getCode());
collectionEntity.setAuthorId(userId);
collectionEntity.setTargetId(themeId);
collectionEntity.setCreateBy(userId);
collectionEntity.setCreateTime(LocalDateTime.now());
collectionService.insertCollection(collectionEntity);
}
//投诉(主题)
public void complaint(String themeId, String user) {
}
//屏蔽(用户)
public void blockUser(String themeId, String userId) {
BlackListEntity blackListEntity = new BlackListEntity();
blackListEntity.setBlockedId(themeService.selectTheme(themeId).getAuthorId());
blackListEntity.setBlocker(userId);
blackListEntity.setBlockedType(BlockTypeEnum.USER.getCode());
blackListService.insertBlackList(blackListEntity);
}
//屏蔽(内容)
public void blockContent(String themeId, String userId) {
BlackListEntity blackListEntity = new BlackListEntity();
blackListEntity.setBlockedId(themeId);
blackListEntity.setBlocker(userId);
blackListEntity.setBlockedType(BlockTypeEnum.CONTENT.getCode());
blackListService.insertBlackList(blackListEntity);
}
public void insert(ThemeEntity themeEntity) {
themeService.insertTheme(themeEntity);
}
}