|
|
@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
@ -175,7 +176,8 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
@Override |
|
|
|
public Result createTopic(TokenDto tokenDto, ResiTopicPublishFormDTO resiTopicPublishFormDTO) { |
|
|
|
if (null == tokenDto) { |
|
|
|
return new Result().error(ModuleConstant.USER_NOT_NULL); |
|
|
|
logger.error(ModuleConstant.USER_NOT_NULL); |
|
|
|
throw new RenException(ModuleConstant.USER_NOT_NULL); |
|
|
|
} |
|
|
|
//1.身份校验,查看当前用户是否是组内成员,当前用户是否被禁言
|
|
|
|
|
|
|
@ -192,7 +194,8 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
//2.创建话题
|
|
|
|
if(resiTopicPublishFormDTO.getTopicContent().length() > TopicConstant.MAX_NUMBER_OF_CONTENT){ |
|
|
|
//内容超过最大限制
|
|
|
|
return new Result().error(ModuleConstant.TOPIC_CONTENT_NUMBER_OF_WORDS_EXCEEDED); |
|
|
|
logger.error(ModuleConstant.TOPIC_CONTENT_NUMBER_OF_WORDS_EXCEEDED); |
|
|
|
throw new RenException(ModuleConstant.TOPIC_CONTENT_NUMBER_OF_WORDS_EXCEEDED); |
|
|
|
} |
|
|
|
ResiTopicEntity topic = ConvertUtils.sourceToTarget(resiTopicPublishFormDTO,ResiTopicEntity.class); |
|
|
|
topic.setCreatedBy(tokenDto.getUserId()); |
|
|
@ -200,8 +203,8 @@ 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); |
|
|
|
logger.error(ModuleConstant.NO_PRIMARY_KEY_RETURNED); |
|
|
|
throw new RenException(ModuleConstant.NO_PRIMARY_KEY_RETURNED); |
|
|
|
} |
|
|
|
if(null != resiTopicPublishFormDTO.getAttachmentList() && resiTopicPublishFormDTO.getAttachmentList().size() > 0){ |
|
|
|
ResiTopicAttachmentEntity attachment = new ResiTopicAttachmentEntity(); |
|
|
@ -230,8 +233,8 @@ 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); |
|
|
|
logger.error(ModuleConstant.GROUP_STASTICAL_NOT_SINGLE); |
|
|
|
throw new RenException(ModuleConstant.GROUP_STASTICAL_NOT_SINGLE); |
|
|
|
}else{ |
|
|
|
ResiGroupStatisticalEntity statistical2Update = new ResiGroupStatisticalEntity(); |
|
|
|
statistical2Update.setId(statistical.get(NumConstant.ZERO).getId()); |
|
|
@ -241,8 +244,8 @@ 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); |
|
|
|
logger.error(ModuleConstant.NO_SUCH_GROUP_STASTICAL_INFO); |
|
|
|
throw new RenException(ModuleConstant.NO_SUCH_GROUP_STASTICAL_INFO); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -265,7 +268,8 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
@Override |
|
|
|
public Result<List<ResiTopicInfoResultDTO>> getLatestTopics(TokenDto tokenDto, String groupId) { |
|
|
|
if (null == tokenDto) { |
|
|
|
return new Result().error(ModuleConstant.USER_NOT_NULL); |
|
|
|
logger.error(ModuleConstant.USER_NOT_NULL); |
|
|
|
throw new RenException(ModuleConstant.USER_NOT_NULL); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(groupId)) { |
|
|
|
return new Result<List<ResiTopicInfoResultDTO>>().error(); |
|
|
@ -305,7 +309,8 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
@Override |
|
|
|
public Result<List<ResiTopicInfoResultDTO>> getPastTopicList(TokenDto tokenDto, ResiTopicPageFormDTO topicPageFormDTO) { |
|
|
|
if (null == tokenDto) { |
|
|
|
return new Result().error(ModuleConstant.USER_NOT_NULL); |
|
|
|
logger.error(ModuleConstant.USER_NOT_NULL); |
|
|
|
throw new RenException(ModuleConstant.USER_NOT_NULL); |
|
|
|
} |
|
|
|
|
|
|
|
//1.查询历史话题列表
|
|
|
@ -350,7 +355,8 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
@Override |
|
|
|
public Result hideTopic(TokenDto tokenDto, ResiTopicOperationFormDTO hiddenFormDTO) { |
|
|
|
if (null == tokenDto) { |
|
|
|
return new Result().error(ModuleConstant.USER_NOT_NULL); |
|
|
|
logger.error(ModuleConstant.USER_NOT_NULL); |
|
|
|
throw new RenException(ModuleConstant.USER_NOT_NULL); |
|
|
|
} |
|
|
|
|
|
|
|
//1.1拿到组Id
|
|
|
@ -405,7 +411,8 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
public Result cancelHiddenTopics(TokenDto tokenDto, List<String> topicIds) { |
|
|
|
|
|
|
|
if(null == topicIds || topicIds.size() <= 0){ |
|
|
|
return new Result().error(ModuleConstant.TOPIC_ID_LIST_NOT_NULL); |
|
|
|
logger.error(ModuleConstant.TOPIC_ID_LIST_NOT_NULL); |
|
|
|
throw new RenException(ModuleConstant.TOPIC_ID_LIST_NOT_NULL); |
|
|
|
} |
|
|
|
|
|
|
|
//1.1拿到组Id
|
|
|
@ -494,8 +501,8 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
//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); |
|
|
|
logger.error(ModuleConstant.NO_SUCH_TOPIC); |
|
|
|
throw new RenException(ModuleConstant.NO_SUCH_TOPIC); |
|
|
|
} |
|
|
|
ResiTopicDetailResultDTO resultDTO = new ResiTopicDetailResultDTO(); |
|
|
|
resultDTO.setTopicId(topicId); |
|
|
@ -615,18 +622,18 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
if(MemberStateConstant.SILENT.equals(resiGroupMemberDTO.getStatus())){ |
|
|
|
//当前用户被禁言
|
|
|
|
logger.error(ModuleConstant.SLIENT_MEMBER); |
|
|
|
return new Result().error(ModuleConstant.SLIENT_MEMBER); |
|
|
|
throw new RenException(ModuleConstant.SLIENT_MEMBER); |
|
|
|
}else if(MemberStateConstant.REMOVED.equals(resiGroupMemberDTO.getStatus())){ |
|
|
|
//当前用户已被移出群
|
|
|
|
logger.error(ModuleConstant.REMOVED_MEMBER); |
|
|
|
return new Result().error(ModuleConstant.REMOVED_MEMBER); |
|
|
|
throw new RenException(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); |
|
|
|
throw new RenException(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -644,21 +651,21 @@ 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); |
|
|
|
logger.error(ModuleConstant.NO_TEAMLEADER_AUTH); |
|
|
|
throw new RenException(ModuleConstant.NO_TEAMLEADER_AUTH); |
|
|
|
}else{ |
|
|
|
//是组长
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
//未找到当前用户的成员信息
|
|
|
|
logger.warn(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); |
|
|
|
return new Result().error(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); |
|
|
|
logger.error(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); |
|
|
|
throw new RenException(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
//未能识别该话题基本信息
|
|
|
|
logger.warn(ModuleConstant.NO_SUCH_TOPIC); |
|
|
|
return new Result().error(ModuleConstant.NO_SUCH_TOPIC); |
|
|
|
logger.error(ModuleConstant.NO_SUCH_TOPIC); |
|
|
|
throw new RenException(ModuleConstant.NO_SUCH_TOPIC); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|