forked from luyan/epmet-cloud-lingshan
				
			
				 19 changed files with 410 additions and 0 deletions
			
			
		@ -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; | 
				
			|||
} | 
				
			|||
@ -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(); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -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); | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -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())); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
} | 
				
			|||
					Loading…
					
					
				
		Reference in new issue