Commit 3fdd9bb1 authored by 刘基明's avatar 刘基明

删除无用方法

parent 620dec6b
package com.tanpu.community.controller;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.community.api.beans.req.topic.TopicConcealReq;
import com.tanpu.community.api.beans.req.topic.TopicTopReq;
import com.tanpu.community.manager.TopicManager;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.*;
@RestController
@Slf4j
@RequestMapping(value = "/api/admin/topic")
public class AdminController {
@Autowired
private TopicManager topicManager;
@Autowired
private UserHolder userHolder;
@GetMapping(value="/add")
@ApiOperation("新增话题")
@ResponseBody
public CommonResp<Void> addTopic(@RequestParam String topicTitle){
String userId = userHolder.getUserId();
topicManager.insertTopic(topicTitle,userId);
return CommonResp.success();
}
//
// @ApiOperation("单个话题详细数据")
// @GetMapping("/detailData")
// @ResponseBody
// public CommonResp<TopicDO> selectOne(@RequestParam String topicId) throws MissingServletRequestParameterException {
// if (StringUtils.isEmpty(topicId)){
// throw new MissingServletRequestParameterException("topicId","String");
// }
// TopicDO topicDO =topicManager.getDetail(topicId);
// return CommonResp.success(topicDO);
// }
@PostMapping(value = "/setTop")
@ApiOperation("顶置/取消顶置话题")
@ResponseBody
public CommonResp<Void> setTopTopic(@RequestBody TopicTopReq req) throws MissingServletRequestParameterException {
topicManager.setTopTopic(req.getTopicId(),req.isTop());
return CommonResp.success();
}
@PostMapping(value = "/setConceal")
@ApiOperation("隐藏/显示话题")
@ResponseBody
public CommonResp<Void> setConceal(@RequestBody TopicConcealReq req) throws MissingServletRequestParameterException {
topicManager.setTopicConceal(req.getTopicId(),req.isConceal());
return CommonResp.success();
}
//
// @PostMapping(value = "/modifyViewNum")
// @ApiOperation("话题浏览数调整(后台管理)")
// @ResponseBody
// public CommonResp<Void> modifyViewNum(@RequestBody TopicModifyMountReq req) throws MissingServletRequestParameterException {
// topicManager.modifyViewCount(req.getTopicId(),req.getModifyMount());
// return CommonResp.success();
// }
//
// @GetMapping(value = "/dataAnalyse")
// @ApiOperation("话题数据分析")
// @ResponseBody
// public CommonResp<TopicDataAnalysDTO> dataAnalyse(@RequestParam String topicId) throws MissingServletRequestParameterException {
// TopicDataAnalysDTO result =topicManager.queryDataAnalysis(topicId);
// return CommonResp.success(result);
// }
}
...@@ -181,6 +181,19 @@ public class ThemeManager { ...@@ -181,6 +181,19 @@ public class ThemeManager {
} }
/**
* 举报主题
* @param req
* @param userId
*/
public void report(ReportThemeReq req, String userId) {
//更改举报状态
themeService.updateReportStatus(req.getThemeId());
//写入举报日志
ThemeEntity themeEntity = themeService.queryByThemeId(req.getThemeId());
reportLogService.insert(ReportTypeEnum.THEME, userId,req.getThemeId(),themeEntity.getAuthorId(),req.getReason());
}
// 返回用户发布、回复、收藏的主题列表 // 返回用户发布、回复、收藏的主题列表
public List<ThemeQo> queryThemesByUser(QueryRecordThemeReq req, String userId) { public List<ThemeQo> queryThemesByUser(QueryRecordThemeReq req, String userId) {
...@@ -190,46 +203,8 @@ public class ThemeManager { ...@@ -190,46 +203,8 @@ public class ThemeManager {
themeEntities = themeService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize()); themeEntities = themeService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
break; break;
case 2://回复 case 2://回复
List<ThemeQo> commentThemeList = new ArrayList<>();
//评论列表 List<ThemeQo> commentThemeList = getCommentThemeQos(req, userId);
List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息
UserInfoEntity userInfoEntity = userInfoService.queryUserById(req.getUserId());
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) {
return commentThemeList;
}
themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds));
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
//组装附件
batchFeignCallService.getAttachDetailByBatch(themeQos);
//主题列表
Map<String, ThemeQo> themeMap = themeQos.stream()
.collect(Collectors.toMap(ThemeQo::getThemeId, o -> o));
//主题+评论封装转发对象
for (CommentEntity commentEntity : commentEntities) {
String themeId = commentEntity.getThemeId();
//评论内容包装到ThemeContentQo里
ThemeContentQo commentContent = ThemeContentQo.builder()
.type(RelTypeEnum.TEXT.type)
.value(commentEntity.getContent())
.build();
//原主题包装到FormerThemeQo中
ThemeQo themeQo = themeMap.get(themeId);
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder()
.authorId(userInfoEntity.getId())
.nickName(userInfoEntity.getUiUsernameMp())
.userImg(userInfoEntity.getUiHeadimgMp())
.content(Arrays.asList(commentContent))
.formerTheme(f)
.commentId(commentEntity.getCommentId())
.themeType(ThemeTypeEnum.RES_COMMENT.getCode())
.build();
commentThemeList.add(commentThemeQo);
}
return commentThemeList; return commentThemeList;
case 3://点赞 case 3://点赞
Set<String> likeThemeIds = collectionService.getListByUser(req.getUserId(), CollectionTypeEnum.LIKE_THEME); Set<String> likeThemeIds = collectionService.getListByUser(req.getUserId(), CollectionTypeEnum.LIKE_THEME);
...@@ -244,6 +219,51 @@ public class ThemeManager { ...@@ -244,6 +219,51 @@ public class ThemeManager {
return themeQos; return themeQos;
} }
private List<ThemeQo> getCommentThemeQos(QueryRecordThemeReq req, String userId) {
List<ThemeQo> commentThemeList = new ArrayList<>();
List<ThemeEntity> themeEntities;
//评论列表
List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息
UserInfoEntity userInfoEntity = userInfoService.queryUserById(req.getUserId());
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) {
return commentThemeList;
}
themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds));
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
//组装附件
batchFeignCallService.getAttachDetailByBatch(themeQos);
//主题列表
Map<String, ThemeQo> themeMap = themeQos.stream()
.collect(Collectors.toMap(ThemeQo::getThemeId, o -> o));
//主题+评论封装转发对象
for (CommentEntity commentEntity : commentEntities) {
String themeId = commentEntity.getThemeId();
//评论内容包装到ThemeContentQo里
ThemeContentQo commentContent = ThemeContentQo.builder()
.type(RelTypeEnum.TEXT.type)
.value(commentEntity.getContent())
.build();
//原主题包装到FormerThemeQo中
ThemeQo themeQo = themeMap.get(themeId);
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder()
.authorId(userInfoEntity.getId())
.nickName(userInfoEntity.getUiUsernameMp())
.userImg(userInfoEntity.getUiHeadimgMp())
.content(Arrays.asList(commentContent))
.formerTheme(f)
.commentId(commentEntity.getCommentId())
.themeType(ThemeTypeEnum.RES_COMMENT.getCode())
.build();
commentThemeList.add(commentThemeQo);
}
return null;
}
//查询正文 //查询正文
public ThemeQo getDetail(String themeId, String userId) { public ThemeQo getDetail(String themeId, String userId) {
...@@ -437,11 +457,5 @@ public class ThemeManager { ...@@ -437,11 +457,5 @@ public class ThemeManager {
} }
} }
public void report(ReportThemeReq req, String userId) {
//更改举报状态
themeService.updateReportStatus(req.getThemeId());
//写入举报日志
ThemeEntity themeEntity = themeService.queryByThemeId(req.getThemeId());
reportLogService.insert(ReportTypeEnum.THEME, userId,req.getThemeId(),themeEntity.getAuthorId(),req.getReason());
}
} }
...@@ -66,31 +66,6 @@ public class TopicManager { ...@@ -66,31 +66,6 @@ public class TopicManager {
} }
public void setTopTopic(String topicId, boolean setTop) {
TopicEntity topicEntity = topicService.queryById(topicId);
if (topicEntity == null) {
throw new BizException("找不到话题,id:" + topicId);
}
if (setTop) {
topicService.updateTopicToTop(topicId);
} else {
topicService.updateTopicNotTop(topicId);
}
}
public void setTopicConceal(String topicId, boolean setConceal) {
TopicEntity topicEntity = topicService.queryById(topicId);
if (topicEntity == null) {
throw new BizException("找不到话题,id:" + topicId);
}
if (setConceal) {
topicService.updateTopicToConceal(topicId);
} else {
topicService.updateTopicNotConceal(topicId);
}
}
public void refreshRedisCache() { public void refreshRedisCache() {
List<TopicEntity> topicEntities = topicService.queryAll(); List<TopicEntity> topicEntities = topicService.queryAll();
...@@ -122,7 +97,7 @@ public class TopicManager { ...@@ -122,7 +97,7 @@ public class TopicManager {
} }
//后台管理:返回数据分析 //返回数据分析
public TopicDataAnalysDTO queryDataAnalysis(String topicId) { public TopicDataAnalysDTO queryDataAnalysis(String topicId) {
TopicDataAnalysDTO topicDataAnalysDTO = new TopicDataAnalysDTO(); TopicDataAnalysDTO topicDataAnalysDTO = new TopicDataAnalysDTO();
TopicEntity topicEntity = topicService.queryById(topicId); TopicEntity topicEntity = topicService.queryById(topicId);
......
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