diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/GovIssueOpenFeignClient.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/GovIssueOpenFeignClient.java index f5d2786c93..f1768a23fd 100644 --- a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/GovIssueOpenFeignClient.java +++ b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/GovIssueOpenFeignClient.java @@ -244,4 +244,12 @@ public interface GovIssueOpenFeignClient { @PostMapping("/gov/issue/issue/detail") Result queryIssueDetail(@RequestBody IssueDetailFormDTO formDTO); + + /** + * @param topicIdList + * @Description 查询当前未成为议题的话题但是提交了转议题申请的 + * @author sun + */ + @PostMapping("/gov/issue/issueapplication/notissuetotopicids") + Result> notIssueToTopicIds(@RequestBody List topicIdList); } diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBack.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBack.java index 84b1220993..53f22684a1 100644 --- a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBack.java +++ b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBack.java @@ -211,4 +211,9 @@ public class GovIssueOpenFeignClientFallBack implements GovIssueOpenFeignClient public Result queryIssueDetail(IssueDetailFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "detail", formDTO); } + + @Override + public Result> notIssueToTopicIds(List topicIdList) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "notIssueToTopicIds", topicIdList); + } } diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueApplicationController.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueApplicationController.java index 63f5af6117..575b75a56b 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueApplicationController.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueApplicationController.java @@ -164,4 +164,14 @@ public class IssueApplicationController { ValidatorUtils.validateEntity(fomrDTO, PageFormDTO.AddUserInternalGroup.class); return new Result>().ok(issueApplicationService.queryUserPubAuditingIssues(fomrDTO)); } + + /** + * @param topicIdList + * @Description 查询当前未成为议题的话题但是提交了转议题申请的 + * @author sun + */ + @PostMapping("notissuetotopicids") + public Result> notIssueToTopicIds(@RequestBody List topicIdList) { + return new Result>().ok(issueApplicationService.notIssueToTopicIds(topicIdList)); + } } \ No newline at end of file diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueApplicationDao.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueApplicationDao.java index 38ec62c1d6..33296076b6 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueApplicationDao.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueApplicationDao.java @@ -66,4 +66,12 @@ public interface IssueApplicationDao extends BaseDao { List selectUserPubAuditingIssues(UserPubAuditingIssueFormDTO formDTO); List selectByTopicId(@Param("topicId") String topicId); + + /** + * @param topicIdList + * @Description 查询当前未成为议题的话题但是提交了转议题申请的 + * @author sun + */ + List selectTopicIdList(@Param("topicIdList") List topicIdList); + } \ No newline at end of file diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueApplicationService.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueApplicationService.java index 6c2df1b318..aecc10b0b5 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueApplicationService.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueApplicationService.java @@ -143,4 +143,11 @@ public interface IssueApplicationService extends BaseService queryUserPubAuditingIssues(UserPubAuditingIssueFormDTO fomrDTO); + + /** + * @param topicIdList + * @Description 查询当前未成为议题的话题但是提交了转议题申请的 + * @author sun + */ + List notIssueToTopicIds(List topicIdList); } \ No newline at end of file diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueApplicationServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueApplicationServiceImpl.java index 71e62d3e1f..a699e58a61 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueApplicationServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueApplicationServiceImpl.java @@ -175,4 +175,15 @@ public class IssueApplicationServiceImpl extends BaseServiceImpl notIssueToTopicIds(List topicIdList) { + List idList = baseDao.selectTopicIdList(topicIdList); + return idList; + } + } \ No newline at end of file diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueApplicationDao.xml b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueApplicationDao.xml index 3d94af1c56..2820a43019 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueApplicationDao.xml +++ b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueApplicationDao.xml @@ -72,4 +72,18 @@ AND TOPIC_ID = #{topicId} ORDER BY CREATED_TIME DESC + + + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/ExitGroupFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/ExitGroupFormDTO.java new file mode 100644 index 0000000000..0c10e60de1 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/ExitGroupFormDTO.java @@ -0,0 +1,43 @@ +package com.epmet.resi.group.dto.group.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @author sun + * @Description 删除组员-接口入参 + */ +@NoArgsConstructor +@Data +public class ExitGroupFormDTO implements Serializable { + + private static final long serialVersionUID = 9033824126731443502L; + /** + * 屏蔽突然的话题及评论,勾选:yes;不勾选:no + */ + @NotBlank(message = "是否屏蔽话题及评论不能为空") + private String shieldFlag; + /** + * 组成员用户id + */ + @NotBlank(message = "被删除用户Id不能为空") + private String userId; + /** + * 小组ID + */ + @NotBlank(message = "小组Id不能为空") + private String groupId; + + /** + * 客户Id + */ + private String customerId; + + /** + * OPERATE_USER_ID操作人id + */ + private String operateUserId; +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ExitGroupController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ExitGroupController.java new file mode 100644 index 0000000000..9f58b1eba7 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ExitGroupController.java @@ -0,0 +1,48 @@ +package com.epmet.modules.group.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.exception.RenException; +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.group.service.ExitGroupService; +import com.epmet.resi.group.dto.group.form.ExitGroupFormDTO; +import lombok.extern.slf4j.Slf4j; +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; + +/** + * @author sun + * @dscription + */ +@Slf4j +@RestController +@RequestMapping("exitgroup") +public class ExitGroupController { + @Autowired + private ExitGroupService exitGroupService; + + + /** + * @param formDTO + * @Description 删除组员 + * @author sun + * 如果shieldFlag=yes, 则将讨论中的话题并且不存在正在审核的议题申请的置为已屏蔽 + * 不要忘了插入:exit_group_record + */ + @PostMapping("removemember") + public Result removeMember(@LoginUser TokenDto tokenDto, @RequestBody ExitGroupFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + if(!"".equals(formDTO.getShieldFlag())&&!"".equals(formDTO.getShieldFlag())){ + throw new RenException("参数错误,是否屏蔽历史话题参数值错误"); + } + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setOperateUserId(tokenDto.getUserId()); + exitGroupService.removeMember(formDTO); + return new Result(); + } + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ExitGroupService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ExitGroupService.java new file mode 100644 index 0000000000..af8b7f30c7 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ExitGroupService.java @@ -0,0 +1,18 @@ +package com.epmet.modules.group.service; + +import com.epmet.resi.group.dto.group.form.ExitGroupFormDTO; + +/** + * @author sun + * @dscription + */ +public interface ExitGroupService { + + /** + * @param formDTO + * @Description 删除组员 + * @author sun + */ + void removeMember(ExitGroupFormDTO formDTO); + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ExitGroupServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ExitGroupServiceImpl.java new file mode 100644 index 0000000000..0b8392a927 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ExitGroupServiceImpl.java @@ -0,0 +1,120 @@ +package com.epmet.modules.group.service.impl; + +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.Result; +import com.epmet.feign.GovIssueOpenFeignClient; +import com.epmet.modules.group.service.ExitGroupService; +import com.epmet.modules.member.dao.ExitGroupRecordDao; +import com.epmet.modules.member.dao.GroupMemeberOperationDao; +import com.epmet.modules.member.dao.ResiGroupMemberDao; +import com.epmet.modules.member.entity.ExitGroupRecordEntity; +import com.epmet.modules.topic.dao.ResiTopicCommentDao; +import com.epmet.modules.topic.dao.ResiTopicDao; +import com.epmet.modules.topic.entity.ResiTopicEntity; +import com.epmet.resi.group.dto.group.form.ExitGroupFormDTO; +import com.epmet.resi.group.dto.member.GroupMemeberOperationDTO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author sun + * @dscription + */ +@Slf4j +@Service +public class ExitGroupServiceImpl implements ExitGroupService { + + @Autowired + private ResiGroupMemberDao resiGroupMemberDao; + @Autowired + private GroupMemeberOperationDao groupMemeberOperationDao; + @Autowired + private ExitGroupRecordDao exitGroupRecordDao; + @Autowired + private ResiTopicDao resiTopicDao; + @Autowired + private GovIssueOpenFeignClient govIssueOpenFeignClient; + @Autowired + private ResiTopicCommentDao resiTopicCommentDao; + + /** + * @param formDTO + * @Description 删除组员 + * @author sun + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void removeMember(ExitGroupFormDTO formDTO) { + //1.校验被删除人员是否是当前小组内成员 + int num = resiGroupMemberDao.checkUserInGroup(formDTO.getUserId(), formDTO.getGroupId()); + if (num < NumConstant.ONE) { + throw new RenException("当前待删除人员不是本小组成员"); + } + + //2.判断是否屏蔽本小组内历史话题 + List delIdList = new ArrayList<>(); + if ("yes".equals(formDTO.getShieldFlag())) { + //2-1.查询当前被删除人员发表过的话题还未成为议题的并且只是谈论中的数据 + List topicIdList = resiTopicDao.selectIdList(formDTO.getGroupId(), formDTO.getUserId()); + //2-2.查询当前未成为议题的话题但是提交了转议题申请的话题 + if (!CollectionUtils.isEmpty(topicIdList)) { + Result> listResult = govIssueOpenFeignClient.notIssueToTopicIds(topicIdList); + if (!listResult.success()) { + throw new RenException(listResult.getInternalMsg()); + } + //获取只是单纯的话题既没有被转成议题又不存在转议题申请待审核数据 + delIdList = topicIdList.stream().filter(o -> !listResult.getData().contains(o)).collect(Collectors.toList()); + } + //2-3.屏蔽这些单纯的话题 + if (delIdList.size() > NumConstant.ZERO) { + resiTopicDao.upTopicList(delIdList, formDTO.getOperateUserId()); + } + } + + //3.判断是否屏蔽本小组内历史评论 + if ("yes".equals(formDTO.getShieldFlag())) { + //3-1.查询别人的话题但自己评论过的话题Id + List commetTopicList = resiTopicCommentDao.selectTopicIds(formDTO.getGroupId(), formDTO.getUserId()); + delIdList.addAll(commetTopicList); + //3-2.本小组内屏蔽自己创建的话题发表过的评论以及别人发表的话题自己评论过的评论 + if (delIdList.size() > NumConstant.ZERO) { + resiTopicCommentDao.upTopicCommentList(delIdList, formDTO.getOperateUserId()); + } + } + + //4.修改组成员出入群记录表数据状态、删除组成员关系表数据、新增退群记录表数据 + //4-1.修改组成员出入群记录表数据状态 + GroupMemeberOperationDTO operationDTO = new GroupMemeberOperationDTO(); + operationDTO.setGroupId(formDTO.getGroupId()); + operationDTO.setCustomerUserId(formDTO.getUserId()); + operationDTO.setOperateUserId(formDTO.getOperateUserId()); + if (groupMemeberOperationDao.upByGroupAndUserId(operationDTO) < NumConstant.ONE) { + throw new RenException(String.format("修改组成员出入群记录表数据失败,小组Id【%s】被修改人Id【%s】", formDTO.getGroupId(), formDTO.getUserId())); + } + //4-2.删除组成员关系表数据并修改状态 + if (resiGroupMemberDao.delByGroupAndUserId(formDTO.getGroupId(), formDTO.getUserId()) < NumConstant.ONE) { + throw new RenException(String.format("删除组成员关系表数据操作失败,小组Id【%s】被修改人Id【%s】", formDTO.getGroupId(), formDTO.getUserId())); + } + //4-3.新增退群记录表数据 + ExitGroupRecordEntity entity = new ExitGroupRecordEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setGroupId(formDTO.getGroupId()); + entity.setMemberUserId(formDTO.getUserId()); + entity.setShieldFlag(formDTO.getShieldFlag()); + entity.setLeaveType("0"); + if (exitGroupRecordDao.insert(entity) < NumConstant.ONE) { + throw new RenException(String.format("新增退群记录表数据操作失败,小组Id【%s】被修改人Id【%s】", formDTO.getGroupId(), formDTO.getUserId())); + } + + } + + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/dao/GroupMemeberOperationDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/dao/GroupMemeberOperationDao.java index 49ecf7fbbe..bf0f443668 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/dao/GroupMemeberOperationDao.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/dao/GroupMemeberOperationDao.java @@ -59,4 +59,10 @@ public interface GroupMemeberOperationDao extends BaseDao { * @date 2020/12/18 下午4:33 */ Integer checkUserInGroup(@Param("userId")String userId,@Param("groupId")String groupId); + + /** + * @Description 修改组成员数据状态 + * @author sun + */ + int delByGroupAndUserId(@Param("groupId")String groupId, @Param("userId")String userId); } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentDao.java index 57ef0adc97..efa950684b 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentDao.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentDao.java @@ -67,4 +67,17 @@ public interface ResiTopicCommentDao extends BaseDao { * @date 2020/12/23 上午11:09 */ Integer selectCommentCountByUserId(@Param("userId") String userId); + + /** + * @Description 查询本小组内自己评论过的别人发表的话题Id集合 + * @author sun + */ + List selectTopicIds(@Param("groupId") String groupId, @Param("userId") String userId); + + /** + * @Description 屏蔽自己发表的话题且自己评论过的评论 + * @author sun + */ + void upTopicCommentList(@Param("delIdList") List delIdList, @Param("userId") String userId); + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicDao.java index ebbab2046a..abc817659d 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicDao.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicDao.java @@ -212,4 +212,16 @@ public interface ResiTopicDao extends BaseDao { String selectCustomerIdByTopicId(@Param("topicId")String topicId); ResiTopicDTO selectByIssueId(@Param("issueId") String issueId); + + /** + * @Description 查询当前小组里被删除人员创建的话题还未转为议题并且是讨论中的话题数据 + * @author sun + */ + List selectIdList(@Param("groupId") String groupId, @Param("userId") String userId); + + /** + * @Description 批量修改话题状态 + * @author sun + */ + int upTopicList(@Param("delIdList") List delIdList, @Param("userId") String userId); } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/GroupMemeberOperationDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/GroupMemeberOperationDao.xml index c47f80f4d3..cd7d33e5ca 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/GroupMemeberOperationDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/GroupMemeberOperationDao.xml @@ -39,4 +39,19 @@ AND GROUP_ID = #{groupId} AND OPERATE_STATUS = 'under_auditting' + + + UPDATE group_memeber_operation + SET operate_status = 'removed', + operate_user_id = #{operateUserId}, + updated_by = #{operateUserId}, + updated_time = NOW() + WHERE + group_id = #{groupId} + AND customer_user_id = #{customerUserId} + ORDER BY + created_time DESC + LIMIT 1 + + diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/ResiGroupMemberDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/ResiGroupMemberDao.xml index ea34d4a39c..013e384ec9 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/ResiGroupMemberDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/ResiGroupMemberDao.xml @@ -164,4 +164,17 @@ AND RESI_GROUP_ID = #{groupId} AND `STATUS` = 'approved' + + + UPDATE resi_group_member + SET del_flag = '1', + status = 'removed' + WHERE + resi_group_id = #{groupId} + AND customer_user_id = #{userId} + ORDER BY + created_time DESC + LIMIT 1 + + diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentDao.xml index 3dc42e00a4..7fe318b292 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentDao.xml @@ -97,4 +97,31 @@ AND CREATED_BY = #{userId} + + + + UPDATE resi_topic_comment + SET `status` = 'hidden', + updated_by = #{userId}, + updated_time = NOW() + WHERE + del_flag = '0' + + topic_id = #{topicId} + + + diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml index e1e57899c9..183169ab08 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml @@ -570,5 +570,31 @@ where rt.DEL_FLAG='0' and rt.ISSUE_ID=#{issueId} + + + + + UPDATE resi_topic + SET status = 'hidden', + updated_by = #{userId}, + updated_time = NOW() + WHERE + del_flag = '0' + + id = #{id} + + +