王金鹏 6 years ago
parent
commit
056594d68d
  1. 3
      esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/comment/TopicCommentStatementFormDTO.java
  2. 11
      esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/controller/AppTopicCommentController.java
  3. 24
      esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/dao/TopicCommentDao.java
  4. 25
      esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/service/TopicCommentService.java
  5. 8
      esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/service/TopicCommentUserAttitudeService.java
  6. 20
      esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/service/impl/TopicCommentServiceImpl.java
  7. 63
      esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/service/impl/TopicCommentUserAttitudeServiceImpl.java
  8. 26
      esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/resources/mapper/comment/TopicCommentDao.xml

3
esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/comment/TopicCommentStatementFormDTO.java

@ -37,11 +37,12 @@ public class TopicCommentStatementFormDTO implements Serializable {
*/
private String commentId;
private String topicId;
private String useId;
private String userName;
private String topicId;
}

11
esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/controller/AppTopicCommentController.java

@ -57,5 +57,14 @@ public class AppTopicCommentController {
return topicCommentService.listOfComments(formDto);
}
/**
* 评论/接口
* @param formDto
* @return
*/
@PostMapping("statement")
public Result statement(@RequestBody TopicCommentStatementFormDTO formDto) {
topicCommentUserAttitudeService.statement(formDto);
return new Result();
}
}

24
esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/dao/TopicCommentDao.java

@ -36,6 +36,30 @@ public interface TopicCommentDao extends BaseDao<TopicCommentEntity> {
void updateReplyCount(String commentId);
/**
* 赞数+1
* @param commentId
*/
void updateApproveNumAdd(String commentId);
/**
* 踩数+1
* @param commentId
*/
void updateOpposeNumAdd(String commentId);
/**
* 赞数-1
* @param commentId
*/
void updateApproveNumSubtract(String commentId);
/**
* 踩数-1
* @param commentId
*/
void updateOpposeNumSubtract(String commentId);
long selectCountOfStatementNum(String topicId);

25
esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/service/TopicCommentService.java

@ -107,4 +107,29 @@ public interface TopicCommentService extends BaseService<TopicCommentEntity> {
* 移动端评论列表
*/
Result<TopicCommentsResultDTO> listOfComments(TopicCommentsFormDTO formDto);
/**
* 赞数+1
* @param commentId
*/
void updateApproveNumAdd(String commentId);
/**
* 踩数+1
* @param commentId
*/
void updateOpposeNumAdd(String commentId);
/**
* 赞数-1
* @param commentId
*/
void updateApproveNumSubtract(String commentId);
/**
* 踩数-1
* @param commentId
*/
void updateOpposeNumSubtract(String commentId);
}

8
esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/comment/service/TopicCommentUserAttitudeService.java

@ -20,6 +20,7 @@ package com.elink.esua.epdc.modules.comment.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.dto.TopicCommentUserAttitudeDTO;
import com.elink.esua.epdc.dto.comment.TopicCommentStatementFormDTO;
import com.elink.esua.epdc.modules.comment.entity.TopicCommentUserAttitudeEntity;
import java.util.List;
@ -92,4 +93,11 @@ public interface TopicCommentUserAttitudeService extends BaseService<TopicCommen
* @date 2019-10-23
*/
void delete(String[] ids);
/**
* 评论/接口
* @param formDto
* @return
*/
void statement(TopicCommentStatementFormDTO formDto);
}

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

@ -196,4 +196,24 @@ public class TopicCommentServiceImpl extends BaseServiceImpl<TopicCommentDao, To
return new Result<TopicCommentsResultDTO>().ok(data);
}
@Override
public void updateApproveNumAdd(String commentId) {
baseDao.updateApproveNumAdd(commentId);
}
@Override
public void updateOpposeNumAdd(String commentId) {
baseDao.updateOpposeNumAdd(commentId);
}
@Override
public void updateApproveNumSubtract(String commentId) {
baseDao.updateApproveNumSubtract(commentId);
}
@Override
public void updateOpposeNumSubtract(String commentId) {
baseDao.updateOpposeNumSubtract(commentId);
}
}

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

@ -24,9 +24,11 @@ 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.constant.FieldConstant;
import com.elink.esua.epdc.dto.TopicCommentUserAttitudeDTO;
import com.elink.esua.epdc.dto.comment.TopicCommentStatementFormDTO;
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.redis.TopicCommentUserAttitudeRedis;
import com.elink.esua.epdc.modules.comment.service.TopicCommentService;
import com.elink.esua.epdc.modules.comment.service.TopicCommentUserAttitudeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -48,6 +50,8 @@ public class TopicCommentUserAttitudeServiceImpl extends BaseServiceImpl<TopicCo
@Autowired
private TopicCommentUserAttitudeRedis topicCommentUserAttitudeRedis;
@Autowired
private TopicCommentService topicCommentService;
@Override
public PageData<TopicCommentUserAttitudeDTO> page(Map<String, Object> params) {
@ -101,4 +105,63 @@ public class TopicCommentUserAttitudeServiceImpl extends BaseServiceImpl<TopicCo
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void statement(TopicCommentStatementFormDTO formDto) {
//根据用户id和事件id查询记录
QueryWrapper<TopicCommentUserAttitudeEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(formDto.getUseId()), "USER_ID", formDto.getUseId());
wrapper.eq(StringUtils.isNotBlank(formDto.getCommentId()), "COMMENT_ID", formDto.getCommentId());
TopicCommentUserAttitudeEntity topicCommentUserAttitudeEntity = baseDao.selectOne(wrapper);
if ("0".equals(formDto.getAttitude()) || "1".equals(formDto.getAttitude())){
if (topicCommentUserAttitudeEntity == null){
//没有点赞或者点踩,直接插入数据
TopicCommentUserAttitudeDTO topicCommentUserAttitudeDTO = new TopicCommentUserAttitudeDTO();
topicCommentUserAttitudeDTO.setCommentId(formDto.getCommentId());
topicCommentUserAttitudeDTO.setUserId(formDto.getUseId());
topicCommentUserAttitudeDTO.setAttitudeFlag(formDto.getAttitude());
this.save(topicCommentUserAttitudeDTO);
if ("0".equals(formDto.getAttitude())){
topicCommentService.updateApproveNumAdd(formDto.getCommentId());
}
if ("1".equals(formDto.getAttitude())){
topicCommentService.updateOpposeNumAdd(formDto.getCommentId());
}
}else {
if (!formDto.getAttitude().equals(topicCommentUserAttitudeEntity.getAttitudeFlag())){
topicCommentUserAttitudeEntity.setAttitudeFlag(formDto.getAttitude());
this.updateById(topicCommentUserAttitudeEntity);
if ("0".equals(formDto.getAttitude())){
//赞数加1 踩数减一
topicCommentService.updateApproveNumAdd(formDto.getCommentId());
topicCommentService.updateOpposeNumSubtract(formDto.getCommentId());
}else {
//踩数加一 赞数减一
topicCommentService.updateOpposeNumAdd(formDto.getCommentId());
topicCommentService.updateApproveNumSubtract(formDto.getCommentId());
}
}
}
}else {
//删除点赞或踩的记录,如果重新点赞或踩则重新插入
this.deleteById(topicCommentUserAttitudeEntity.getId());
if ("2".equals(formDto.getAttitude())){
//取消赞
topicCommentService.updateApproveNumSubtract(formDto.getCommentId());
}
if ("3".equals(formDto.getAttitude())){
//取消踩
topicCommentService.updateOpposeNumSubtract(formDto.getCommentId());
}
}
}
}

26
esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/resources/mapper/comment/TopicCommentDao.xml

@ -34,6 +34,32 @@
WHERE ID = #{commentId}
</update>
<update id="updateApproveNumAdd" parameterType="java.lang.String">
UPDATE epdc_topic_comment
SET LIKE_COUNT = LIKE_COUNT + 1
WHERE ID = #{commentId}
</update>
<update id="updateOpposeNumAdd" parameterType="java.lang.String">
UPDATE epdc_topic_comment
SET UN_LIKE_COUNT = UN_LIKE_COUNT + 1
WHERE ID = #{commentId}
</update>
<update id="updateApproveNumSubtract" parameterType="java.lang.String">
UPDATE epdc_topic_comment
SET LIKE_COUNT = LIKE_COUNT - 1
WHERE ID = #{commentId}
</update>
<update id="updateOpposeNumSubtract" parameterType="java.lang.String">
UPDATE epdc_topic_comment
SET UN_LIKE_COUNT = UN_LIKE_COUNT - 1
WHERE ID = #{commentId}
</update>
<select id="selectCountOfStatementNum" resultType="long">
SELECT

Loading…
Cancel
Save