Browse Source

活动评论

dev_shibei_match
yinzuomei 4 years ago
parent
commit
67c18b2685
  1. 5
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 39
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentFormDTO.java
  3. 25
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentQueryFormDTO.java
  4. 30
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/CommentResultDTO.java
  5. 40
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/ActCommentController.java
  6. 4
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCommentDao.java
  7. 20
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCommentService.java
  8. 9
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java
  9. 107
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentServiceImpl.java
  10. 35
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java
  11. 16
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCommentDao.xml

5
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -169,8 +169,9 @@ public enum EpmetErrorCode {
PARTY_MEMBER_CREATE_BRANCH_GROUP(8906,"您不是党员,不能创建支部小组"),
NOT_IN_GROUP_CAN_NOT_VIEW(8907,"当前内容仅允许组内成员查看"),
PARTY_MEMBER_JOIN_BRANCH_GROUP(8908,"您不是党员,不能加入支部小组"),
CAN_NOT_CANCEL(8909,"活动%s,不能取消");
GROUP_ACT_CAN_NOT_CANCEL(8909,"活动%s,不能取消"),
//8910的msg动态赋值
GROUP_ACT_CAN_NOT_COMMENT(8910,"当前活动,不能评论");
private int code;
private String msg;

39
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentFormDTO.java

@ -0,0 +1,39 @@
package com.epmet.resi.group.dto.act.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 005评论活动
*
* @author yinzuomei@elink-cn.com
* @date 2021/4/20 12:35
*/
@Data
public class CommentFormDTO implements Serializable {
public interface AddUserInternalGroup {
}
public interface AddUserShowGroup extends CustomerClientShowGroup {
}
@NotBlank(message = "groupActId不能为空", groups = AddUserInternalGroup.class)
private String groupActId;
@NotBlank(message = "评论内容不能为空", groups = AddUserShowGroup.class)
@Length(max = 500, message = "评论内容最多输入500字", groups = AddUserShowGroup.class)
private String commentContent;
/**
* 当前用户id
*/
@NotBlank(message = "tokenDto获取userId为空", groups = AddUserInternalGroup.class)
private String userId;
@NotBlank(message = "tokenDto获取customerId为空", groups = AddUserInternalGroup.class)
private String customerId;
}

25
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentQueryFormDTO.java

@ -0,0 +1,25 @@
package com.epmet.resi.group.dto.act.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 006活动评论列表查询
*
* @author yinzuomei@elink-cn.com
* @date 2021/4/20 12:55
*/
@Data
public class CommentQueryFormDTO implements Serializable {
private static final long serialVersionUID = 4013876445914100561L;
public interface AddUserInternalGroup {
}
@NotBlank(message = "groupActId不能为空", groups = AddUserInternalGroup.class)
private String groupActId;
private Integer pageNo;
private Integer pageSize;
}

30
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/CommentResultDTO.java

@ -0,0 +1,30 @@
package com.epmet.resi.group.dto.act.result;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 006活动评论列表查询
*
* @author yinzuomei@elink-cn.com
* @date 2021/4/20 12:58
*/
@Data
public class CommentResultDTO implements Serializable {
private static final long serialVersionUID = 6487668038520643604L;
private String commentId;
private String commentContent;
private String commentUserHeadPhoto;
private String commentUserName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
private Date commentTime;
private String commentUserId;
}

40
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/ActCommentController.java

@ -17,11 +17,23 @@
package com.epmet.modules.act.controller;
import com.baomidou.mybatisplus.extension.api.R;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.modules.act.service.ActCommentService;
import com.epmet.resi.group.dto.act.form.CommentFormDTO;
import com.epmet.resi.group.dto.act.form.CommentQueryFormDTO;
import com.epmet.resi.group.dto.act.result.CommentResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 活动评论表
@ -36,5 +48,33 @@ public class ActCommentController {
@Autowired
private ActCommentService actCommentService;
/**
* @param tokenDto
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
* @author yinzuomei
* @description 005评论活动
* @Date 2021/4/20 12:38
**/
@PostMapping("submit")
public Result submitComment(@LoginUser TokenDto tokenDto, @RequestBody CommentFormDTO formDTO) {
formDTO.setUserId(tokenDto.getUserId());
formDTO.setCommentContent(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(formDTO,CommentFormDTO.AddUserShowGroup.class,CommentFormDTO.AddUserInternalGroup.class);
actCommentService.submitComment(formDTO);
return new Result();
}
/**
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.resi.group.dto.act.result.CommentResultDTO>>
* @param formDTO
* @author yinzuomei
* @description 006活动评论列表查询
* @Date 2021/4/20 13:01
**/
@PostMapping("comlist")
public Result<List<CommentResultDTO>> queryCommentList(@RequestBody CommentQueryFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, CommentQueryFormDTO.AddUserInternalGroup.class);
return new Result<List<CommentResultDTO>>().ok(actCommentService.queryCommentList(formDTO));
}
}

4
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCommentDao.java

@ -19,8 +19,11 @@ package com.epmet.modules.act.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.modules.act.entity.ActCommentEntity;
import com.epmet.resi.group.dto.act.result.CommentResultDTO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 活动评论表
*
@ -30,4 +33,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ActCommentDao extends BaseDao<ActCommentEntity> {
List<CommentResultDTO> selectCommentList(String groupActId);
}

20
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCommentService.java

@ -19,6 +19,11 @@ package com.epmet.modules.act.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.modules.act.entity.ActCommentEntity;
import com.epmet.resi.group.dto.act.form.CommentFormDTO;
import com.epmet.resi.group.dto.act.form.CommentQueryFormDTO;
import com.epmet.resi.group.dto.act.result.CommentResultDTO;
import java.util.List;
/**
* 活动评论表
@ -28,4 +33,19 @@ import com.epmet.modules.act.entity.ActCommentEntity;
*/
public interface ActCommentService extends BaseService<ActCommentEntity> {
/**
* 005评论活动
*
* @param formDTO
* @return
*/
void submitComment(CommentFormDTO formDTO);
/**
* 006活动评论列表查询
*
* @param formDTO
* @return com.epmet.resi.group.dto.act.result.CommentResultDTO
*/
List<CommentResultDTO> queryCommentList(CommentQueryFormDTO formDTO);
}

9
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java

@ -20,6 +20,7 @@ package com.epmet.modules.act.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.modules.act.entity.GroupActInfoEntity;
import com.epmet.resi.group.dto.act.GroupActIdDTO;
import com.epmet.resi.group.dto.act.GroupActInfoDTO;
import com.epmet.resi.group.dto.act.form.ActDetailFormDTO;
import com.epmet.resi.group.dto.act.form.ActReadViewFormDTO;
import com.epmet.resi.group.dto.act.form.CancelActFormDTO;
@ -66,4 +67,12 @@ public interface GroupActInfoService extends BaseService<GroupActInfoEntity> {
* @return com.epmet.resi.group.dto.act.GroupActIdDTO
*/
GroupActIdDTO cancelAct(CancelActFormDTO formDTO);
/**
* 查询活动主信息
*
* @param groupActId
* @return com.epmet.resi.group.dto.act.GroupActInfoDTO
*/
GroupActInfoDTO getGroupActInfoDTO(String groupActId);
}

107
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentServiceImpl.java

@ -18,10 +18,34 @@
package com.epmet.modules.act.service.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.scan.param.TextScanParamDTO;
import com.epmet.commons.tools.scan.param.TextTaskDTO;
import com.epmet.commons.tools.scan.result.SyncScanResult;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.ScanContentUtils;
import com.epmet.dto.result.UserBaseInfoResultDTO;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.modules.act.dao.ActCommentDao;
import com.epmet.modules.act.entity.ActCommentEntity;
import com.epmet.modules.act.service.ActCommentService;
import com.epmet.modules.act.service.GroupActInfoService;
import com.epmet.modules.constant.GroupActConstant;
import com.epmet.resi.group.dto.act.GroupActInfoDTO;
import com.epmet.resi.group.dto.act.form.CommentFormDTO;
import com.epmet.resi.group.dto.act.form.CommentQueryFormDTO;
import com.epmet.resi.group.dto.act.result.CommentResultDTO;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* 活动评论表
@ -32,5 +56,88 @@ import org.springframework.stereotype.Service;
@Service
public class ActCommentServiceImpl extends BaseServiceImpl<ActCommentDao, ActCommentEntity> implements ActCommentService {
@Value("${openapi.scan.server.url}")
private String scanApiUrl;
@Value("${openapi.scan.method.textSyncScan}")
private String textSyncScanMethod;
@Autowired
private GroupActInfoService groupActInfoService;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
/**
* 005评论活动
*
* @param formDTO
* @return
*/
@Override
public void submitComment(CommentFormDTO formDTO) {
//1、关闭和已取消不能评论
GroupActInfoDTO groupActInfoDTO = groupActInfoService.getGroupActInfoDTO(formDTO.getGroupActId());
if (GroupActConstant.CLOSED.equals(groupActInfoDTO.getStatus())) {
throw new RenException(EpmetErrorCode.GROUP_ACT_CAN_NOT_COMMENT.getCode(), "当前活动已关闭,不能评论");
} else if (GroupActConstant.CANCELED.equals(groupActInfoDTO.getStatus())) {
throw new RenException(EpmetErrorCode.GROUP_ACT_CAN_NOT_COMMENT.getCode(), "当前活动已取消,不能评论");
}
//2、评论内容审核
TextScanParamDTO textScanParamDTO = new TextScanParamDTO();
TextTaskDTO taskDTO = new TextTaskDTO();
taskDTO.setContent(formDTO.getCommentContent());
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", ""));
textScanParamDTO.getTasks().add(taskDTO);
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO);
if (!textSyncScanResult.success()) {
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
} else {
if (!textSyncScanResult.getData().isAllPass()) {
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode(), EpmetErrorCode.TEXT_SCAN_FAILED.getMsg());
}
}
//3、插入记录
ActCommentEntity actCommentEntity = new ActCommentEntity();
actCommentEntity.setCustomerId(formDTO.getCustomerId());
actCommentEntity.setCommentContent(formDTO.getCommentContent());
actCommentEntity.setCommentUserId(formDTO.getUserId());
actCommentEntity.setGroupActId(formDTO.getGroupActId());
baseDao.insert(actCommentEntity);
}
/**
* 006活动评论列表查询
*
* @param formDTO
* @return com.epmet.resi.group.dto.act.result.CommentResultDTO
*/
@Override
public List<CommentResultDTO> queryCommentList(CommentQueryFormDTO formDTO) {
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize());
List<CommentResultDTO> list=baseDao.selectCommentList(formDTO.getGroupActId());
if(CollectionUtils.isEmpty(list)){
return Collections.EMPTY_LIST;
}
//2.调用user服务,查询人员基础数据
List<String> userIdList = list.stream().map(CommentResultDTO::getCommentUserId).collect(Collectors.toList());
Result<List<UserBaseInfoResultDTO>> result = epmetUserOpenFeignClient.queryUserBaseInfo(userIdList);
if (!result.success()) {
throw new RenException("调用user服务,获取用户基础数据失败");
}
if (!CollectionUtils.isEmpty(result.getData())) {
//3.遍历封装数据并返回
list.forEach(l -> {
result.getData().forEach(user -> {
if (l.getCommentUserId().equals(user.getUserId())) {
l.setCommentUserHeadPhoto(user.getHeadImgUrl());
l.setCommentUserName(user.getSurname().concat(user.getName()));
}
});
});
}
return list;
}
}

35
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java

@ -52,6 +52,7 @@ import com.epmet.modules.constant.GroupActConstant;
import com.epmet.modules.group.service.ResiGroupService;
import com.epmet.modules.member.service.ResiGroupMemberService;
import com.epmet.resi.group.dto.act.GroupActIdDTO;
import com.epmet.resi.group.dto.act.GroupActInfoDTO;
import com.epmet.resi.group.dto.act.form.ActDetailFormDTO;
import com.epmet.resi.group.dto.act.form.ActReadViewFormDTO;
import com.epmet.resi.group.dto.act.form.CancelActFormDTO;
@ -268,7 +269,6 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
private void scanActContent(String title, List<String> textList, List<String> imgList) {
//活动标题
if (StringUtils.isNotBlank(title)) {
//创建话题内容审核
TextScanParamDTO textScanParamDTO = new TextScanParamDTO();
TextTaskDTO taskDTO = new TextTaskDTO();
taskDTO.setContent(title);
@ -547,17 +547,31 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
}
//2、活动已关闭,不能取消
if (GroupActConstant.CLOSED.equals(actInfoEntity.getStatus())) {
throw new RenException(EpmetErrorCode.CAN_NOT_CANCEL.getCode(), String.format(EpmetErrorCode.CAN_NOT_CANCEL.getMsg(), "已关闭"));
throw new RenException(EpmetErrorCode.GROUP_ACT_CAN_NOT_CANCEL.getCode(), String.format(EpmetErrorCode.GROUP_ACT_CAN_NOT_CANCEL.getMsg(), "已关闭"));
} else if (GroupActConstant.CANCELED.equals(actInfoEntity.getStatus())) {
throw new RenException(EpmetErrorCode.CAN_NOT_CANCEL.getCode(), "活动已取消");
throw new RenException(EpmetErrorCode.GROUP_ACT_CAN_NOT_CANCEL.getCode(), "活动已取消");
}
//3、记录取消时间
//3、取消原因审核
TextScanParamDTO textScanParamDTO = new TextScanParamDTO();
TextTaskDTO taskDTO = new TextTaskDTO();
taskDTO.setContent(formDTO.getReason());
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", ""));
textScanParamDTO.getTasks().add(taskDTO);
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO);
if (!textSyncScanResult.success()) {
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
} else {
if (!textSyncScanResult.getData().isAllPass()) {
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode(), EpmetErrorCode.TEXT_SCAN_FAILED.getMsg());
}
}
//4、记录取消时间
Date nowDate=new Date();
actInfoEntity.setCanceledTime(nowDate);
actInfoEntity.setStatus(GroupActConstant.CANCELED);
baseDao.updateById(actInfoEntity);
//4、插入一条操作日志
//5、插入一条操作日志
ActOperationRecordEntity actOperationRecordEntity = new ActOperationRecordEntity();
actOperationRecordEntity.setCustomerId(actInfoEntity.getCustomerId());
actOperationRecordEntity.setOperateUserId(formDTO.getUserId());
@ -572,4 +586,15 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr
resultDTO.setGroupActId(formDTO.getGroupActId());
return resultDTO;
}
/**
* 查询活动主信息
*
* @param groupActId
* @return com.epmet.resi.group.dto.act.GroupActInfoDTO
*/
@Override
public GroupActInfoDTO getGroupActInfoDTO(String groupActId) {
return ConvertUtils.sourceToTarget(baseDao.selectById(groupActId), GroupActInfoDTO.class);
}
}

16
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCommentDao.xml

@ -3,6 +3,20 @@
<mapper namespace="com.epmet.modules.act.dao.ActCommentDao">
<select id="selectCommentList" resultType="com.epmet.resi.group.dto.act.result.CommentResultDTO"
parameterType="java.lang.String">
SELECT
ac.id as commentId,
ac.COMMENT_CONTENT as commentContent,
ac.CREATED_TIME as commentTime,
ac.COMMENT_USER_ID as commentUserId
FROM
act_comment ac
WHERE
ac.DEL_FLAG = '0'
AND ac.GROUP_ACT_ID = #{groupActId}
ORDER BY
ac.CREATED_TIME DESC
</select>
</mapper>
Loading…
Cancel
Save