|
@ -22,27 +22,69 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
|
|
import com.epmet.commons.tools.scan.param.ImgScanParamDTO; |
|
|
|
|
|
import com.epmet.commons.tools.scan.param.ImgTaskDTO; |
|
|
|
|
|
import com.epmet.commons.tools.scan.param.TextScanParamDTO; |
|
|
|
|
|
import com.epmet.commons.tools.scan.param.TextTaskDTO; |
|
|
|
|
|
import com.epmet.commons.tools.scan.result.SyncScanResult; |
|
|
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
|
|
import com.epmet.commons.tools.utils.ScanContentUtils; |
|
|
import com.epmet.dto.result.AllGridsByUserIdResultDTO; |
|
|
import com.epmet.dto.result.AllGridsByUserIdResultDTO; |
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
|
|
import com.epmet.modules.feign.EpmetUserFeignClient; |
|
|
|
|
|
import com.epmet.modules.group.dao.ResiGroupDao; |
|
|
|
|
|
import com.epmet.modules.group.dao.ResiGroupStatisticalDao; |
|
|
|
|
|
import com.epmet.modules.group.entity.ResiGroupEntity; |
|
|
|
|
|
import com.epmet.modules.group.entity.ResiGroupStatisticalEntity; |
|
|
|
|
|
import com.epmet.modules.group.redis.ResiGroupRedis; |
|
|
|
|
|
import com.epmet.modules.member.dao.ResiGroupMemberDao; |
|
|
|
|
|
import com.epmet.modules.member.redis.ResiGroupMemberRedis; |
|
|
|
|
|
import com.epmet.modules.member.service.ResiGroupMemberService; |
|
|
|
|
|
import com.epmet.modules.topic.dao.ResiTopicAttachmentDao; |
|
|
|
|
|
import com.epmet.modules.topic.dao.ResiTopicDao; |
|
|
|
|
|
import com.epmet.modules.topic.dao.ResiTopicOperationDao; |
|
|
import com.epmet.modules.topic.dao.TopicDraftDao; |
|
|
import com.epmet.modules.topic.dao.TopicDraftDao; |
|
|
|
|
|
import com.epmet.modules.topic.entity.ResiTopicAttachmentEntity; |
|
|
|
|
|
import com.epmet.modules.topic.entity.ResiTopicEntity; |
|
|
|
|
|
import com.epmet.modules.topic.entity.ResiTopicOperationEntity; |
|
|
import com.epmet.modules.topic.entity.TopicDraftEntity; |
|
|
import com.epmet.modules.topic.entity.TopicDraftEntity; |
|
|
|
|
|
import com.epmet.modules.topic.service.TopicDraftAttachmentService; |
|
|
|
|
|
import com.epmet.modules.topic.service.TopicDraftOperationService; |
|
|
import com.epmet.modules.topic.service.TopicDraftService; |
|
|
import com.epmet.modules.topic.service.TopicDraftService; |
|
|
|
|
|
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.group.ResiGroupInfoRedisDTO; |
|
|
|
|
|
import com.epmet.resi.group.dto.group.ResiGroupStatisticalInfoRedisDTO; |
|
|
|
|
|
import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; |
|
|
|
|
|
import com.epmet.resi.group.dto.member.ResiGroupMemberInfoRedisDTO; |
|
|
|
|
|
import com.epmet.resi.group.dto.topic.TopicDraftAttachmentDTO; |
|
|
import com.epmet.resi.group.dto.topic.TopicDraftDTO; |
|
|
import com.epmet.resi.group.dto.topic.TopicDraftDTO; |
|
|
import com.epmet.resi.group.dto.topic.form.MyAuditingListFormDTO; |
|
|
import com.epmet.resi.group.dto.topic.TopicDraftOperationDTO; |
|
|
|
|
|
import com.epmet.resi.group.dto.topic.form.*; |
|
|
|
|
|
import com.epmet.resi.group.dto.topic.result.DraftDetailResultDTO; |
|
|
import com.epmet.resi.group.dto.topic.result.MyAuditingListResultDTO; |
|
|
import com.epmet.resi.group.dto.topic.result.MyAuditingListResultDTO; |
|
|
import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; |
|
|
import com.epmet.resi.group.dto.topic.result.TopicAuditResultDTO; |
|
|
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.concurrent.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -52,12 +94,54 @@ import java.util.stream.Collectors; |
|
|
* @since v1.0.0 2020-12-17 |
|
|
* @since v1.0.0 2020-12-17 |
|
|
*/ |
|
|
*/ |
|
|
@Service |
|
|
@Service |
|
|
|
|
|
@Slf4j |
|
|
public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicDraftEntity> implements TopicDraftService { |
|
|
public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicDraftEntity> implements TopicDraftService { |
|
|
private static Logger logger = LoggerFactory.getLogger(TopicDraftServiceImpl.class); |
|
|
private static Logger logger = LoggerFactory.getLogger(TopicDraftServiceImpl.class); |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ResiGroupMemberService resiGroupMemberService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ResiTopicAttachmentDao resiTopicAttachmentDao; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ResiTopicOperationDao resiTopicOperationDao; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private EpmetUserFeignClient epmetUserFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ResiGroupDao resiGroupDao; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ResiGroupMemberDao resiGroupMemberDao; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ResiGroupStatisticalDao resiGroupStatisticalDao; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ResiTopicDao resiTopicDao; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ResiGroupRedis resiGroupRedis; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private TopicDraftAttachmentService topicDraftAttachmentService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private TopicDraftOperationService topicDraftOperationService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ResiGroupMemberRedis resiGroupMemberRedis; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${openapi.scan.server.url}") |
|
|
|
|
|
private String scanApiUrl; |
|
|
|
|
|
@Value("${openapi.scan.method.textSyncScan}") |
|
|
|
|
|
private String textSyncScanMethod; |
|
|
|
|
|
@Value("${openapi.scan.method.imgSyncScan}") |
|
|
|
|
|
private String imgSyncScanMethod; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<TopicDraftDTO> page(Map<String, Object> params) { |
|
|
public PageData<TopicDraftDTO> page(Map<String, Object> params) { |
|
|
IPage<TopicDraftEntity> page = baseDao.selectPage( |
|
|
IPage<TopicDraftEntity> page = baseDao.selectPage( |
|
@ -142,4 +226,414 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
return list; |
|
|
return list; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 发布话题 |
|
|
|
|
|
* |
|
|
|
|
|
* @param tokenDto |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @return void |
|
|
|
|
|
* @author zhaoqifeng |
|
|
|
|
|
* @date 2020/12/17 15:49 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void createTopic(TokenDto tokenDto, CreateTopicFormDTO formDTO) { |
|
|
|
|
|
if(StringUtils.isEmpty(formDTO.getTopicContent()) && CollectionUtils.isEmpty(formDTO.getVideoList())) { |
|
|
|
|
|
//话题内容和语音不能同时为空
|
|
|
|
|
|
log.error(ModuleConstant.TOPIC_CONTENT_AND_VOICE_IS_NULL); |
|
|
|
|
|
throw new RenException(ModuleConstant.TOPIC_CONTENT_AND_VOICE_IS_NULL); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//1.保存话题草稿
|
|
|
|
|
|
if(formDTO.getTopicContent().length() > TopicConstant.MAX_NUMBER_OF_CONTENT){ |
|
|
|
|
|
//内容超过最大限制
|
|
|
|
|
|
log.error(ModuleConstant.TOPIC_CONTENT_NUMBER_OF_WORDS_EXCEEDED); |
|
|
|
|
|
throw new RenException(ModuleConstant.TOPIC_CONTENT_NUMBER_OF_WORDS_EXCEEDED); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TopicDraftEntity topic = ConvertUtils.sourceToTarget(formDTO,TopicDraftEntity.class); |
|
|
|
|
|
topic.setCreatedBy(tokenDto.getUserId()); |
|
|
|
|
|
topic.setDraftStatus(TopicConstant.AUDITING); |
|
|
|
|
|
baseDao.insert(topic); |
|
|
|
|
|
if (StringUtils.isNotEmpty(formDTO.getTopicDraftId())) { |
|
|
|
|
|
//隐藏旧话题草稿
|
|
|
|
|
|
TopicDraftEntity old = new TopicDraftEntity(); |
|
|
|
|
|
old.setId(formDTO.getTopicDraftId()); |
|
|
|
|
|
old.setIsSee(NumConstant.ONE_STR); |
|
|
|
|
|
baseDao.updateById(old); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(formDTO.getImageList())){ |
|
|
|
|
|
TopicDraftAttachmentDTO attachment = new TopicDraftAttachmentDTO(); |
|
|
|
|
|
int sort = 0; |
|
|
|
|
|
for(String url : formDTO.getImageList()){ |
|
|
|
|
|
attachment.setAttachmentUrl(url); |
|
|
|
|
|
attachment.setTopicDraftId(topic.getId()); |
|
|
|
|
|
attachment.setCreatedBy(tokenDto.getUserId()); |
|
|
|
|
|
attachment.setAttachmentFormat(url.substring(url.lastIndexOf(".") + NumConstant.ONE).toLowerCase()); |
|
|
|
|
|
attachment.setSort(sort++); |
|
|
|
|
|
attachment.setAttachmentType("image"); |
|
|
|
|
|
topicDraftAttachmentService.save(attachment); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(formDTO.getVideoList())){ |
|
|
|
|
|
TopicDraftAttachmentDTO attachment = new TopicDraftAttachmentDTO(); |
|
|
|
|
|
int sort = 0; |
|
|
|
|
|
for(String url : formDTO.getVideoList()){ |
|
|
|
|
|
attachment.setAttachmentUrl(url); |
|
|
|
|
|
attachment.setTopicDraftId(topic.getId()); |
|
|
|
|
|
attachment.setCreatedBy(tokenDto.getUserId()); |
|
|
|
|
|
attachment.setAttachmentFormat(url.substring(url.lastIndexOf(".") + NumConstant.ONE).toLowerCase()); |
|
|
|
|
|
attachment.setSort(sort++); |
|
|
|
|
|
attachment.setAttachmentType("image"); |
|
|
|
|
|
topicDraftAttachmentService.save(attachment); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//话题操作记录
|
|
|
|
|
|
TopicDraftOperationDTO operation = new TopicDraftOperationDTO(); |
|
|
|
|
|
operation.setTopicDraftId(topic.getId()); |
|
|
|
|
|
operation.setOperateType(TopicConstant.SUBMIT); |
|
|
|
|
|
operation.setCreatedBy(tokenDto.getUserId()); |
|
|
|
|
|
topicDraftOperationService.save(operation); |
|
|
|
|
|
|
|
|
|
|
|
//2.话题内容审核
|
|
|
|
|
|
String topicContent = formDTO.getTopicContent(); |
|
|
|
|
|
if (StringUtils.isNotBlank(topicContent)) { |
|
|
|
|
|
//创建话题内容审核
|
|
|
|
|
|
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); |
|
|
|
|
|
TextTaskDTO taskDTO = new TextTaskDTO(); |
|
|
|
|
|
taskDTO.setContent(topicContent); |
|
|
|
|
|
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
|
|
textScanParamDTO.getTasks().add(taskDTO); |
|
|
|
|
|
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); |
|
|
|
|
|
if (!textSyncScanResult.success()) { |
|
|
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
|
|
} else { |
|
|
|
|
|
if (!textSyncScanResult.getData().isAllPass()) { |
|
|
|
|
|
//更新话题状态block
|
|
|
|
|
|
TopicDraftEntity draftEntity = new TopicDraftEntity(); |
|
|
|
|
|
draftEntity.setId(topic.getId()); |
|
|
|
|
|
draftEntity.setDraftStatus(TopicConstant.BLOCK); |
|
|
|
|
|
draftEntity.setDraftReason("内容审核失败"); |
|
|
|
|
|
baseDao.updateById(draftEntity); |
|
|
|
|
|
//话题操作记录
|
|
|
|
|
|
TopicDraftOperationDTO operationDTO = new TopicDraftOperationDTO(); |
|
|
|
|
|
operationDTO.setTopicDraftId(topic.getId()); |
|
|
|
|
|
operationDTO.setOperateType(TopicConstant.BLOCK); |
|
|
|
|
|
operationDTO.setCreatedBy(tokenDto.getUserId()); |
|
|
|
|
|
topicDraftOperationService.save(operationDTO); |
|
|
|
|
|
|
|
|
|
|
|
log.error(String.format(TopicConstant.CREATE_TOPIC, topicContent)); |
|
|
|
|
|
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//创建话题图片审核
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getImageList())){ |
|
|
|
|
|
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); |
|
|
|
|
|
formDTO.getImageList().forEach(url -> { |
|
|
|
|
|
ImgTaskDTO task = new ImgTaskDTO(); |
|
|
|
|
|
task.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
|
|
task.setUrl(url); |
|
|
|
|
|
imgScanParamDTO.getTasks().add(task); |
|
|
|
|
|
}); |
|
|
|
|
|
Result<SyncScanResult> imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); |
|
|
|
|
|
if (!imgScanResult.success()){ |
|
|
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
|
|
} else { |
|
|
|
|
|
if (!imgScanResult.getData().isAllPass()) { |
|
|
|
|
|
//更新话题状态block
|
|
|
|
|
|
TopicDraftEntity draftEntity = new TopicDraftEntity(); |
|
|
|
|
|
draftEntity.setId(topic.getId()); |
|
|
|
|
|
draftEntity.setDraftStatus(TopicConstant.BLOCK); |
|
|
|
|
|
draftEntity.setDraftReason("图片审核失败"); |
|
|
|
|
|
baseDao.updateById(draftEntity); |
|
|
|
|
|
//话题操作记录
|
|
|
|
|
|
TopicDraftOperationDTO operationDTO = new TopicDraftOperationDTO(); |
|
|
|
|
|
operationDTO.setTopicDraftId(topic.getId()); |
|
|
|
|
|
operationDTO.setOperateType(TopicConstant.BLOCK); |
|
|
|
|
|
operationDTO.setCreatedBy(tokenDto.getUserId()); |
|
|
|
|
|
topicDraftOperationService.save(operationDTO); |
|
|
|
|
|
throw new RenException(EpmetErrorCode.IMG_SCAN_FAILED.getCode()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//TODO 创建话题语音审核
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getVideoList())){ |
|
|
|
|
|
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); |
|
|
|
|
|
formDTO.getVideoList().forEach(url -> { |
|
|
|
|
|
ImgTaskDTO task = new ImgTaskDTO(); |
|
|
|
|
|
task.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
|
|
task.setUrl(url); |
|
|
|
|
|
imgScanParamDTO.getTasks().add(task); |
|
|
|
|
|
//TODO 根据返回值,
|
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
//TODO 话题草稿状态为 auto_passed: 自动通过
|
|
|
|
|
|
//更新话题状态block
|
|
|
|
|
|
TopicDraftEntity draftEntity = new TopicDraftEntity(); |
|
|
|
|
|
draftEntity.setId(topic.getId()); |
|
|
|
|
|
draftEntity.setDraftStatus(TopicConstant.AUTO_PASSED); |
|
|
|
|
|
baseDao.updateById(draftEntity); |
|
|
|
|
|
//话题操作记录
|
|
|
|
|
|
TopicDraftOperationDTO operationDTO = new TopicDraftOperationDTO(); |
|
|
|
|
|
operationDTO.setTopicDraftId(topic.getId()); |
|
|
|
|
|
operationDTO.setOperateType(TopicConstant.AUTO_PASSED); |
|
|
|
|
|
operationDTO.setCreatedBy(tokenDto.getUserId()); |
|
|
|
|
|
topicDraftOperationService.save(operationDTO); |
|
|
|
|
|
//3.保存话题
|
|
|
|
|
|
saveTopic(tokenDto, formDTO, topic.getId()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 组管理界面-待审核/已驳回列表 |
|
|
|
|
|
* |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @return java.util.List<com.epmet.resi.group.dto.topic.result.TopicAuditResultDTO> |
|
|
|
|
|
* @author zhaoqifeng |
|
|
|
|
|
* @date 2020/12/18 14:34 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public List<TopicAuditResultDTO> auditList(TopicAuditFormDTO formDTO) { |
|
|
|
|
|
List<TopicAuditResultDTO> result; |
|
|
|
|
|
|
|
|
|
|
|
if (TopicConstant.REVIEW.equals(formDTO.getStatus())) { |
|
|
|
|
|
result = baseDao.selectTopicDraftByGroup(formDTO.getGroupId(), formDTO.getStatus()); |
|
|
|
|
|
} else { |
|
|
|
|
|
result = baseDao.selectTopicDraftByGroup(formDTO.getGroupId(), formDTO.getStatus()); |
|
|
|
|
|
} |
|
|
|
|
|
result.forEach(item -> { |
|
|
|
|
|
ResiGroupMemberInfoRedisDTO memberRedis = |
|
|
|
|
|
resiGroupMemberRedis.get(formDTO.getGroupId(),item.getUserName()); |
|
|
|
|
|
if(null != memberRedis && StringUtils.isNotBlank(memberRedis.getUserId())){ |
|
|
|
|
|
item.setUserName(StringUtils.isBlank(memberRedis.getUserShowName()) ? "" : memberRedis.getUserShowName()); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 话题草稿详情 |
|
|
|
|
|
* |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @return com.epmet.resi.group.dto.topic.result.DraftDetailResultDTO |
|
|
|
|
|
* @author zhaoqifeng |
|
|
|
|
|
* @date 2020/12/18 14:55 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public DraftDetailResultDTO detail(DraftDetailFormDTO formDTO) { |
|
|
|
|
|
TopicDraftEntity entity = baseDao.selectById(formDTO.getTopicDraftId()); |
|
|
|
|
|
|
|
|
|
|
|
if(null == entity){ |
|
|
|
|
|
log.error(ModuleConstant.NO_SUCH_TOPIC); |
|
|
|
|
|
throw new RenException(ModuleConstant.NO_SUCH_TOPIC); |
|
|
|
|
|
} |
|
|
|
|
|
DraftDetailResultDTO result = ConvertUtils.sourceToTarget(entity,DraftDetailResultDTO.class); |
|
|
|
|
|
result.setTopicDraftId(formDTO.getTopicDraftId()); |
|
|
|
|
|
result.setReleaseTime(new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE).format(entity.getCreatedTime())); |
|
|
|
|
|
result.setTopicContent(entity.getTopicContent()); |
|
|
|
|
|
result.setReleaseAddress(entity.getAddress()); |
|
|
|
|
|
//2.查询话题图片附件
|
|
|
|
|
|
List<String> imageUrls = topicDraftAttachmentService.getFileList(formDTO.getTopicDraftId(), TopicConstant.IMAGE); |
|
|
|
|
|
result.setImageList(imageUrls); |
|
|
|
|
|
|
|
|
|
|
|
//3.查询话题音频附件
|
|
|
|
|
|
List<String> voiceUrls = topicDraftAttachmentService.getFileList(formDTO.getTopicDraftId(), TopicConstant.VOICE); |
|
|
|
|
|
result.setVoiceList(voiceUrls); |
|
|
|
|
|
|
|
|
|
|
|
//3.拿取用户信息
|
|
|
|
|
|
ResiGroupMemberInfoRedisDTO memberRedis = |
|
|
|
|
|
resiGroupMemberRedis.get(entity.getGroupId(),entity.getCreatedBy()); |
|
|
|
|
|
if(null != memberRedis && StringUtils.isNotBlank(memberRedis.getUserId())){ |
|
|
|
|
|
result.setReleaseUserName(StringUtils.isBlank(memberRedis.getUserShowName()) ? "" : memberRedis.getUserShowName()); |
|
|
|
|
|
result.setReleaseUserHeadPhoto(StringUtils.isBlank(memberRedis.getUserHeadPhoto()) ? "" : memberRedis.getUserHeadPhoto()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 删除已驳回话题 |
|
|
|
|
|
* |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @return void |
|
|
|
|
|
* @author zhaoqifeng |
|
|
|
|
|
* @date 2020/12/18 14:58 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void deleteDraft(DraftDetailFormDTO formDTO) { |
|
|
|
|
|
TopicDraftEntity entity = new TopicDraftEntity(); |
|
|
|
|
|
entity.setId(formDTO.getTopicDraftId()); |
|
|
|
|
|
entity.setIsSee(NumConstant.ONE_STR); |
|
|
|
|
|
baseDao.updateById(entity); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 组长审核 |
|
|
|
|
|
* |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @return void |
|
|
|
|
|
* @author zhaoqifeng |
|
|
|
|
|
* @date 2020/12/18 15:06 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void audit(AuditDraftTopicFormDTO formDTO) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 保存话题 |
|
|
|
|
|
* @author zhaoqifeng |
|
|
|
|
|
* @date 2020/12/18 10:38 |
|
|
|
|
|
* @param tokenDto |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @return void |
|
|
|
|
|
*/ |
|
|
|
|
|
private void saveTopic(TokenDto tokenDto, CreateTopicFormDTO formDTO, String draftId) { |
|
|
|
|
|
//1.身份校验,查看当前用户是否是组内成员,当前用户是否被禁言
|
|
|
|
|
|
ResiGroupMemberDTO resiGroupMemberDTO = |
|
|
|
|
|
resiGroupMemberService.getResiGroupMember(formDTO.getGroupId(),tokenDto.getUserId() ); |
|
|
|
|
|
|
|
|
|
|
|
Result result = verifySilentOrRemoved(resiGroupMemberDTO); |
|
|
|
|
|
if(!result.success()){ |
|
|
|
|
|
throw new RenException(result.getCode(), result.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Date currentTime = new Date(); |
|
|
|
|
|
//2.创建话题
|
|
|
|
|
|
ResiTopicEntity topic = ConvertUtils.sourceToTarget(formDTO,ResiTopicEntity.class); |
|
|
|
|
|
topic.setCreatedBy(tokenDto.getUserId()); |
|
|
|
|
|
topic.setStatus(TopicConstant.PUBLISHMENT); |
|
|
|
|
|
resiTopicDao.insertOne(topic); |
|
|
|
|
|
if(StringUtils.isBlank(topic.getId())){ |
|
|
|
|
|
//没有返回主键
|
|
|
|
|
|
log.error(ModuleConstant.NO_PRIMARY_KEY_RETURNED); |
|
|
|
|
|
throw new RenException(ModuleConstant.NO_PRIMARY_KEY_RETURNED); |
|
|
|
|
|
} |
|
|
|
|
|
if(CollectionUtils.isNotEmpty(formDTO.getImageList())){ |
|
|
|
|
|
ResiTopicAttachmentEntity attachment = new ResiTopicAttachmentEntity(); |
|
|
|
|
|
int sort = 0; |
|
|
|
|
|
for(String url : formDTO.getImageList()){ |
|
|
|
|
|
attachment.setAttachmentUrl(url); |
|
|
|
|
|
attachment.setTopicId(topic.getId()); |
|
|
|
|
|
attachment.setCreatedBy(tokenDto.getUserId()); |
|
|
|
|
|
attachment.setAttachmentFormat(url.substring(url.lastIndexOf(".") + NumConstant.ONE).toLowerCase()); |
|
|
|
|
|
attachment.setSort(sort++); |
|
|
|
|
|
attachment.setAttachmentType("image"); |
|
|
|
|
|
resiTopicAttachmentDao.insertOne(attachment); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//3.话题操作记录
|
|
|
|
|
|
ResiTopicOperationEntity operation = new ResiTopicOperationEntity(); |
|
|
|
|
|
operation.setTopicId(topic.getId()); |
|
|
|
|
|
operation.setOperationType(TopicConstant.PUBLISHMENT); |
|
|
|
|
|
operation.setCreatedBy(tokenDto.getUserId()); |
|
|
|
|
|
resiTopicOperationDao.insertOne(operation); |
|
|
|
|
|
|
|
|
|
|
|
//4.小组统计信息,话题数+1
|
|
|
|
|
|
QueryWrapper<ResiGroupStatisticalEntity> wrapper = new QueryWrapper<>(); |
|
|
|
|
|
wrapper.eq(FieldConstant.DEL_FLAG, NumConstant.ZERO_STR); |
|
|
|
|
|
wrapper.eq(TopicConstant.RESI_GROUP_ID,formDTO.getGroupId()); |
|
|
|
|
|
List<ResiGroupStatisticalEntity> statistical = resiGroupStatisticalDao.selectList(wrapper); |
|
|
|
|
|
if(null != statistical && statistical.size() >= NumConstant.ONE){ |
|
|
|
|
|
if(statistical.size() != NumConstant.ONE){ |
|
|
|
|
|
log.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()); |
|
|
|
|
|
statistical2Update.setTotalTopics(null == statistical.get(NumConstant.ZERO).getTotalTopics() ? NumConstant.ONE : statistical.get(NumConstant.ZERO).getTotalTopics() + NumConstant.ONE); |
|
|
|
|
|
statistical2Update.setUpdatedBy(tokenDto.getUserId()); |
|
|
|
|
|
statistical2Update.setUpdatedTime(currentTime); |
|
|
|
|
|
resiGroupStatisticalDao.updateById(statistical2Update); |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
log.error(ModuleConstant.NO_SUCH_GROUP_STASTICAL_INFO); |
|
|
|
|
|
throw new RenException(ModuleConstant.NO_SUCH_GROUP_STASTICAL_INFO); |
|
|
|
|
|
} |
|
|
|
|
|
//5.更新群缓存信息,话题数量+1
|
|
|
|
|
|
updCacheGroupStatisticalInfo(formDTO.getGroupId(),ModuleConstant.PLUS_OPERATION,NumConstant.ONE); |
|
|
|
|
|
|
|
|
|
|
|
//6.群组信息,更新latestTopicPublishDate字段
|
|
|
|
|
|
ResiGroupEntity group2Update = new ResiGroupEntity(); |
|
|
|
|
|
group2Update.setId(formDTO.getGroupId()); |
|
|
|
|
|
group2Update.setLatestTopicPublishDate(currentTime); |
|
|
|
|
|
resiGroupDao.updateById(group2Update); |
|
|
|
|
|
|
|
|
|
|
|
TopicDraftEntity draftEntity = new TopicDraftEntity(); |
|
|
|
|
|
draftEntity.setId(draftId); |
|
|
|
|
|
draftEntity.setTopicId(topic.getId()); |
|
|
|
|
|
baseDao.updateById(draftEntity); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 查询当前组员在组内是否被禁言或已被移除 |
|
|
|
|
|
* @Param resiGroupMemberDTO |
|
|
|
|
|
* @return Result.class |
|
|
|
|
|
* @Author zhaoqf |
|
|
|
|
|
* @Date 2020.04.01 15:00 |
|
|
|
|
|
**/ |
|
|
|
|
|
private Result verifySilentOrRemoved(ResiGroupMemberDTO resiGroupMemberDTO){ |
|
|
|
|
|
if(null != resiGroupMemberDTO){ |
|
|
|
|
|
if(MemberStateConstant.SILENT.equals(resiGroupMemberDTO.getStatus())){ |
|
|
|
|
|
//当前用户被禁言
|
|
|
|
|
|
log.error(ModuleConstant.SLIENT_MEMBER); |
|
|
|
|
|
throw new RenException(ModuleConstant.SLIENT_MEMBER); |
|
|
|
|
|
}else if(MemberStateConstant.REMOVED.equals(resiGroupMemberDTO.getStatus())){ |
|
|
|
|
|
//当前用户已被移出群
|
|
|
|
|
|
log.error(ModuleConstant.REMOVED_MEMBER); |
|
|
|
|
|
throw new RenException(ModuleConstant.REMOVED_MEMBER); |
|
|
|
|
|
}else{ |
|
|
|
|
|
return new Result(); |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
//当前用户非组内成员
|
|
|
|
|
|
log.error(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); |
|
|
|
|
|
throw new RenException(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 更新组统计缓存信息 |
|
|
|
|
|
* @Param groupId |
|
|
|
|
|
* @Param operation "+":plus "-":minus |
|
|
|
|
|
* @return |
|
|
|
|
|
* @Author zhaoqf |
|
|
|
|
|
* @Date 2020.04.14 23:31 |
|
|
|
|
|
**/ |
|
|
|
|
|
private void updCacheGroupStatisticalInfo(String groupId,String operation,Integer quantity){ |
|
|
|
|
|
|
|
|
|
|
|
//ResiGroupRedis在get()时已经校验缓存中是否有数据,如果没有数据则从数据库中拉取并重新放入缓存
|
|
|
|
|
|
ResiGroupInfoRedisDTO groupCache = |
|
|
|
|
|
resiGroupRedis.get(groupId); |
|
|
|
|
|
if(groupCache != null && StringUtils.isNotBlank(groupCache.getGroupId())){ |
|
|
|
|
|
ResiGroupStatisticalInfoRedisDTO statisticalCache = groupCache.getGroupStatisticalInfo(); |
|
|
|
|
|
if(null != statisticalCache){ |
|
|
|
|
|
if(StringUtils.equals(ModuleConstant.PLUS_OPERATION,operation)){ |
|
|
|
|
|
statisticalCache.setTotalTopics( |
|
|
|
|
|
null == statisticalCache.getTotalTopics() ? quantity : statisticalCache.getTotalTopics() + quantity |
|
|
|
|
|
); |
|
|
|
|
|
}else if(StringUtils.equals(ModuleConstant.MINUS_OPERATION,operation)){ |
|
|
|
|
|
statisticalCache.setTotalTopics( |
|
|
|
|
|
null == statisticalCache.getTotalTopics() ? quantity : statisticalCache.getTotalTopics() - quantity |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
groupCache.setGroupStatisticalInfo(statisticalCache); |
|
|
|
|
|
}else{ |
|
|
|
|
|
//没有相应的群组统计缓存信息
|
|
|
|
|
|
} |
|
|
|
|
|
resiGroupRedis.set(groupCache); |
|
|
|
|
|
}else{ |
|
|
|
|
|
//没有相应的群组缓存信息
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |