Commit 0c9f7e93 authored by 刘基明's avatar 刘基明

svc

parent 214a68a1
......@@ -232,7 +232,7 @@ public class ThemeManager {
Set<String> fansSet = new HashSet<>(followRelService.queryFansByFollowerId(userId));
themeQo.setFollow(fansSet.contains(authorId));
//是否点赞
CollectionEntity likeEntity = collectionService.getTargetCollection(themeId, userId, CollectionTypeEnum.LIKE_THEME);
CollectionEntity likeEntity = collectionService.getNotDeleteTargetCollection(themeId, userId, CollectionTypeEnum.LIKE_THEME);
themeQo.setHasLiked(likeEntity!=null);
//是否转发
Integer forwardCountByUser = themeService.getForwardCountByUser(themeId, userId);
......
......@@ -22,8 +22,8 @@ public class CollectionService {
// 若不存在则新增,若存在则修改deleteTag
public void addIfNotExist(String themeId, String userId, CollectionTypeEnum type) {
// 判断是否删除
CollectionEntity queryCollection = getDeletedTargetCollection(themeId, userId, type);
// 判断记录是否存在,无论是否删除
CollectionEntity queryCollection = getTargetCollection(themeId, userId, type);
if (queryCollection != null) {
queryCollection.setDeleteTag(DeleteTagEnum.NOT_DELETED.getCode());
queryCollection.setCollectionTime(LocalDateTime.now());
......@@ -42,7 +42,7 @@ public class CollectionService {
//根据用户、主题、类型查询未删除对象
public CollectionEntity getTargetCollection(String targetId, String userId, CollectionTypeEnum type) {
public CollectionEntity getNotDeleteTargetCollection(String targetId, String userId, CollectionTypeEnum type) {
return collectionMapper.selectOne(new LambdaQueryWrapper<CollectionEntity>()
.eq(CollectionEntity::getCollectionType, type.getCode())
.eq(CollectionEntity::getUserId, userId)
......@@ -50,18 +50,18 @@ public class CollectionService {
.eq(CollectionEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()));
}
//根据用户、主题、类型查询已删除对象
public CollectionEntity getDeletedTargetCollection(String themeId, String userId, CollectionTypeEnum type) {
//根据用户、主题、类型查询记录,包括已删除对象
public CollectionEntity getTargetCollection(String themeId, String userId, CollectionTypeEnum type) {
return collectionMapper.selectOne(new LambdaQueryWrapper<CollectionEntity>()
.eq(CollectionEntity::getCollectionType, type.getCode())
.eq(CollectionEntity::getUserId, userId)
.eq(CollectionEntity::getTargetId, themeId)
.eq(CollectionEntity::getDeleteTag, DeleteTagEnum.DELETED.getCode()));
.eq(CollectionEntity::getTargetId, themeId));
}
// 根据用户id和行为type获取target_id列表
public Set<String> getListByUser(String userId, CollectionTypeEnum type) {
return collectionMapper.selectList(new LambdaQueryWrapper<CollectionEntity>()
.eq(CollectionEntity::getUserId,userId)
.eq(CollectionEntity::getCollectionType, type.getCode())
.eq(CollectionEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()))
.stream().map(CollectionEntity::getTargetId).collect(Collectors.toSet());
......@@ -85,7 +85,7 @@ public class CollectionService {
}
//逻辑删除,修改delete_tag
public void delete(String themeId, String userId, CollectionTypeEnum type) {
CollectionEntity queryCollection = getTargetCollection(themeId, userId, type);
CollectionEntity queryCollection = getNotDeleteTargetCollection(themeId, userId, type);
if (queryCollection != null) {
queryCollection.setDeleteTag(DeleteTagEnum.DELETED.getCode());
queryCollection.setUncollectionTime(LocalDateTime.now());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment