Browse Source

话题评论加分

dev_shibei_match
zxc 5 years ago
parent
commit
d12c664852
  1. 4
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/TopicConstant.java
  2. 9
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentDao.java
  3. 8
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicDao.java
  4. 42
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java
  5. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java
  6. 9
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentDao.xml
  7. 9
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml

4
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/TopicConstant.java

@ -103,4 +103,8 @@ public interface TopicConstant {
String GROUP_INFO_FAILURE = "根据groupId未查询到组信息......"; String GROUP_INFO_FAILURE = "根据groupId未查询到组信息......";
String CREATE_TOPIC_FAILURE = "发布话题加分失败......"; String CREATE_TOPIC_FAILURE = "发布话题加分失败......";
String COMMENT_TOPIC_FAILURE = "评论话题加分失败......";
String GET_CUSTOMER_ID_FAILURE = "查询客户ID失败......";
} }

9
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentDao.java

@ -22,7 +22,6 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.modules.comment.entity.ResiTopicCommentEntity; import com.epmet.modules.comment.entity.ResiTopicCommentEntity;
import com.epmet.resi.group.dto.comment.form.ResiQueryCommentFormDTO; import com.epmet.resi.group.dto.comment.form.ResiQueryCommentFormDTO;
import com.epmet.resi.group.dto.comment.result.ResiCommentResultDTO; import com.epmet.resi.group.dto.comment.result.ResiCommentResultDTO;
import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -60,4 +59,12 @@ public interface ResiTopicCommentDao extends BaseDao<ResiTopicCommentEntity> {
* @author sun * @author sun
*/ */
List<String> selectTopicList(@Param("userId") String userId); List<String> selectTopicList(@Param("userId") String userId);
/**
* @Description 根据userId查询此人今日评论次数
* @Param userId
* @author zxc
* @date 2020/12/23 上午11:09
*/
Integer selectCommentCountByUserId(@Param("userId") String userId);
} }

8
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicDao.java

@ -202,4 +202,12 @@ public interface ResiTopicDao extends BaseDao<ResiTopicEntity> {
* @date 2020/12/23 上午10:02 * @date 2020/12/23 上午10:02
*/ */
Integer selectPublishTopicCountByUserId(@Param("userId")String userId); Integer selectPublishTopicCountByUserId(@Param("userId")String userId);
/**
* @Description 根据topicId查询客户ID
* @Param topicId
* @author zxc
* @date 2020/12/23 下午2:25
*/
String selectCustomerIdByTopicId(@Param("topicId")String topicId);
} }

42
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java

@ -17,23 +17,27 @@
package com.epmet.modules.topic.service.impl; package com.epmet.modules.topic.service.impl;
import com.alibaba.fastjson.JSON;
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.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.MqConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.form.mq.MqBaseMsgDTO;
import com.epmet.commons.tools.dto.form.mq.eventmsg.BasePointEventMsg;
import com.epmet.commons.tools.enums.EventEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.scan.param.TextScanParamDTO; import com.epmet.commons.tools.scan.param.TextScanParamDTO;
import com.epmet.commons.tools.scan.param.TextTaskDTO; import com.epmet.commons.tools.scan.param.TextTaskDTO;
import com.epmet.commons.tools.scan.result.SyncScanResult; import com.epmet.commons.tools.scan.result.SyncScanResult;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.commons.tools.utils.ScanContentUtils;
import com.epmet.commons.tools.utils.SendMqMsgUtils;
import com.epmet.dto.form.UserResiInfoListFormDTO; import com.epmet.dto.form.UserResiInfoListFormDTO;
import com.epmet.dto.result.UserResiInfoResultDTO; import com.epmet.dto.result.UserResiInfoResultDTO;
import com.epmet.modules.comment.entity.ResiTopicCommentEntity; import com.epmet.modules.comment.entity.ResiTopicCommentEntity;
@ -58,7 +62,6 @@ import com.epmet.resi.group.dto.topic.ResiTopicCommentDTO;
import com.epmet.resi.group.dto.topic.ResiTopicDTO; import com.epmet.resi.group.dto.topic.ResiTopicDTO;
import com.epmet.resi.group.dto.topic.form.ResiPublishCommentFormDTO; import com.epmet.resi.group.dto.topic.form.ResiPublishCommentFormDTO;
import com.epmet.resi.group.dto.topic.result.IssueGridResultDTO; import com.epmet.resi.group.dto.topic.result.IssueGridResultDTO;
import com.epmet.resi.group.dto.topic.result.ResiTopicInfoResultDTO;
import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -224,6 +227,37 @@ public class ResiTopicCommentServiceImpl extends BaseServiceImpl<ResiTopicCommen
comment.setCreatedBy(tokenDto.getUserId()); comment.setCreatedBy(tokenDto.getUserId());
baseDao.insertOne(comment); baseDao.insertOne(comment);
// 话题评论前3次,加积分【对小组内话题进行15字以上评论】
Integer commentCount = baseDao.selectCommentCountByUserId(tokenDto.getUserId());
if (null != commentCount && commentCount <= NumConstant.THREE){
if (StringUtils.isNotBlank(commentContent) && commentContent.length() > NumConstant.FIFTEEN){
//mq的事件类型
MqBaseMsgDTO mqBaseMsgDTO = new MqBaseMsgDTO();
mqBaseMsgDTO.setEventClass(EventEnum.PARTICIPATE_ONE_TOPIC.getEventClass());
//事件code
mqBaseMsgDTO.setEventTag(EventEnum.PARTICIPATE_ONE_TOPIC.getEventTag());
List<BasePointEventMsg> pointEventMsgList = new ArrayList<>();
BasePointEventMsg pointEventMsg = new BasePointEventMsg();
String customerId = resiTopicdDao.selectCustomerIdByTopicId(resiCommentFormDTO.getTopicId());
if (StringUtils.isBlank(customerId)){
throw new RenException(TopicConstant.GET_CUSTOMER_ID_FAILURE);
}
pointEventMsg.setCustomerId(customerId);
pointEventMsg.setUserId(tokenDto.getUserId());
// 加分
pointEventMsg.setActionFlag(MqConstant.PLUS);
pointEventMsg.setIsCommon(false);
pointEventMsg.setEventTag(mqBaseMsgDTO.getEventTag());
pointEventMsgList.add(pointEventMsg);
mqBaseMsgDTO.setMsg(JSON.toJSONString(pointEventMsgList));
Result msgResult= SendMqMsgUtils.sendMsg(mqBaseMsgDTO);
if(!msgResult.success()){
logger.error(TopicConstant.COMMENT_TOPIC_FAILURE);
}
}
}
return new Result(); return new Result();
} }

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java

@ -360,7 +360,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
// 创建话题增加积分 // 创建话题增加积分
// 查询此人今日发表话题数量 // 查询此人今日发表话题数量
Integer publishTopicCount = baseDao.selectPublishTopicCountByUserId(tokenDto.getUserId()); Integer publishTopicCount = baseDao.selectPublishTopicCountByUserId(tokenDto.getUserId());
if (null != publishTopicCount && publishTopicCount <= NumConstant.FIVE){ if (null != publishTopicCount && publishTopicCount <= NumConstant.THREE){
//mq的事件类型 //mq的事件类型
MqBaseMsgDTO mqBaseMsgDTO = new MqBaseMsgDTO(); MqBaseMsgDTO mqBaseMsgDTO = new MqBaseMsgDTO();
mqBaseMsgDTO.setEventClass(EventEnum.PUBLISH_ONE_TOPIC.getEventClass()); mqBaseMsgDTO.setEventClass(EventEnum.PUBLISH_ONE_TOPIC.getEventClass());

9
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentDao.xml

@ -88,4 +88,13 @@
) )
</select> </select>
<!-- 根据userId查询此人今日评论次数 -->
<select id="selectCommentCountByUserId" resultType="java.lang.Integer">
SELECT COUNT(ID) FROM resi_topic_comment
WHERE DEL_FLAG = 0
AND DATE_FORMAT(CREATED_TIME,'%Y%m%d') = DATE_FORMAT(NOW(),'%Y%m%d')
AND CHAR_LENGTH(COMMENT_CONTENT) > 15
AND CREATED_BY = #{userId}
</select>
</mapper> </mapper>

9
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml

@ -551,5 +551,14 @@
AND CREATED_BY = #{userId} AND CREATED_BY = #{userId}
</select> </select>
<!-- 根据topicId查询客户ID -->
<select id="selectCustomerIdByTopicId" resultType="java.lang.String">
SELECT g.CUSTOMER_ID FROM resi_topic t
LEFT JOIN resi_group g ON g.ID = t.GROUP_ID
WHERE t.DEL_FLAG = 0
AND g.DEL_FLAG = 0
AND t.ID = #{topicId}
</select>
</mapper> </mapper>

Loading…
Cancel
Save