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

屏蔽fix

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