Browse Source

小组成员删除

master
sunyuchao 4 years ago
parent
commit
74bbe6258b
  1. 8
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/GovIssueOpenFeignClient.java
  2. 5
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBack.java
  3. 10
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueApplicationController.java
  4. 8
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueApplicationDao.java
  5. 7
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueApplicationService.java
  6. 11
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueApplicationServiceImpl.java
  7. 14
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueApplicationDao.xml
  8. 43
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/ExitGroupFormDTO.java
  9. 48
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ExitGroupController.java
  10. 18
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ExitGroupService.java
  11. 120
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ExitGroupServiceImpl.java
  12. 6
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/dao/GroupMemeberOperationDao.java
  13. 6
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/dao/ResiGroupMemberDao.java
  14. 13
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentDao.java
  15. 12
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicDao.java
  16. 15
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/GroupMemeberOperationDao.xml
  17. 13
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/ResiGroupMemberDao.xml
  18. 27
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentDao.xml
  19. 26
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml

8
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<IssueResultDTO> queryIssueDetail(@RequestBody IssueDetailFormDTO formDTO);
/**
* @param topicIdList
* @Description 查询当前未成为议题的话题但是提交了转议题申请的
* @author sun
*/
@PostMapping("/gov/issue/issueapplication/notissuetotopicids")
Result<List<String>> notIssueToTopicIds(@RequestBody List<String> topicIdList);
}

5
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<IssueResultDTO> queryIssueDetail(IssueDetailFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "detail", formDTO);
}
@Override
public Result<List<String>> notIssueToTopicIds(List<String> topicIdList) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "notIssueToTopicIds", topicIdList);
}
}

10
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<List<UserPubAuditingIssueResDTO>>().ok(issueApplicationService.queryUserPubAuditingIssues(fomrDTO));
}
/**
* @param topicIdList
* @Description 查询当前未成为议题的话题但是提交了转议题申请的
* @author sun
*/
@PostMapping("notissuetotopicids")
public Result<List<String>> notIssueToTopicIds(@RequestBody List<String> topicIdList) {
return new Result<List<String>>().ok(issueApplicationService.notIssueToTopicIds(topicIdList));
}
}

8
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueApplicationDao.java

@ -66,4 +66,12 @@ public interface IssueApplicationDao extends BaseDao<IssueApplicationEntity> {
List<UserPubAuditingIssueResDTO> selectUserPubAuditingIssues(UserPubAuditingIssueFormDTO formDTO);
List<IssueApplicationDTO> selectByTopicId(@Param("topicId") String topicId);
/**
* @param topicIdList
* @Description 查询当前未成为议题的话题但是提交了转议题申请的
* @author sun
*/
List<String> selectTopicIdList(@Param("topicIdList") List<String> topicIdList);
}

7
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueApplicationService.java

@ -143,4 +143,11 @@ public interface IssueApplicationService extends BaseService<IssueApplicationEnt
* @Date 2020/11/23 9:35
**/
List<UserPubAuditingIssueResDTO> queryUserPubAuditingIssues(UserPubAuditingIssueFormDTO fomrDTO);
/**
* @param topicIdList
* @Description 查询当前未成为议题的话题但是提交了转议题申请的
* @author sun
*/
List<String> notIssueToTopicIds(List<String> topicIdList);
}

11
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<IssueApplicatio
return null;
}
/**
* @param topicIdList
* @Description 查询当前未成为议题的话题但是提交了转议题申请的
* @author sun
*/
@Override
public List<String> notIssueToTopicIds(List<String> topicIdList) {
List<String> idList = baseDao.selectTopicIdList(topicIdList);
return idList;
}
}

14
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
</select>
<select id="selectTopicIdList" resultType="java.lang.String">
SELECT
topic_id
FROM
issue_application
WHERE
del_flag = '0'
AND apply_status = 'under_auditing'
<foreach collection="topicIdList" item="topicId" open="AND (" close=")" separator=" OR ">
topic_id = #{topicId}
</foreach>
</select>
</mapper>

43
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;
}

