|  |  | @ -17,6 +17,7 @@ | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | package com.epmet.modules.topic.service.impl; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
			
				
					|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
	
		
			
				
					|  |  | @ -55,13 +56,15 @@ import com.epmet.resi.group.constant.TopicConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.member.form.RemoveMemberFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.topic.ResiTopicDTO; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.topic.form.ResiTopicOperationFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.topic.form.ResiTopicPageFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.topic.form.ResiTopicPublishFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.topic.result.ResiTopicDetailResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.topic.result.ResiTopicInfoResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.logging.Log; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.logging.LogFactory; | 
			
		
	
		
			
				
					|  |  |  | import org.bouncycastle.math.raw.Mod; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
	
		
			
				
					|  |  | @ -108,6 +111,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private ResiTopicOperationService resiTopicOperationService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private final Log logger = LogFactory.getLog(getClass()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public PageData<ResiTopicDTO> page(Map<String, Object> params) { | 
			
		
	
	
		
			
				
					|  |  | @ -198,6 +202,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |         baseDao.insertOne(topic); | 
			
		
	
		
			
				
					|  |  |  |         if(StringUtils.isBlank(topic.getId())){ | 
			
		
	
		
			
				
					|  |  |  |             //没有返回主键
 | 
			
		
	
		
			
				
					|  |  |  |             logger.warn(ModuleConstant.NO_PRIMARY_KEY_RETURNED); | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(ModuleConstant.NO_PRIMARY_KEY_RETURNED); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         if(null != resiTopicPublishFormDTO.getAttachmentList() && resiTopicPublishFormDTO.getAttachmentList().size() > 0){ | 
			
		
	
	
		
			
				
					|  |  | @ -207,7 +212,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |                 attachment.setAttachmentUrl(url); | 
			
		
	
		
			
				
					|  |  |  |                 attachment.setTopicId(topic.getId()); | 
			
		
	
		
			
				
					|  |  |  |                 attachment.setCreatedBy(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |                 attachment.setAttachmentFormat(url.substring(url.lastIndexOf(".") + 1).toLowerCase()); | 
			
		
	
		
			
				
					|  |  |  |                 attachment.setAttachmentFormat(url.substring(url.lastIndexOf(".") + NumConstant.ONE).toLowerCase()); | 
			
		
	
		
			
				
					|  |  |  |                 attachment.setSort(sort++); | 
			
		
	
		
			
				
					|  |  |  |                 resiTopicAttachmentDao.insertOne(attachment); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
	
		
			
				
					|  |  | @ -227,6 +232,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |         List<ResiGroupStatisticalEntity> statistical =  resiGroupStatisticalDao.selectList(wrapper); | 
			
		
	
		
			
				
					|  |  |  |         if(null != statistical && statistical.size() >= NumConstant.ONE){ | 
			
		
	
		
			
				
					|  |  |  |             if(statistical.size() != NumConstant.ONE){ | 
			
		
	
		
			
				
					|  |  |  |                 logger.warn(ModuleConstant.GROUP_STASTICAL_NOT_SINGLE); | 
			
		
	
		
			
				
					|  |  |  |                 return new Result().error(ModuleConstant.GROUP_STASTICAL_NOT_SINGLE); | 
			
		
	
		
			
				
					|  |  |  |             }else{ | 
			
		
	
		
			
				
					|  |  |  |                 ResiGroupStatisticalEntity statistical2Update = new ResiGroupStatisticalEntity(); | 
			
		
	
	
		
			
				
					|  |  | @ -237,6 +243,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |                 resiGroupStatisticalDao.updateById(statistical2Update); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         }else{ | 
			
		
	
		
			
				
					|  |  |  |             logger.warn(ModuleConstant.NO_SUCH_GROUP_STASTICAL_INFO); | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(ModuleConstant.NO_SUCH_GROUP_STASTICAL_INFO); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -360,6 +367,20 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |         operationRecord.setCreatedBy(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         resiTopicOperationDao.insertOne(operationRecord); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         // 4.组话题数量-1 (对应的在解除屏蔽时组话题数量+1)
 | 
			
		
	
		
			
				
					|  |  |  |         QueryWrapper<ResiGroupStatisticalEntity> statisticalWrapper = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |         statisticalWrapper.eq(TopicConstant.RESI_GROUP_ID,topic.getGroupId()); | 
			
		
	
		
			
				
					|  |  |  |         statisticalWrapper.eq(FieldConstant.DEL_FLAG,NumConstant.ZERO_STR); | 
			
		
	
		
			
				
					|  |  |  |         ResiGroupStatisticalEntity statistical = resiGroupStatisticalDao.selectOne(statisticalWrapper); | 
			
		
	
		
			
				
					|  |  |  |         if(null != statistical && StringUtils.isNotBlank(statistical.getId()) && StringUtils.isNotBlank(statistical.getResiGroupId())){ | 
			
		
	
		
			
				
					|  |  |  |             ResiGroupStatisticalEntity statistical2Update = new ResiGroupStatisticalEntity(); | 
			
		
	
		
			
				
					|  |  |  |             statistical2Update.setId(statistical.getId()); | 
			
		
	
		
			
				
					|  |  |  |             statistical2Update.setTotalTopics( | 
			
		
	
		
			
				
					|  |  |  |                     null == statistical.getTotalTopics() || statistical.getTotalTopics() == 0 ? 0 : statistical.getTotalTopics() - NumConstant.ONE | 
			
		
	
		
			
				
					|  |  |  |             ); | 
			
		
	
		
			
				
					|  |  |  |             resiGroupStatisticalDao.updateById(statistical2Update); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new Result(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -399,6 +420,18 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |             operation.setCreatedBy(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |             resiTopicOperationDao.insertOne(operation); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         QueryWrapper<ResiGroupStatisticalEntity> statisticalWrapper = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |         statisticalWrapper.eq(TopicConstant.RESI_GROUP_ID,topic.getGroupId()); | 
			
		
	
		
			
				
					|  |  |  |         statisticalWrapper.eq(FieldConstant.DEL_FLAG,NumConstant.ZERO_STR); | 
			
		
	
		
			
				
					|  |  |  |         ResiGroupStatisticalEntity statistical = resiGroupStatisticalDao.selectOne(statisticalWrapper); | 
			
		
	
		
			
				
					|  |  |  |         if(null != statistical && StringUtils.isNotBlank(statistical.getId())){ | 
			
		
	
		
			
				
					|  |  |  |             ResiGroupStatisticalEntity statistical2Update = new ResiGroupStatisticalEntity(); | 
			
		
	
		
			
				
					|  |  |  |             statistical2Update.setId(statistical.getId()); | 
			
		
	
		
			
				
					|  |  |  |             statistical2Update.setTotalTopics( | 
			
		
	
		
			
				
					|  |  |  |                     statistical.getTotalTopics() == null  ? 0 : statistical.getTotalTopics() + topicIds.size() | 
			
		
	
		
			
				
					|  |  |  |             ); | 
			
		
	
		
			
				
					|  |  |  |             resiGroupStatisticalDao.updateById(statistical2Update); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new Result(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
	
		
			
				
					|  |  | @ -450,14 +483,10 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Result<ResiTopicDetailResultDTO> getTopicDetail(TokenDto tokenDto, String topicId) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if(StringUtils.isBlank(topicId)){ | 
			
		
	
		
			
				
					|  |  |  |             return new Result<ResiTopicDetailResultDTO>().error(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //1.获取话题基本信息
 | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicEntity topicDetail = baseDao.selectById(topicId); | 
			
		
	
		
			
				
					|  |  |  |         if(null == topicDetail || !StringUtils.equals(topicDetail.getId(),topicId)){ | 
			
		
	
		
			
				
					|  |  |  |             logger.warn(ModuleConstant.NO_SUCH_TOPIC); | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(ModuleConstant.NO_SUCH_TOPIC); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicDetailResultDTO resultDTO = new ResiTopicDetailResultDTO(); | 
			
		
	
	
		
			
				
					|  |  | @ -491,7 +520,8 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |                 resultDTO.setReleaseUserHeadPhoto(userInfo.getData().getHeadPhoto()); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         }else{ | 
			
		
	
		
			
				
					|  |  |  |             logger.warn(ModuleConstant.USER_INFO_LIST_NOT_FOUND); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -509,6 +539,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Result<List<ResiTopicInfoResultDTO>> getHiddenTopics(TokenDto tokenDto, ResiTopicPageFormDTO topicPageFormDTO) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //1.查询屏蔽话题列表
 | 
			
		
	
		
			
				
					|  |  |  |         topicPageFormDTO.setUserId(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         topicPageFormDTO.setPageNo((topicPageFormDTO.getPageNo() - NumConstant.ONE) * topicPageFormDTO.getPageSize()); | 
			
		
	
	
		
			
				
					|  |  | @ -518,7 +549,17 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |                 baseDao.getPastTopics(topicPageFormDTO); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //2.遍历用户信息
 | 
			
		
	
		
			
				
					|  |  |  |         if (null != hiddenTopics && hiddenTopics.size() > 0) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             List<String> userIdList = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |             for (ResiTopicInfoResultDTO topic : hiddenTopics) { | 
			
		
	
		
			
				
					|  |  |  |                 userIdList.add(topic.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             UserResiInfoListFormDTO formDTO = new UserResiInfoListFormDTO(); | 
			
		
	
		
			
				
					|  |  |  |             formDTO.setUserIdList(userIdList); | 
			
		
	
		
			
				
					|  |  |  |             Result<List<UserResiInfoResultDTO>> userResiInfoDTOListResult = epmetUserFeignClient.getUserResiInfoList(formDTO); | 
			
		
	
		
			
				
					|  |  |  |             setUserInfo(userResiInfoDTOListResult, hiddenTopics); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new Result<List<ResiTopicInfoResultDTO>>().ok(hiddenTopics); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
	
		
			
				
					|  |  | @ -534,15 +575,18 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |         if(null != resiGroupMemberDTO){ | 
			
		
	
		
			
				
					|  |  |  |             if(MemberStateConstant.SILENT.equals(resiGroupMemberDTO.getStatus())){ | 
			
		
	
		
			
				
					|  |  |  |                 //当前用户被禁言
 | 
			
		
	
		
			
				
					|  |  |  |                 logger.error(ModuleConstant.SLIENT_MEMBER); | 
			
		
	
		
			
				
					|  |  |  |                 return new Result().error(ModuleConstant.SLIENT_MEMBER); | 
			
		
	
		
			
				
					|  |  |  |             }else if(MemberStateConstant.REMOVED.equals(resiGroupMemberDTO.getStatus())){ | 
			
		
	
		
			
				
					|  |  |  |                 //当前用户已被移出群
 | 
			
		
	
		
			
				
					|  |  |  |                 logger.error(ModuleConstant.REMOVED_MEMBER); | 
			
		
	
		
			
				
					|  |  |  |                 return new Result().error(ModuleConstant.REMOVED_MEMBER); | 
			
		
	
		
			
				
					|  |  |  |             }else{ | 
			
		
	
		
			
				
					|  |  |  |                 return new Result(); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         }else{ | 
			
		
	
		
			
				
					|  |  |  |             //当前用户非组内成员
 | 
			
		
	
		
			
				
					|  |  |  |             logger.error(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
	
		
			
				
					|  |  | @ -561,6 +605,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |                 //1.2判断是否是组长
 | 
			
		
	
		
			
				
					|  |  |  |                 if(!StringUtils.equals(leaderVerify.getCustomerUserId(),userId)){ | 
			
		
	
		
			
				
					|  |  |  |                     //非组长,无权限进行操作
 | 
			
		
	
		
			
				
					|  |  |  |                     logger.warn(ModuleConstant.NO_TEAMLEADER_AUTH); | 
			
		
	
		
			
				
					|  |  |  |                     return new Result().error(ModuleConstant.NO_TEAMLEADER_AUTH); | 
			
		
	
		
			
				
					|  |  |  |                 }else{ | 
			
		
	
		
			
				
					|  |  |  |                     //是组长
 | 
			
		
	
	
		
			
				
					|  |  | @ -568,14 +613,24 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             }else{ | 
			
		
	
		
			
				
					|  |  |  |                 //未找到当前用户的成员信息
 | 
			
		
	
		
			
				
					|  |  |  |                 logger.warn(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); | 
			
		
	
		
			
				
					|  |  |  |                 return new Result().error(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         }else{ | 
			
		
	
		
			
				
					|  |  |  |             //未能识别该话题基本信息
 | 
			
		
	
		
			
				
					|  |  |  |             logger.warn(ModuleConstant.NO_SUCH_TOPIC); | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(ModuleConstant.NO_SUCH_TOPIC); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description 将用户信息(头像、昵称)遍历到返回的查询话题结果中  TODO 后期要改到缓存中 | 
			
		
	
		
			
				
					|  |  |  |      * @Param Result<List<UserResiInfoResultDTO>> | 
			
		
	
		
			
				
					|  |  |  |      * @Param List<ResiTopicInfoResultDTO> | 
			
		
	
		
			
				
					|  |  |  |      * @return void | 
			
		
	
		
			
				
					|  |  |  |      * @Author wangc | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.04.10 17:47 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     public void setUserInfo(Result<List<UserResiInfoResultDTO>> userResiInfoDTOListResult,List<ResiTopicInfoResultDTO> topics){ | 
			
		
	
		
			
				
					|  |  |  |         if(userResiInfoDTOListResult.success() && null != userResiInfoDTOListResult.getData()){ | 
			
		
	
		
			
				
					|  |  |  |             if(userResiInfoDTOListResult.getData().size() > 0){ | 
			
		
	
	
		
			
				
					|  |  | @ -589,6 +644,8 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         }else{ | 
			
		
	
		
			
				
					|  |  |  |             logger.warn(ModuleConstant.USER_INFO_LIST_NOT_FOUND); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | 
 |