|
|
|
@ -24,17 +24,30 @@ 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.modules.feign.EpmetUserFeignClient; |
|
|
|
import com.epmet.modules.group.dao.ResiGroupDao; |
|
|
|
import com.epmet.modules.group.entity.ResiGroupEntity; |
|
|
|
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; |
|
|
|
import com.epmet.modules.utils.ModuleConstant; |
|
|
|
import com.epmet.resi.group.constant.MemberStateConstant; |
|
|
|
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.ResiTopicPageFormDTO; |
|
|
|
import com.epmet.resi.group.dto.topic.form.ResiTopicPublishFormDTO; |
|
|
|
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; |
|
|
|
@ -56,6 +69,21 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
@Autowired |
|
|
|
private ResiGroupMemberService resiGroupMemberService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ResiTopicAttachmentDao resiTopicAttachmentDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ResiTopicOperationDao resiTopicOperationDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ResiTopicCommentDao resiTopicCommentDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
EpmetUserFeignClient epmetUserFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
ResiGroupDao resiGroupDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<ResiTopicDTO> page(Map<String, Object> params) { |
|
|
|
IPage<ResiTopicEntity> page = baseDao.selectPage( |
|
|
|
@ -126,14 +154,112 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
resiGroupMemberService.getResiGroupMember(tokenDto.getUserId() , resiTopicPublishFormDTO.getGroupId()); |
|
|
|
|
|
|
|
if(null != resiGroupMemberDTO){ |
|
|
|
if(!MemberStateConstant.APPROVED.equals(resiGroupMemberDTO.getStatus())){ |
|
|
|
//如果当前用户的状态不是已通过,说明是已禁言或被移除的状态
|
|
|
|
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(); |
|
|
|
} |
|
|
|
|
|
|
|
//2.创建话题
|
|
|
|
if(resiTopicPublishFormDTO.getTopicContent().length() > TopicConstant.MAX_NUMBER_OF_CONTENT){ |
|
|
|
//内容超过最大限制
|
|
|
|
return new Result().error(); |
|
|
|
} |
|
|
|
ResiTopicEntity topic = ConvertUtils.sourceToTarget(resiTopicPublishFormDTO,ResiTopicEntity.class); |
|
|
|
topic.setCreatedBy(tokenDto.getUserId()); |
|
|
|
baseDao.insert(topic); |
|
|
|
if(StringUtils.isBlank(topic.getId())){ |
|
|
|
//没有返回主键
|
|
|
|
return new Result().error(); |
|
|
|
} |
|
|
|
if(null != resiTopicPublishFormDTO.getAttachmentList() && resiTopicPublishFormDTO.getAttachmentList().size() > 0){ |
|
|
|
ResiTopicAttachmentEntity attachment = new ResiTopicAttachmentEntity(); |
|
|
|
for(String url : resiTopicPublishFormDTO.getAttachmentList()){ |
|
|
|
attachment.setAttachmentUrl(url); |
|
|
|
attachment.setTopicId(topic.getId()); |
|
|
|
attachment.setCreatedBy(tokenDto.getUnionId()); |
|
|
|
resiTopicAttachmentDao.insert(attachment); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//3.话题操作记录
|
|
|
|
ResiTopicOperationEntity operation = new ResiTopicOperationEntity(); |
|
|
|
operation.setTopicId(topic.getId()); |
|
|
|
operation.setOperationType(TopicConstant.PUBLISHMENT); |
|
|
|
resiTopicOperationDao.insert(operation); |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 评论话题 |
|
|
|
* @Param tokenDto |
|
|
|
* @Param resiCommentFormDTO |
|
|
|
* @return Result |
|
|
|
* @Author wangc |
|
|
|
* @Date 2020.03.31 17:36 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public Result commentTopic(TokenDto tokenDto, ResiCommentFormDTO resiCommentFormDTO) { |
|
|
|
|
|
|
|
//1.判断当前用户是否被禁言
|
|
|
|
ResiTopicDTO topic = get(resiCommentFormDTO.getTopicId()); |
|
|
|
if(null == topic){ |
|
|
|
|
|
|
|
return new Result().error(); |
|
|
|
} |
|
|
|
|
|
|
|
ResiGroupMemberDTO resiGroupMemberDTO = |
|
|
|
resiGroupMemberService.getResiGroupMember(tokenDto.getUserId() , topic.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(); |
|
|
|
} |
|
|
|
|
|
|
|
if(resiCommentFormDTO.getCommentContent().length() > TopicConstant.MAX_NUMBER_OF_COMMENT){ |
|
|
|
|
|
|
|
return new Result().error(); |
|
|
|
} |
|
|
|
ResiTopicCommentEntity comment = ConvertUtils.sourceToTarget(resiCommentFormDTO,ResiTopicCommentEntity.class); |
|
|
|
comment.setStatus(TopicConstant.PUBLISHMENT); |
|
|
|
resiTopicCommentDao.insert(comment); |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @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) { |
|
|
|
|
|
|
|
//1.查询话题列表
|
|
|
|
List<ResiTopicInfoResultDTO> lastestTenTopics = |
|
|
|
baseDao.getLatestTenTopics(groupId); |
|
|
|
|
|
|
|
//2.遍历放用户信息与网格信息
|
|
|
|
ResiGroupEntity group = resiGroupDao.selectById(groupId); |
|
|
|
if(null != group && ModuleConstant.DEL_FLAG.equals(group.getDelFlag())){ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -141,4 +267,11 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<List<ResiTopicInfoResultDTO>> getPastTopicList(TokenDto tokenDto, ResiTopicPageFormDTO topicPageFormDTO) { |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |