Browse Source

话题的评论回复、评论的支持反对发送消息

dev
liuchuang 6 years ago
parent
commit
ac688b17e0
  1. 18
      esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/constant/TopicNoticeConstant.java
  2. 11
      esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/service/impl/TopicCommentServiceImpl.java
  3. 45
      esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/service/impl/TopicCommentUserAttitudeServiceImpl.java

18
esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/constant/TopicNoticeConstant.java

@ -14,15 +14,6 @@ public interface TopicNoticeConstant {
* 评论被回复 * 评论被回复
*/ */
String NOTICE_TOPIC_COMMENT_REPLY = "你的评论【有新回复】"; String NOTICE_TOPIC_COMMENT_REPLY = "你的评论【有新回复】";
/**
* 话题支持
*/
String NOTICE_TOPIC_APPROVE = "你的话题【有新的支持】";
/**
* 话题反对
*/
String NOTICE_TOPIC_OPPOSE = "你的话题【有新的反对】";
/** /**
* 评论支持 * 评论支持
*/ */
@ -49,6 +40,13 @@ public interface TopicNoticeConstant {
*/ */
String NOTICE_BUSINESS_TYPE_TOPIC_COMMENT_REPLY = "topicCommentReply"; String NOTICE_BUSINESS_TYPE_TOPIC_COMMENT_REPLY = "topicCommentReply";
/**
* 消息所属业务类型话题评论支持
*/
String NOTICE_BUSINESS_TYPE_TOPIC_COMMENT_APPROVE = "topicCommentApprove";
/**
* 消息所属业务类型话题评论反对
*/
String NOTICE_BUSINESS_TYPE_TOPIC_COMMENT_OPPOSE = "topicCommentOppose";
} }

11
esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/service/impl/TopicCommentServiceImpl.java

@ -32,6 +32,7 @@ import com.elink.esua.epdc.dto.comment.TopicCommentsResultDTO;
import com.elink.esua.epdc.dto.constant.TopicNoticeConstant; import com.elink.esua.epdc.dto.constant.TopicNoticeConstant;
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO;
import com.elink.esua.epdc.dto.topic.TopicCommentsDTO; import com.elink.esua.epdc.dto.topic.TopicCommentsDTO;
import com.elink.esua.epdc.dto.topic.TopicDTO;
import com.elink.esua.epdc.modules.async.NewsTask; import com.elink.esua.epdc.modules.async.NewsTask;
import com.elink.esua.epdc.modules.comment.dao.TopicCommentDao; import com.elink.esua.epdc.modules.comment.dao.TopicCommentDao;
import com.elink.esua.epdc.modules.comment.entity.TopicCommentEntity; import com.elink.esua.epdc.modules.comment.entity.TopicCommentEntity;
@ -155,16 +156,19 @@ public class TopicCommentServiceImpl extends BaseServiceImpl<TopicCommentDao, To
// 评论数加1 // 评论数加1
topicService.updateCommentNum(commentEntity.getTopicId()); topicService.updateCommentNum(commentEntity.getTopicId());
// 话题信息
TopicDTO topicDto = topicService.get(commentFormDTO.getTopicId());
// 组装发送消息内容 // 组装发送消息内容
EpdcInformationFormDTO informationFormDTO = new EpdcInformationFormDTO(); EpdcInformationFormDTO informationFormDTO = new EpdcInformationFormDTO();
informationFormDTO.setType(TopicNoticeConstant.NOTICE_TYPE_INTERACTIVE_NOTICE); informationFormDTO.setType(TopicNoticeConstant.NOTICE_TYPE_INTERACTIVE_NOTICE);
informationFormDTO.setBusinessId(topicDto.getId());
if (isComment) { if (isComment) {
// 评论 // 评论
informationFormDTO.setUserId(commentEntity.getUserId()); informationFormDTO.setUserId(topicDto.getUserId());
informationFormDTO.setContent(commentEntity.getContent()); informationFormDTO.setContent(topicDto.getTopicContent());
informationFormDTO.setTitle(TopicNoticeConstant.NOTICE_TOPIC_COMMENT); informationFormDTO.setTitle(TopicNoticeConstant.NOTICE_TOPIC_COMMENT);
informationFormDTO.setBusinessType(TopicNoticeConstant.NOTICE_BUSINESS_TYPE_TOPIC_COMMENT); informationFormDTO.setBusinessType(TopicNoticeConstant.NOTICE_BUSINESS_TYPE_TOPIC_COMMENT);
informationFormDTO.setBusinessId(commentEntity.getId());
informationFormDTO.setRelBusinessContent(commentFormDTO.getUserName()+":"+commentFormDTO.getContent()); informationFormDTO.setRelBusinessContent(commentFormDTO.getUserName()+":"+commentFormDTO.getContent());
} else { } else {
// 回复 // 回复
@ -172,7 +176,6 @@ public class TopicCommentServiceImpl extends BaseServiceImpl<TopicCommentDao, To
informationFormDTO.setContent(commentFormDTO.getUserName()+":"+commentFormDTO.getContent()); informationFormDTO.setContent(commentFormDTO.getUserName()+":"+commentFormDTO.getContent());
informationFormDTO.setTitle(TopicNoticeConstant.NOTICE_TOPIC_COMMENT_REPLY); informationFormDTO.setTitle(TopicNoticeConstant.NOTICE_TOPIC_COMMENT_REPLY);
informationFormDTO.setBusinessType(TopicNoticeConstant.NOTICE_BUSINESS_TYPE_TOPIC_COMMENT_REPLY); informationFormDTO.setBusinessType(TopicNoticeConstant.NOTICE_BUSINESS_TYPE_TOPIC_COMMENT_REPLY);
informationFormDTO.setBusinessId(commentEntity.getId());
informationFormDTO.setRelBusinessContent(parentComment.getContent()); informationFormDTO.setRelBusinessContent(parentComment.getContent());
} }
// 发送消息 // 发送消息

45
esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/service/impl/TopicCommentUserAttitudeServiceImpl.java

@ -20,14 +20,18 @@ package com.elink.esua.epdc.modules.comment.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.dto.TopicCommentUserAttitudeDTO; import com.elink.esua.epdc.dto.TopicCommentUserAttitudeDTO;
import com.elink.esua.epdc.dto.comment.TopicCommentDTO;
import com.elink.esua.epdc.dto.comment.TopicCommentStatementFormDTO; import com.elink.esua.epdc.dto.comment.TopicCommentStatementFormDTO;
import com.elink.esua.epdc.dto.constant.TopicNoticeConstant;
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO;
import com.elink.esua.epdc.modules.async.NewsTask;
import com.elink.esua.epdc.modules.comment.dao.TopicCommentUserAttitudeDao; import com.elink.esua.epdc.modules.comment.dao.TopicCommentUserAttitudeDao;
import com.elink.esua.epdc.modules.comment.entity.TopicCommentUserAttitudeEntity; import com.elink.esua.epdc.modules.comment.entity.TopicCommentUserAttitudeEntity;
import com.elink.esua.epdc.modules.comment.redis.TopicCommentUserAttitudeRedis;
import com.elink.esua.epdc.modules.comment.service.TopicCommentService; import com.elink.esua.epdc.modules.comment.service.TopicCommentService;
import com.elink.esua.epdc.modules.comment.service.TopicCommentUserAttitudeService; import com.elink.esua.epdc.modules.comment.service.TopicCommentUserAttitudeService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -48,11 +52,12 @@ import java.util.Map;
@Service @Service
public class TopicCommentUserAttitudeServiceImpl extends BaseServiceImpl<TopicCommentUserAttitudeDao, TopicCommentUserAttitudeEntity> implements TopicCommentUserAttitudeService { public class TopicCommentUserAttitudeServiceImpl extends BaseServiceImpl<TopicCommentUserAttitudeDao, TopicCommentUserAttitudeEntity> implements TopicCommentUserAttitudeService {
@Autowired
private TopicCommentUserAttitudeRedis topicCommentUserAttitudeRedis;
@Autowired @Autowired
private TopicCommentService topicCommentService; private TopicCommentService topicCommentService;
@Autowired
private NewsTask newsTask;
@Override @Override
public PageData<TopicCommentUserAttitudeDTO> page(Map<String, Object> params) { public PageData<TopicCommentUserAttitudeDTO> page(Map<String, Object> params) {
IPage<TopicCommentUserAttitudeEntity> page = baseDao.selectPage( IPage<TopicCommentUserAttitudeEntity> page = baseDao.selectPage(
@ -114,8 +119,14 @@ public class TopicCommentUserAttitudeServiceImpl extends BaseServiceImpl<TopicCo
wrapper.eq(StringUtils.isNotBlank(formDto.getCommentId()), "COMMENT_ID", formDto.getCommentId()); wrapper.eq(StringUtils.isNotBlank(formDto.getCommentId()), "COMMENT_ID", formDto.getCommentId());
TopicCommentUserAttitudeEntity topicCommentUserAttitudeEntity = baseDao.selectOne(wrapper); TopicCommentUserAttitudeEntity topicCommentUserAttitudeEntity = baseDao.selectOne(wrapper);
// 组装发送消息内容
TopicCommentDTO commentDto = topicCommentService.get(formDto.getCommentId());
EpdcInformationFormDTO informationFormDTO = new EpdcInformationFormDTO();
informationFormDTO.setType(TopicNoticeConstant.NOTICE_TYPE_INTERACTIVE_NOTICE);
informationFormDTO.setUserId(commentDto.getUserId());
informationFormDTO.setContent(commentDto.getContent());
if ("0".equals(formDto.getAttitude()) || "1".equals(formDto.getAttitude())){ if (NumConstant.ZERO_STR.equals(formDto.getAttitude()) || NumConstant.ONE_STR.equals(formDto.getAttitude())){
if (topicCommentUserAttitudeEntity == null){ if (topicCommentUserAttitudeEntity == null){
//没有点赞或者点踩,直接插入数据 //没有点赞或者点踩,直接插入数据
TopicCommentUserAttitudeDTO topicCommentUserAttitudeDTO = new TopicCommentUserAttitudeDTO(); TopicCommentUserAttitudeDTO topicCommentUserAttitudeDTO = new TopicCommentUserAttitudeDTO();
@ -124,11 +135,21 @@ public class TopicCommentUserAttitudeServiceImpl extends BaseServiceImpl<TopicCo
topicCommentUserAttitudeDTO.setAttitudeFlag(formDto.getAttitude()); topicCommentUserAttitudeDTO.setAttitudeFlag(formDto.getAttitude());
this.save(topicCommentUserAttitudeDTO); this.save(topicCommentUserAttitudeDTO);
if ("0".equals(formDto.getAttitude())){ if (NumConstant.ZERO_STR.equals(formDto.getAttitude())){
topicCommentService.updateApproveNumAdd(formDto.getCommentId()); topicCommentService.updateApproveNumAdd(formDto.getCommentId());
// 支持
informationFormDTO.setTitle(TopicNoticeConstant.NOTICE_COMMENT_APPROVE);
informationFormDTO.setBusinessType(TopicNoticeConstant.NOTICE_BUSINESS_TYPE_TOPIC_COMMENT_APPROVE);
informationFormDTO.setRelBusinessContent(formDto.getUserName()+"支持了你的评论");
} }
if ("1".equals(formDto.getAttitude())){ if (NumConstant.ONE_STR.equals(formDto.getAttitude())){
topicCommentService.updateOpposeNumAdd(formDto.getCommentId()); topicCommentService.updateOpposeNumAdd(formDto.getCommentId());
// 反对
informationFormDTO.setTitle(TopicNoticeConstant.NOTICE_COMMENT_OPPOSE);
informationFormDTO.setBusinessType(TopicNoticeConstant.NOTICE_BUSINESS_TYPE_TOPIC_COMMENT_OPPOSE);
informationFormDTO.setRelBusinessContent(formDto.getUserName()+"反对了你的评论");
} }
}else { }else {
@ -136,7 +157,7 @@ public class TopicCommentUserAttitudeServiceImpl extends BaseServiceImpl<TopicCo
topicCommentUserAttitudeEntity.setAttitudeFlag(formDto.getAttitude()); topicCommentUserAttitudeEntity.setAttitudeFlag(formDto.getAttitude());
this.updateById(topicCommentUserAttitudeEntity); this.updateById(topicCommentUserAttitudeEntity);
if ("0".equals(formDto.getAttitude())){ if (NumConstant.ZERO_STR.equals(formDto.getAttitude())){
//赞数加1 踩数减一 //赞数加1 踩数减一
topicCommentService.updateApproveNumAdd(formDto.getCommentId()); topicCommentService.updateApproveNumAdd(formDto.getCommentId());
topicCommentService.updateOpposeNumSubtract(formDto.getCommentId()); topicCommentService.updateOpposeNumSubtract(formDto.getCommentId());
@ -150,18 +171,16 @@ public class TopicCommentUserAttitudeServiceImpl extends BaseServiceImpl<TopicCo
}else { }else {
//删除点赞或踩的记录,如果重新点赞或踩则重新插入 //删除点赞或踩的记录,如果重新点赞或踩则重新插入
this.deleteById(topicCommentUserAttitudeEntity.getId()); this.deleteById(topicCommentUserAttitudeEntity.getId());
if ("2".equals(formDto.getAttitude())){ if (NumConstant.TWO_STR.equals(formDto.getAttitude())){
//取消赞 //取消赞
topicCommentService.updateApproveNumSubtract(formDto.getCommentId()); topicCommentService.updateApproveNumSubtract(formDto.getCommentId());
} }
if ("3".equals(formDto.getAttitude())){ if (NumConstant.THREE_STR.equals(formDto.getAttitude())){
//取消踩 //取消踩
topicCommentService.updateOpposeNumSubtract(formDto.getCommentId()); topicCommentService.updateOpposeNumSubtract(formDto.getCommentId());
} }
} }
// 发送消息
newsTask.insertUserInformation(informationFormDTO);
} }
} }

Loading…
Cancel
Save