Commit 2de37d0e authored by 刘基明's avatar 刘基明

屏蔽fix

parent fd84c963
...@@ -65,6 +65,8 @@ public class ThemeController { ...@@ -65,6 +65,8 @@ public class ThemeController {
@RequestMapping(value = "/forward") @RequestMapping(value = "/forward")
@ResponseBody @ResponseBody
public String forwardTheme(String themeId){ public String forwardTheme(String themeId){
String userId="liujm";
themeManager.forward(themeId,userId);
return "success"; return "success";
} }
...@@ -98,13 +100,16 @@ public class ThemeController { ...@@ -98,13 +100,16 @@ public class ThemeController {
@RequestMapping(value = "/complaint") @RequestMapping(value = "/complaint")
@ResponseBody @ResponseBody
public String complaintTheme(String themeId){ public String complaintTheme(String themeId){
return "success";
return "功能暂未开放";
} }
@ApiOperation("屏蔽") @ApiOperation("屏蔽")
@RequestMapping(value = "/conceal") @RequestMapping(value = "/conceal")
@ResponseBody @ResponseBody
public String concealTheme(String themeId){ public String concealTheme(String themeId){
String user="liujm";
themeManager.blockContent(themeId,user);
return "success"; return "success";
} }
} }
...@@ -32,13 +32,14 @@ public class ThemeManager { ...@@ -32,13 +32,14 @@ public class ThemeManager {
//返回推荐主题文章 //返回推荐主题文章
public List<ThemeEntity> selectHotThemes(){ public List<ThemeEntity> selectHotThemes(){
//TOTO:根据算法计算推荐主题 //TODO:根据算法计算推荐主题
return null; return null;
} }
//返回关注主题 //返回关注主题
public List<ThemeEntity> selectInterestThemes(String userId){ public List<ThemeEntity> selectInterestThemes(String userId){
List<String> fansRelEntities = fansRelService.queryFansByFollowerId(userId).stream().map(FansRelEntity::getIdolId).collect(Collectors.toList()); List<String> fansList = fansRelService.queryFansByFollowerId(userId).stream().map(FansRelEntity::getIdolId).collect(Collectors.toList());
List<ThemeEntity> result = themeService.selectByFans(fansList);
return null; return null;
} }
...@@ -65,12 +66,12 @@ public class ThemeManager { ...@@ -65,12 +66,12 @@ public class ThemeManager {
//转发 //转发
public void forward(String themeId, String user) { public void forward(String themeId, String user) {
//TODO
} }
//分享 //分享
public void share(String themeId, String user) { public void share(String themeId, String user) {
//TODO
} }
//收藏 //收藏
...@@ -85,24 +86,22 @@ public class ThemeManager { ...@@ -85,24 +86,22 @@ public class ThemeManager {
} }
//投诉(主题) //投诉(主题)
public void complaint(String themeId, String user) { public void complaint(String themeId, String user) {
//TODO
} }
//屏蔽(用户) //屏蔽(用户)
public void blockUser(String themeId, String userId) { public void blockUser(String themeId, String userId) {
BlackListEntity blackListEntity = new BlackListEntity(); BlackListEntity selectOne = blackListService.selectOne(userId, BlockTypeEnum.USER.getCode(), themeService.selectTheme(themeId).getAuthorId());
blackListEntity.setBlockedId(themeService.selectTheme(themeId).getAuthorId()); if (selectOne==null){
blackListEntity.setBlocker(userId); blackListService.insertBlackList(userId, BlockTypeEnum.USER.getCode(), themeService.selectTheme(themeId).getAuthorId());
blackListEntity.setBlockedType(BlockTypeEnum.USER.getCode()); }
blackListService.insertBlackList(blackListEntity);
} }
//屏蔽(内容) //屏蔽(内容)
public void blockContent(String themeId, String userId) { public void blockContent(String themeId, String userId) {
BlackListEntity blackListEntity = new BlackListEntity(); BlackListEntity selectOne = blackListService.selectOne(userId, BlockTypeEnum.USER.getCode(), themeId);
blackListEntity.setBlockedId(themeId); if (selectOne==null){
blackListEntity.setBlocker(userId); blackListService.insertBlackList(userId, BlockTypeEnum.USER.getCode(), themeId);
blackListEntity.setBlockedType(BlockTypeEnum.CONTENT.getCode()); }
blackListService.insertBlackList(blackListEntity);
} }
public void insert(ThemeEntity themeEntity) { public void insert(ThemeEntity themeEntity) {
......
...@@ -16,6 +16,19 @@ public class BlackListService { ...@@ -16,6 +16,19 @@ public class BlackListService {
blackListMapper.insert(blackListEntity); blackListMapper.insert(blackListEntity);
} }
public BlackListEntity selectOne(String blocker,Integer blockType,String blockId) {
return blackListMapper.selectOne(new LambdaQueryWrapper<BlackListEntity>().eq(BlackListEntity::getBlocker, blocker).
eq(BlackListEntity::getBlockedId, blockId).eq(BlackListEntity::getBlockedType, blockType));
}
public void insertBlackList(String blocker,Integer blockType,String blockId){
BlackListEntity blackListEntity = new BlackListEntity();
blackListEntity.setBlockedType(blockType);
blackListEntity.setBlocker(blocker);
blackListEntity.setBlockedId(blockId);
blackListMapper.insert(blackListEntity);
}
public void deleteBlackList(String blocker,String blockId,String blockType){ public void deleteBlackList(String blocker,String blockId,String blockType){
blackListMapper.delete(new LambdaQueryWrapper<BlackListEntity>().eq(BlackListEntity::getBlocker,blocker). blackListMapper.delete(new LambdaQueryWrapper<BlackListEntity>().eq(BlackListEntity::getBlocker,blocker).
eq(BlackListEntity::getBlockedId,blockId).eq(BlackListEntity::getBlockedType,blockType)); eq(BlackListEntity::getBlockedId,blockId).eq(BlackListEntity::getBlockedType,blockType));
......
package com.tanpu.community.service; package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.dao.entity.community.ThemeEntity; import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.mapper.community.ThemeMapper; import com.tanpu.community.dao.mapper.community.ThemeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -26,11 +25,10 @@ public class ThemeService { ...@@ -26,11 +25,10 @@ public class ThemeService {
//根据话题查询主题 //根据话题查询主题
public List<ThemeEntity> selectByTopic(String topidId){ public List<ThemeEntity> selectByTopic(String topidId){
QueryWrapper<ThemeEntity> themeEntityQueryWrapper = new QueryWrapper<>(); return themeMapper.selectList(new LambdaQueryWrapper<ThemeEntity>().eq(ThemeEntity::getTopicId,topidId));
themeEntityQueryWrapper.eq("topic_id",topidId); }
return themeMapper.selectList(themeEntityQueryWrapper); //查询列表中用户的主题
public List<ThemeEntity> selectByFans(List<String> fansList) {
return themeMapper.selectList(new LambdaQueryWrapper<ThemeEntity>().in(ThemeEntity::getAuthorId,fansList));
} }
} }
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