Commit ec929dd6 authored by 刘基明's avatar 刘基明

评论回复评论

parent 3617c248
......@@ -21,15 +21,9 @@ public class TopicFollowQo {
private String topicTitle;
@ApiModelProperty(value = "阅读量")
private Integer viewCount;
@ApiModelProperty(value = "讨论量")
private Integer disscussCount;
@ApiModelProperty(value = "阅读量-格式化")
private String formatViewCount;
@ApiModelProperty(value = "讨论量-格式化")
@ApiModelProperty(value = "讨论量")
private String formatDisscussCount;
@ApiModelProperty(value = "话题介绍")
......@@ -41,6 +35,9 @@ public class TopicFollowQo {
@ApiModelProperty(value = "是否专属 0否,1是")
private Integer specialPermission;
@ApiModelProperty(value = "是否有权限")
private boolean hasPermission;
@ApiModelProperty(value = "更新帖子数量")
private Integer updateCount;
......
package com.tanpu.community.api.beans.qo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("热点话题对象")
public class TopicHotQo {
@ApiModelProperty(value = "话题ID")
private String topicId;
@ApiModelProperty(value = "话题名称")
private String topicTitle;
@ApiModelProperty(value = "类型 1:热 2:新")
private Integer type;
@ApiModelProperty(value = "阅读量")
private String formatViewCount;
@ApiModelProperty(value = "讨论量")
private String formatDisscussCount;
@ApiModelProperty(value = "是否置顶")
private Integer isTop;
@ApiModelProperty(value = "浏览量调整基数")
private Integer viewCntAdjust;
@ApiModelProperty(value = "话题下的帖子权重")
private Double themeWeight;
@ApiModelProperty(value = "话题介绍")
private String topicDesc;
@ApiModelProperty(value = "封面")
private String coverImg;
@ApiModelProperty(value = "是否专属 0否,1是")
private Integer specialPermission;
@ApiModelProperty(value = "是否有权限")
private boolean hasPermission;
}
......@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("热点话题对象")
@ApiModel("话题排序对象")
public class TopicRankQo {
@ApiModelProperty(value = "话题ID")
......
......@@ -79,6 +79,7 @@ public class CommentManager {
.themeId(req.getThemeId())
.parentId(req.getParentId())
.replyId(req.getReplyId())
.replyUserId(req.getReplyUserId())
.authorId(userId)
.content(req.getComment())
.commentType(CommentTypeEnum.THEME.getCode())
......@@ -155,6 +156,13 @@ public class CommentManager {
commentQo.setBelongUserOrgId(userInfo.getBelongUserOrgId());
commentQo.setBelongUserOrgName(userInfo.getBelongUserOrgName());
}
// 回复用户名
String replyUserId = commentQo.getReplyUserId();
UserInfoResp replyUser = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, authorId),
60, () -> this.getUserInfo(replyUserId), UserInfoResp.class);
if (replyUser != null) {
commentQo.setReplyUserName(replyUser.getNickName());
}
commentQo.setHasLiked(false);
commentQo.setLikeCount(0);
}
......@@ -196,7 +204,7 @@ public class CommentManager {
//删除评论
public void delete(String commentId, String userId) {
if (StringUtils.isBlank(commentId)){
if (StringUtils.isBlank(commentId)) {
throw new BizException("commentId不能为空");
}
commentService.delete(commentId, userId);
......
......@@ -97,53 +97,55 @@ public class ThemeManager {
@Resource
private ThemeService themeService;
@Autowired
@Resource
private CollectionService collectionService;
@Autowired
@Resource
private CommentService commentService;
@Autowired
@Resource
private FollowRelService followRelService;
@Autowired
@Resource
private BlackListService blackListService;
@Autowired
@Resource
private ThemeAttachmentService themeAttachmentService;
@Resource
private BatchFeignCallService batchFeignCallService;
@Autowired
@Resource
private VisitLogService visitLogService;
@Autowired
@Resource
private ReportLogService reportLogService;
@Autowired
@Resource
private RankService rankService;
@Autowired
@Resource
private ESService esService;
@Autowired
@Resource
private FeignClientForFatools feignClientForFatools;
@Autowired
@Resource
private RedisCache redisCache;
@Autowired
@Resource
private RecommendService recommendService;
@Resource
private RestTemplate restTemplate;
@Autowired
@Resource
private NotificationService notificationService;
@Autowired
@Resource
private ThemeTextCheckService themeTextCheckService;
@Resource
private TopicService topicService;
@PostConstruct
public void init() throws IOException {
......@@ -697,10 +699,20 @@ public class ThemeManager {
// 查询正文
public CommonResp<ThemeQo> getThemeDetail(String themeId, String userId) {
ThemeEntity themeEntity = themeService.queryByThemeIdIgnoreDelete(themeId);
if (themeEntity == null) {
throw new BizException("找不到帖子id:" + themeId);
}
// 校验主题权限
if (StringUtils.isNotBlank(themeEntity.getTopicId()) &&
!topicService.checkPermission(themeEntity.getTopicId(), userId)) {
return CommonResp.error(ErrorCodeConstant.TOPIC_PERMISSION_ABORT.getCode(), topicService.getPermissionToast(themeEntity.getTopicId()));
}
if (themeEntity.getDeleteTag().equals(DeleteTagEnum.DELETED.getCode())) {
return CommonResp.error(ErrorCodeConstant.UNREACHABLE, null);
}
......
......@@ -11,7 +11,6 @@ import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
import com.tanpu.community.api.enums.OperationTypeEnum;
import com.tanpu.community.api.enums.TopicSpecialPermissionEnum;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.entity.community.TopicFollowRelEntity;
import com.tanpu.community.dao.mapper.community.TopicFollowRelMapper;
import com.tanpu.community.service.RankService;
import com.tanpu.community.service.ThemeService;
......@@ -55,7 +54,7 @@ public class TopicManager {
List<TopicRankQo> topicList = rankService.getRankTopicList(req.getSearchKeyword());
Page<TopicRankQo> result = PageUtils.page(req.getPage(), topicList);
// 添加权限
topicService.batchCheckPermission(result.getContent(),userHolder.getUserId());
topicService.batchCheckPermission(result.getContent(), userHolder.getUserId());
return result;
}
......@@ -103,41 +102,14 @@ public class TopicManager {
}
//
if (TopicSpecialPermissionEnum.TRUE.getCode().equals(topicEntity.getSpecialPermission()) && !checkPermission(topicId, userHolder.getUserId())) {
return CommonResp.error(ErrorCodeConstant.TOPIC_PERMISSION_ABORT.getCode(), getPermissionToast(topicId));
if (TopicSpecialPermissionEnum.TRUE.getCode().equals(topicEntity.getSpecialPermission()) &&
!topicService.checkPermission(topicId, userHolder.getUserId())) {
return CommonResp.error(ErrorCodeConstant.TOPIC_PERMISSION_ABORT.getCode(), topicService.getPermissionToast(topicId));
}
return CommonResp.success(rankService.getTopicDetail(topicId));
}
private String getPermissionToast(String topicId) {
String permission = "专业版会员";
return "暂无权限参与此话题~您可联系官方客服 021- 了解详情";
// return "该话题仅限" + permission + "可参与哦~";
}
/**
* 判断用户是否拥有权限(1对1)
*
* @param topicId
* @param userId
*/
private boolean checkPermission(String topicId, String userId) {
TopicEntity topicEntity = topicService.queryOnlineTopicById(topicId);
if (TopicSpecialPermissionEnum.FALSE.equals(topicEntity.getSpecialPermission())) {
return true;
}
TopicFollowRelEntity topicFollowRelEntity = topicFollowRelMapper.queryOneByTopicIdAndUserId(topicId, userId);
if (topicFollowRelEntity != null) {
return true;
} else {
return false;
}
}
/**
* 关注/取关 话题
......@@ -150,7 +122,7 @@ public class TopicManager {
// 检验话题权限是否专属
TopicEntity topicEntity = topicService.queryOnlineTopicById(req.getTopicId());
if (TopicSpecialPermissionEnum.TRUE.equals(topicEntity.getSpecialPermission())) {
if (TopicSpecialPermissionEnum.TRUE.getCode().equals(topicEntity.getSpecialPermission())) {
return CommonResp.error(ErrorCodeConstant.ILLEGAL_ARGEMENT.getCode(), "专属话题不支持关注");
}
......
......@@ -6,6 +6,7 @@ import com.tanpu.community.api.beans.qo.TopicFollowQo;
import com.tanpu.community.api.beans.qo.TopicRankQo;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.StatusEnum;
import com.tanpu.community.api.enums.TopicSpecialPermissionEnum;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.entity.community.TopicFollowRelEntity;
import com.tanpu.community.dao.mapper.community.TopicFollowRelMapper;
......@@ -91,10 +92,6 @@ public class TopicService {
}
public void followTopic(String topicId, String userId) {
}
public boolean addFollowTopic(String topicId, String userId) {
TopicFollowRelEntity searchResult = topicFollowRelMapper.queryOneByTopicIdAndUserId(topicId, userId);
......@@ -126,7 +123,37 @@ public class TopicService {
public void batchCheckPermission(List<TopicRankQo> content, String userId) {
if (StringUtils.isBlank(userId)){
return;
}
}
/**
* 判断用户是否拥有权限(1对1)
*
* @param topicId
* @param userId
*/
public boolean checkPermission(String topicId, String userId) {
TopicEntity topicEntity = queryOnlineTopicById(topicId);
if (TopicSpecialPermissionEnum.FALSE.getCode().equals(topicEntity.getSpecialPermission())) {
return true;
}
TopicFollowRelEntity topicFollowRelEntity = topicFollowRelMapper.queryOneByTopicIdAndUserId(topicId, userId);
if (topicFollowRelEntity != null) {
return true;
} else {
return false;
}
}
public String getPermissionToast(String topicId) {
String permission = "专业版会员";
return "暂无权限参与此话题~您可联系官方客服 021- 了解详情";
// return "该话题仅限" + permission + "可参与哦~";
}
}
......@@ -150,6 +150,7 @@ public class ConvertUtil {
private static TopicFollowQo topicEntityToFollowQo(TopicEntity topicEntity) {
TopicFollowQo topicFollowQo = new TopicFollowQo();
BeanUtils.copyProperties(topicEntity, topicFollowQo);
topicFollowQo.setHasPermission(true);
return topicFollowQo;
}
......
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