48
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();
}
}

18
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);
}

120
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<String> delIdList = new ArrayList<>();
if ("yes".equals(formDTO.getShieldFlag())) {
//2-1.查询当前被删除人员发表过的话题还未成为议题的并且只是谈论中的数据
List<String> topicIdList = resiTopicDao.selectIdList(formDTO.getGroupId(), formDTO.getUserId());
//2-2.查询当前未成为议题的话题但是提交了转议题申请的话题
if (!CollectionUtils.isEmpty(topicIdList)) {
Result<List<String>> 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<String> 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()));
}
}
}

6
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<GroupMemeberOperationE
* @date 2020/12/18 下午4:40
*/
Integer checkAwaitAudit(@Param("userId")String userId,@Param("groupId")String groupId);
/**
* @Description 修改组成员数据状态
* @author sun
*/
int upByGroupAndUserId(GroupMemeberOperationDTO formDTO);
}

6
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/dao/ResiGroupMemberDao.java

@ -128,4 +128,10 @@ public interface ResiGroupMemberDao extends BaseDao<ResiGroupMemberEntity> {
* @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);
}

13
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<ResiTopicCommentEntity> {
* @date 2020/12/23 上午11:09
*/
Integer selectCommentCountByUserId(@Param("userId") String userId);
/**
* @Description 查询本小组内自己评论过的别人发表的话题Id集合
* @author sun
*/
List<String> selectTopicIds(@Param("groupId") String groupId, @Param("userId") String userId);
/**
* @Description 屏蔽自己发表的话题且自己评论过的评论
* @author sun
*/
void upTopicCommentList(@Param("delIdList") List<String> delIdList, @Param("userId") String userId);
}

12
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<ResiTopicEntity> {
String selectCustomerIdByTopicId(@Param("topicId")String topicId);
ResiTopicDTO selectByIssueId(@Param("issueId") String issueId);
/**
* @Description 查询当前小组里被删除人员创建的话题还未转为议题并且是讨论中的话题数据
* @author sun
*/
List<String> selectIdList(@Param("groupId") String groupId, @Param("userId") String userId);
/**
* @Description 批量修改话题状态
* @author sun
*/
int upTopicList(@Param("delIdList") List<String> delIdList, @Param("userId") String userId);
}

15
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'
</select>
<update id="upByGroupAndUserId">
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
</update>
</mapper>

13
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'
</select>
<update id="delByGroupAndUserId">
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
</update>
</mapper>

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

@ -97,4 +97,31 @@
AND CREATED_BY = #{userId}
</select>
<select id="selectTopicIds" resultType="java.lang.String">
SELECT DISTINCT
re.topic_id
FROM
resi_topic_comment re
INNER JOIN resi_topic rt ON re.topic_id = rt.id
WHERE
rt.del_flag = '0'
AND re.del_flag = '0'
<!-- 本小组内不是当前被删除人创建的话题 但是当前人评论过的话题 -->
AND rt.group_id = #{groupId}
AND rt.created_by != #{userId}
AND re.created_by = #{userId}
</select>
<update id="upTopicCommentList">
UPDATE resi_topic_comment
SET `status` = 'hidden',
updated_by = #{userId},
updated_time = NOW()
WHERE
del_flag = '0'
<foreach collection="delIdList" item="topicId" open="AND (" close=")" separator=" OR ">
topic_id = #{topicId}
</foreach>
</update>
</mapper>

26
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}
</select>
<select id="selectIdList" resultType="java.lang.String">
SELECT
id
FROM
resi_topic
WHERE
del_flag = '0'
AND shift_issue = '1'
AND `status` = 'discussing'
AND group_id = #{groupId}
AND created_by = #{userId}
</select>
<update id="upTopicList">
UPDATE resi_topic
SET status = 'hidden',
updated_by = #{userId},
updated_time = NOW()
WHERE
del_flag = '0'
<foreach collection="delIdList" item="id" open="AND (" close=")" separator=" OR ">
id = #{id}
</foreach>
</update>
</mapper>

Loading…
Cancel
Save