|  |  | @ -20,21 +20,24 @@ 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; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.page.PageData; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.security.dto.TokenDto; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.ConvertUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.FieldConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.Result; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.UserResiInfoDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.UserResiInfoFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.feign.EpmetUserFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.group.dao.ResiGroupDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.group.entity.ResiGroupEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.member.dao.ResiGroupMemberDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.member.service.ResiGroupMemberService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.topic.dao.ResiTopicAttachmentDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.topic.dao.ResiTopicCommentDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.topic.dao.ResiTopicDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.topic.dao.ResiTopicOperationDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.topic.entity.ResiTopicAttachmentEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.topic.entity.ResiTopicCommentEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.topic.entity.ResiTopicEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.topic.entity.ResiTopicOperationEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.modules.topic.service.ResiTopicService; | 
			
		
	
	
		
			
				
					|  |  | @ -44,15 +47,18 @@ import com.epmet.resi.group.constant.TopicConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.topic.ResiTopicDTO; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.resi.group.dto.topic.form.ResiCommentFormDTO; | 
			
		
	
		
			
				
					|  |  |  | 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.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import java.text.SimpleDateFormat; | 
			
		
	
		
			
				
					|  |  |  | import java.util.ArrayList; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Arrays; | 
			
		
	
		
			
				
					|  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Map; | 
			
		
	
	
		
			
				
					|  |  | @ -84,6 +90,9 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     ResiGroupDao resiGroupDao; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     ResiGroupMemberDao resiGroupMemberDao; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public PageData<ResiTopicDTO> page(Map<String, Object> params) { | 
			
		
	
		
			
				
					|  |  |  |         IPage<ResiTopicEntity> page = baseDao.selectPage( | 
			
		
	
	
		
			
				
					|  |  | @ -153,17 +162,9 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |         ResiGroupMemberDTO resiGroupMemberDTO = | 
			
		
	
		
			
				
					|  |  |  |         resiGroupMemberService.getResiGroupMember(tokenDto.getUserId() , resiTopicPublishFormDTO.getGroupId()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if(null != resiGroupMemberDTO){ | 
			
		
	
		
			
				
					|  |  |  |             if(MemberStateConstant.SILENT.equals(resiGroupMemberDTO.getStatus())){ | 
			
		
	
		
			
				
					|  |  |  |                 //当前用户被禁言
 | 
			
		
	
		
			
				
					|  |  |  |                 return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |             }else if(MemberStateConstant.REMOVED.equals(resiGroupMemberDTO.getStatus())){ | 
			
		
	
		
			
				
					|  |  |  |                 //当前用户已被移出群
 | 
			
		
	
		
			
				
					|  |  |  |                 return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         }else{ | 
			
		
	
		
			
				
					|  |  |  |             //当前用户非组内成员
 | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |         Result result = verifySilentOrRemoved(resiGroupMemberDTO); | 
			
		
	
		
			
				
					|  |  |  |         if(!result.success()){ | 
			
		
	
		
			
				
					|  |  |  |             return result; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //2.创建话题
 | 
			
		
	
	
		
			
				
					|  |  | @ -173,7 +174,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicEntity topic = ConvertUtils.sourceToTarget(resiTopicPublishFormDTO,ResiTopicEntity.class); | 
			
		
	
		
			
				
					|  |  |  |         topic.setCreatedBy(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         baseDao.insert(topic); | 
			
		
	
		
			
				
					|  |  |  |         baseDao.insertOne(topic); | 
			
		
	
		
			
				
					|  |  |  |         if(StringUtils.isBlank(topic.getId())){ | 
			
		
	
		
			
				
					|  |  |  |             //没有返回主键
 | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(); | 
			
		
	
	
		
			
				
					|  |  | @ -184,7 +185,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |                 attachment.setAttachmentUrl(url); | 
			
		
	
		
			
				
					|  |  |  |                 attachment.setTopicId(topic.getId()); | 
			
		
	
		
			
				
					|  |  |  |                 attachment.setCreatedBy(tokenDto.getUnionId()); | 
			
		
	
		
			
				
					|  |  |  |                 resiTopicAttachmentDao.insert(attachment); | 
			
		
	
		
			
				
					|  |  |  |                 resiTopicAttachmentDao.insertOne(attachment); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -192,101 +193,301 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicOperationEntity operation = new ResiTopicOperationEntity(); | 
			
		
	
		
			
				
					|  |  |  |         operation.setTopicId(topic.getId()); | 
			
		
	
		
			
				
					|  |  |  |         operation.setOperationType(TopicConstant.PUBLISHMENT); | 
			
		
	
		
			
				
					|  |  |  |         resiTopicOperationDao.insert(operation); | 
			
		
	
		
			
				
					|  |  |  |         resiTopicOperationDao.insertOne(operation); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new Result(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description 评论话题 | 
			
		
	
		
			
				
					|  |  |  |      * @Description 查看组内最近十条话题 | 
			
		
	
		
			
				
					|  |  |  |      * @Param tokenDto | 
			
		
	
		
			
				
					|  |  |  |      * @Param groupId | 
			
		
	
		
			
				
					|  |  |  |      * @return Result<List<ResiTopicInfoResultDTO>> | 
			
		
	
		
			
				
					|  |  |  |      * @Author wangc | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.04.01 08:59 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Result<List<ResiTopicInfoResultDTO>> getLatestTenTopics(TokenDto tokenDto, String groupId) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if(StringUtils.isBlank(groupId)){ | 
			
		
	
		
			
				
					|  |  |  |             return new Result<List<ResiTopicInfoResultDTO>>().error(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //1.查询话题列表
 | 
			
		
	
		
			
				
					|  |  |  |         List<ResiTopicInfoResultDTO> lastestTenTopics = | 
			
		
	
		
			
				
					|  |  |  |                 baseDao.getLatestTenTopics(groupId,tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //2.遍历存储用户信息
 | 
			
		
	
		
			
				
					|  |  |  |         ResiGroupEntity group = resiGroupDao.selectById(groupId); | 
			
		
	
		
			
				
					|  |  |  |         if(null != group && ModuleConstant.DEL_FLAG.equals(group.getDelFlag())){ | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new Result<List<ResiTopicInfoResultDTO>>().ok(lastestTenTopics); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description 查看历史话题(分页,允许状态筛选) | 
			
		
	
		
			
				
					|  |  |  |      * @Param tokenDto | 
			
		
	
		
			
				
					|  |  |  |      * @Param resiCommentFormDTO | 
			
		
	
		
			
				
					|  |  |  |      * @Param ResiTopicPageFormDTO.class | 
			
		
	
		
			
				
					|  |  |  |      * @return Result<List<ResiTopicInfoResultDTO>> | 
			
		
	
		
			
				
					|  |  |  |      * @Author wangc | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.04.01 10:36 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Result<List<ResiTopicInfoResultDTO>> getPastTopicList(TokenDto tokenDto, ResiTopicPageFormDTO topicPageFormDTO) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //1.查询历史话题列表
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         topicPageFormDTO.setUserId(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         topicPageFormDTO.setPageNo((topicPageFormDTO.getPageNo() - NumConstant.ONE) * topicPageFormDTO.getPageSize()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         List<ResiTopicInfoResultDTO> pastTopics = | 
			
		
	
		
			
				
					|  |  |  |                 baseDao.getPastTopics(topicPageFormDTO); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //2.遍历用户信息
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new Result<List<ResiTopicInfoResultDTO>>().ok(pastTopics); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description 屏蔽话题 | 
			
		
	
		
			
				
					|  |  |  |      * @Param tokenDto | 
			
		
	
		
			
				
					|  |  |  |      * @Param ResiTopicHiddenFormDTO.class | 
			
		
	
		
			
				
					|  |  |  |      * @return Result | 
			
		
	
		
			
				
					|  |  |  |      * @Author wangc | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.03.31 17:36 | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.04.01 12:38 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Result commentTopic(TokenDto tokenDto, ResiCommentFormDTO resiCommentFormDTO) { | 
			
		
	
		
			
				
					|  |  |  |     public Result hideTopic(TokenDto tokenDto, ResiTopicOperationFormDTO hiddenFormDTO) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //1.判断当前用户是否被禁言
 | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicDTO topic = get(resiCommentFormDTO.getTopicId()); | 
			
		
	
		
			
				
					|  |  |  |         if(null == topic){ | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |         //1.1拿到组Id
 | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicEntity topic = baseDao.selectById(hiddenFormDTO.getTopicId()); | 
			
		
	
		
			
				
					|  |  |  |         //1.2校验身份,是否是该话题所属群组的组长
 | 
			
		
	
		
			
				
					|  |  |  |         Result verifyError = verifyLeader(topic,tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         if(!verifyError.success()) { | 
			
		
	
		
			
				
					|  |  |  |             return verifyError; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         ResiGroupMemberDTO resiGroupMemberDTO = | 
			
		
	
		
			
				
					|  |  |  |                 resiGroupMemberService.getResiGroupMember(tokenDto.getUserId() , topic.getGroupId()); | 
			
		
	
		
			
				
					|  |  |  |         //2.屏蔽话题
 | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicEntity topicForUpdate = new ResiTopicEntity(); | 
			
		
	
		
			
				
					|  |  |  |         topicForUpdate.setId(hiddenFormDTO.getTopicId()); | 
			
		
	
		
			
				
					|  |  |  |         topicForUpdate.setUpdatedBy(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         topicForUpdate.setStatus(TopicConstant.HIDDEN); | 
			
		
	
		
			
				
					|  |  |  |         baseDao.update(topicForUpdate); | 
			
		
	
		
			
				
					|  |  |  |         //3.话题操作记录
 | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicOperationEntity operationRecord = new ResiTopicOperationEntity(); | 
			
		
	
		
			
				
					|  |  |  |         operationRecord.setTopicId(hiddenFormDTO.getTopicId()); | 
			
		
	
		
			
				
					|  |  |  |         operationRecord.setOperationReason(hiddenFormDTO.getOperateReason()); | 
			
		
	
		
			
				
					|  |  |  |         operationRecord.setOperationType(TopicConstant.HIDDEN); | 
			
		
	
		
			
				
					|  |  |  |         operationRecord.setCreatedBy(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         resiTopicOperationDao.insertOne(operationRecord); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if(null != resiGroupMemberDTO){ | 
			
		
	
		
			
				
					|  |  |  |             if(MemberStateConstant.SILENT.equals(resiGroupMemberDTO.getStatus())){ | 
			
		
	
		
			
				
					|  |  |  |                 //当前用户被禁言
 | 
			
		
	
		
			
				
					|  |  |  |                 return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |             }else if(MemberStateConstant.REMOVED.equals(resiGroupMemberDTO.getStatus())){ | 
			
		
	
		
			
				
					|  |  |  |                 //当前用户已被移出群
 | 
			
		
	
		
			
				
					|  |  |  |                 return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         }else{ | 
			
		
	
		
			
				
					|  |  |  |             //当前用户非组内成员
 | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |         return new Result(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description 批量取消屏蔽 | 
			
		
	
		
			
				
					|  |  |  |      * @Param tokenDto | 
			
		
	
		
			
				
					|  |  |  |      * @Param topicIds | 
			
		
	
		
			
				
					|  |  |  |      * @return Result | 
			
		
	
		
			
				
					|  |  |  |      * @Author wangc | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.04.01 14:17 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Result cancelHiddenTopics(TokenDto tokenDto, List<String> topicIds) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //1.1拿到组Id
 | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicEntity topic = baseDao.selectById(topicIds.get(0)); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //1.2校验身份,是否是该话题所属群组的组长
 | 
			
		
	
		
			
				
					|  |  |  |         Result verifyError = verifyLeader(topic,tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         if(!verifyError.success()) { | 
			
		
	
		
			
				
					|  |  |  |             return verifyError; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if(resiCommentFormDTO.getCommentContent().length() > TopicConstant.MAX_NUMBER_OF_COMMENT){ | 
			
		
	
		
			
				
					|  |  |  |         //2.批量取消屏蔽
 | 
			
		
	
		
			
				
					|  |  |  |         baseDao.cancelHiddenOrCloseBatch(topicIds,tokenDto.getUserId(),TopicConstant.PUBLISHMENT); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |         //3.记录话题操作日志
 | 
			
		
	
		
			
				
					|  |  |  |         for(String id : topicIds){ | 
			
		
	
		
			
				
					|  |  |  |             ResiTopicOperationEntity operation = new ResiTopicOperationEntity(); | 
			
		
	
		
			
				
					|  |  |  |             operation.setTopicId(id); | 
			
		
	
		
			
				
					|  |  |  |             operation.setOperationType(TopicConstant.CANCEL_HIDDEN); | 
			
		
	
		
			
				
					|  |  |  |             operation.setCreatedBy(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |             resiTopicOperationDao.insertOne(operation); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicCommentEntity comment = ConvertUtils.sourceToTarget(resiCommentFormDTO,ResiTopicCommentEntity.class); | 
			
		
	
		
			
				
					|  |  |  |         comment.setStatus(TopicConstant.PUBLISHMENT); | 
			
		
	
		
			
				
					|  |  |  |         resiTopicCommentDao.insert(comment); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new Result(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description 查看组内最近十条话题 | 
			
		
	
		
			
				
					|  |  |  |      * @Description 关闭话题 | 
			
		
	
		
			
				
					|  |  |  |      * @Param tokenDto | 
			
		
	
		
			
				
					|  |  |  |      * @Param groupId | 
			
		
	
		
			
				
					|  |  |  |      * @return Result<List<ResiTopicInfoResultDTO>> | 
			
		
	
		
			
				
					|  |  |  |      * @Param ResiTopicOperationFormDTO.class | 
			
		
	
		
			
				
					|  |  |  |      * @return Result.class | 
			
		
	
		
			
				
					|  |  |  |      * @Author wangc | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.04.01 08:59 | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.04.01 15:37 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Result<List<ResiTopicInfoResultDTO>> getLatestTenTopics(TokenDto tokenDto, String groupId) { | 
			
		
	
		
			
				
					|  |  |  |     public Result closeTopic(TokenDto tokenDto, ResiTopicOperationFormDTO closeFormDTO) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //1.查询话题列表
 | 
			
		
	
		
			
				
					|  |  |  |         List<ResiTopicInfoResultDTO> lastestTenTopics = | 
			
		
	
		
			
				
					|  |  |  |                 baseDao.getLatestTenTopics(groupId); | 
			
		
	
		
			
				
					|  |  |  |         //1.1拿到组Id
 | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicEntity topic = baseDao.selectById(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //2.遍历放用户信息
 | 
			
		
	
		
			
				
					|  |  |  |         ResiGroupEntity group = resiGroupDao.selectById(groupId); | 
			
		
	
		
			
				
					|  |  |  |         if(null != group && ModuleConstant.DEL_FLAG.equals(group.getDelFlag())){ | 
			
		
	
		
			
				
					|  |  |  |         //1.2校验身份,是否是该话题所属群组的组长
 | 
			
		
	
		
			
				
					|  |  |  |         Result verifyError = verifyLeader(topic,tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         if(!verifyError.success()) { | 
			
		
	
		
			
				
					|  |  |  |             return verifyError; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //2.关闭操作
 | 
			
		
	
		
			
				
					|  |  |  |         List<String> id = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |         id.add(closeFormDTO.getTopicId()); | 
			
		
	
		
			
				
					|  |  |  |         baseDao.cancelHiddenOrCloseBatch(id,tokenDto.getUserId(),TopicConstant.CLOSED); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //3.记录话题操作日志
 | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicOperationEntity operation = new ResiTopicOperationEntity(); | 
			
		
	
		
			
				
					|  |  |  |         operation.setTopicId(id.get(0)); | 
			
		
	
		
			
				
					|  |  |  |         operation.setOperationReason(closeFormDTO.getOperateReason()); | 
			
		
	
		
			
				
					|  |  |  |         operation.setCreatedBy(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         operation.setOperationType(TopicConstant.CLOSED); | 
			
		
	
		
			
				
					|  |  |  |         resiTopicOperationDao.insertOne(operation); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new Result(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description 查看话题详情 | 
			
		
	
		
			
				
					|  |  |  |      * @Param tokenDto | 
			
		
	
		
			
				
					|  |  |  |      * @Param topicId | 
			
		
	
		
			
				
					|  |  |  |      * @return ResiTopicDetailResultDTO | 
			
		
	
		
			
				
					|  |  |  |      * @Author wangc | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.04.01 15:56 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Result<ResiTopicDetailResultDTO> getTopicDetail(TokenDto tokenDto, String topicId) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if(StringUtils.isBlank(topicId)){ | 
			
		
	
		
			
				
					|  |  |  |             return new Result<ResiTopicDetailResultDTO>().error(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         for(ResiTopicInfoResultDTO obj:lastestTenTopics){ | 
			
		
	
		
			
				
					|  |  |  |             if(StringUtils.equals(tokenDto.getUserId(),obj.getUserId())){ | 
			
		
	
		
			
				
					|  |  |  |                 obj.setReleaseUserFlag(TopicConstant.PUBLISHED_BY_MYSELF); | 
			
		
	
		
			
				
					|  |  |  |             }else{ | 
			
		
	
		
			
				
					|  |  |  |                 obj.setReleaseUserFlag(TopicConstant.PUBLISHED_BY_OTHER); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         //1.获取话题基本信息
 | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicEntity topicDetail = baseDao.selectById(topicId); | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicDetailResultDTO resultDTO = new ResiTopicDetailResultDTO(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //2.查询话题附件
 | 
			
		
	
		
			
				
					|  |  |  |         QueryWrapper<ResiTopicAttachmentEntity> wrapper = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |         wrapper.eq(TopicConstant.TOPIC_ID,topicId); | 
			
		
	
		
			
				
					|  |  |  |         wrapper.eq(TopicConstant.DEL_FLAG,NumConstant.ZERO_STR); | 
			
		
	
		
			
				
					|  |  |  |         wrapper.orderByDesc(TopicConstant.CREATED_DATE); | 
			
		
	
		
			
				
					|  |  |  |         List<ResiTopicAttachmentEntity> attachments = resiTopicAttachmentDao.selectList(wrapper); | 
			
		
	
		
			
				
					|  |  |  |         List<String> attachmentUrls = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |         for(ResiTopicAttachmentEntity attachment : attachments){ | 
			
		
	
		
			
				
					|  |  |  |             attachmentUrls.add(attachment.getAttachmentUrl()); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new Result<List<ResiTopicInfoResultDTO>>().ok(lastestTenTopics); | 
			
		
	
		
			
				
					|  |  |  |         resultDTO.setTopicImgs(attachmentUrls); | 
			
		
	
		
			
				
					|  |  |  |         resultDTO.setReleaseTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(topicDetail.getCreatedTime())); | 
			
		
	
		
			
				
					|  |  |  |         resultDTO.setTopicContent(topicDetail.getTopicContent()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //3.拿取用户信息
 | 
			
		
	
		
			
				
					|  |  |  |         ResiTopicDTO topic = get(topicId); | 
			
		
	
		
			
				
					|  |  |  |         ResiGroupEntity group = resiGroupDao.selectById(topic.getGroupId()); | 
			
		
	
		
			
				
					|  |  |  |         UserResiInfoFormDTO userParam = new UserResiInfoFormDTO(); | 
			
		
	
		
			
				
					|  |  |  |         userParam.setUserId(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         userParam.setCustomerId(group.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |         Result<UserResiInfoDTO> userInfo = | 
			
		
	
		
			
				
					|  |  |  |         epmetUserFeignClient.getUserResiInfoDTO(userParam); | 
			
		
	
		
			
				
					|  |  |  |         if(userInfo.success()){ | 
			
		
	
		
			
				
					|  |  |  |             resultDTO.setReleaseUserName(userInfo.getData().getSurname() + userInfo.getData().getName()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             //TODO 调用EpmetUserFeign的查询用户微信信息的方法拉取头像信息
 | 
			
		
	
		
			
				
					|  |  |  |             resultDTO.setReleaseUserHeadPhoto(""); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new Result<ResiTopicDetailResultDTO>().ok(resultDTO); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description 查看历史话题(分页,允许状态筛选) | 
			
		
	
		
			
				
					|  |  |  |      * @Description 屏蔽话题列表查询 | 
			
		
	
		
			
				
					|  |  |  |      * @Param tokenDto | 
			
		
	
		
			
				
					|  |  |  |      * @Param ResiTopicPageFormDTO.class | 
			
		
	
		
			
				
					|  |  |  |      * @return Result<List<ResiTopicInfoResultDTO>> | 
			
		
	
		
			
				
					|  |  |  |      * @return List<ResiTopicInfoResultDTO> | 
			
		
	
		
			
				
					|  |  |  |      * @Author wangc | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.04.01 10:36 | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.04.01 16:45 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Result<List<ResiTopicInfoResultDTO>> getPastTopicList(TokenDto tokenDto, ResiTopicPageFormDTO topicPageFormDTO) { | 
			
		
	
		
			
				
					|  |  |  |     public Result<List<ResiTopicInfoResultDTO>> getHiddenTopics(TokenDto tokenDto, ResiTopicPageFormDTO topicPageFormDTO) { | 
			
		
	
		
			
				
					|  |  |  |         //1.查询屏蔽话题列表
 | 
			
		
	
		
			
				
					|  |  |  |         topicPageFormDTO.setUserId(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         topicPageFormDTO.setPageNo((topicPageFormDTO.getPageNo() - NumConstant.ONE) * topicPageFormDTO.getPageSize()); | 
			
		
	
		
			
				
					|  |  |  |         topicPageFormDTO.setStatus(TopicConstant.HIDDEN); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         List<ResiTopicInfoResultDTO> hiddenTopics = | 
			
		
	
		
			
				
					|  |  |  |                 baseDao.getPastTopics(topicPageFormDTO); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //2.遍历用户信息
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return null; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new Result<List<ResiTopicInfoResultDTO>>().ok(hiddenTopics); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description 查询当前组员在组内是否被禁言或已被移除 | 
			
		
	
		
			
				
					|  |  |  |      * @Param resiGroupMemberDTO | 
			
		
	
		
			
				
					|  |  |  |      * @return Result.class | 
			
		
	
		
			
				
					|  |  |  |      * @Author wangc | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.04.01 15:00 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     private Result verifySilentOrRemoved(ResiGroupMemberDTO resiGroupMemberDTO){ | 
			
		
	
		
			
				
					|  |  |  |         if(null != resiGroupMemberDTO){ | 
			
		
	
		
			
				
					|  |  |  |             if(MemberStateConstant.SILENT.equals(resiGroupMemberDTO.getStatus())){ | 
			
		
	
		
			
				
					|  |  |  |                 //当前用户被禁言
 | 
			
		
	
		
			
				
					|  |  |  |                 return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |             }else if(MemberStateConstant.REMOVED.equals(resiGroupMemberDTO.getStatus())){ | 
			
		
	
		
			
				
					|  |  |  |                 //当前用户已被移出群
 | 
			
		
	
		
			
				
					|  |  |  |                 return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |             }else{ | 
			
		
	
		
			
				
					|  |  |  |                 return new Result(); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         }else{ | 
			
		
	
		
			
				
					|  |  |  |             //当前用户非组内成员
 | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description 校验当前用户是否是该小组组长 | 
			
		
	
		
			
				
					|  |  |  |      * @Param | 
			
		
	
		
			
				
					|  |  |  |      * @return | 
			
		
	
		
			
				
					|  |  |  |      * @Author wangc | 
			
		
	
		
			
				
					|  |  |  |      * @Date 2020.04.01 14:55 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     private Result verifyLeader(ResiTopicEntity topic,String userId){ | 
			
		
	
		
			
				
					|  |  |  |         if(null != topic){ | 
			
		
	
		
			
				
					|  |  |  |             ResiGroupMemberDTO leaderVerify = resiGroupMemberDao.selectLeaderMember(topic.getGroupId()); | 
			
		
	
		
			
				
					|  |  |  |             if(null != leaderVerify){ | 
			
		
	
		
			
				
					|  |  |  |                 //1.2判断是否是组长
 | 
			
		
	
		
			
				
					|  |  |  |                 if(!StringUtils.equals(leaderVerify.getId(),userId)){ | 
			
		
	
		
			
				
					|  |  |  |                     //非组长,无权限进行操作
 | 
			
		
	
		
			
				
					|  |  |  |                     return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |                 }else{ | 
			
		
	
		
			
				
					|  |  |  |                     return new Result(); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             }else{ | 
			
		
	
		
			
				
					|  |  |  |                 return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         }else{ | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | } |