|
|
@ -166,40 +166,28 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public String saveOrUpdateContent(TokenDto tokenDto, DraftContentFromDTO fromDTO) { |
|
|
|
public DraftContentSaveResultDTO saveOrUpdateContent(TokenDto tokenDto, DraftContentFromDTO fromDTO, boolean required) { |
|
|
|
log.debug("saveOrUpdateContent param:{}", JSON.toJSONString(fromDTO)); |
|
|
|
if (required) { |
|
|
|
ValidatorUtils.validateEntity(fromDTO, AddGroup.class, DefaultGroup.class); |
|
|
|
} |
|
|
|
|
|
|
|
DraftEntity draftEntity = null; |
|
|
|
List<DraftContentEntity> draftContentList = null; |
|
|
|
if (StringUtils.isNotBlank(fromDTO.getDraftId())) { |
|
|
|
draftEntity = draftDao.selectById(fromDTO.getDraftId()); |
|
|
|
if (draftEntity == null) { |
|
|
|
log.warn("saveOrUpdateContent draftId is not exist in db"); |
|
|
|
throw new RenException("参数错误"); |
|
|
|
} |
|
|
|
draftEntity.setTitle(draftEntity.getTitle()); |
|
|
|
for (int i = 0; i < fromDTO.getContentList().size(); i++) { |
|
|
|
if(DraftConstant.TEXT.equals(fromDTO.getContentList().get(i).getContentType())) { |
|
|
|
String content = fromDTO.getContentList().get(i).getContent(); |
|
|
|
if(content.length() > 50) { |
|
|
|
content = content.substring(0, 50); |
|
|
|
} |
|
|
|
draftEntity.setPreviewContent(content); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
draftEntity = this.checkDraftStatus(fromDTO.getDraftId()); |
|
|
|
draftEntity.setTitle(StringUtils.isBlank(draftEntity.getTitle()) ? "" : draftEntity.getTitle()); |
|
|
|
buildPreviewContent(fromDTO, draftEntity); |
|
|
|
draftDao.updateById(draftEntity); |
|
|
|
|
|
|
|
} else { |
|
|
|
LoginUserDetailsFormDTO detailsFormDTO = new LoginUserDetailsFormDTO(); |
|
|
|
detailsFormDTO.setUserId(loginUserUtil.getLoginUserId()); |
|
|
|
detailsFormDTO.setApp(loginUserUtil.getLoginUserApp()); |
|
|
|
detailsFormDTO.setClient(loginUserUtil.getLoginUserClient()); |
|
|
|
Result<LoginUserDetailsResultDTO> loginUserDetails = epmetUserOpenFeignClient.getLoginUserDetails(detailsFormDTO); |
|
|
|
if (loginUserDetails == null || loginUserDetails.getData() == null){ |
|
|
|
if (loginUserDetails == null || loginUserDetails.getData() == null) { |
|
|
|
log.warn("saveOrUpdateContent getloginUserDetails return null"); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(),EpmetErrorCode.SERVER_ERROR.getMsg()); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); |
|
|
|
} |
|
|
|
draftEntity = new DraftEntity(); |
|
|
|
draftEntity.setTitle(fromDTO.getTitle()); |
|
|
@ -211,32 +199,38 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
draftEntity.setGridId(""); |
|
|
|
draftEntity.setDepartmentId(loginUserDetails.getData().getCustomerId()); |
|
|
|
draftEntity.setDelFlag(NumConstant.ZERO_STR); |
|
|
|
for (int i = 0; i < fromDTO.getContentList().size(); i++) { |
|
|
|
if(DraftConstant.TEXT.equals(fromDTO.getContentList().get(i).getContentType())) { |
|
|
|
String content = fromDTO.getContentList().get(i).getContent(); |
|
|
|
if(content.length() > 50) { |
|
|
|
content = content.substring(0, 50); |
|
|
|
} |
|
|
|
draftEntity.setPreviewContent(content); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
buildPreviewContent(fromDTO, draftEntity); |
|
|
|
draftDao.insert(draftEntity); |
|
|
|
} |
|
|
|
|
|
|
|
String draftId = draftEntity.getId(); |
|
|
|
fromDTO.setDraftId(draftId); |
|
|
|
draftContentList = buildDraftContent(tokenDto, fromDTO); |
|
|
|
if (CollectionUtils.isEmpty(draftContentList)) { |
|
|
|
log.warn("saveOrUpdateContent contentList is empty"); |
|
|
|
throw new RenException("参数错误"); |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, Object> draftIdMap = new HashMap<>(); |
|
|
|
draftIdMap.put("DRAFT_ID", fromDTO.getDraftId()); |
|
|
|
draftIdMap.put(ModuleConstant.FIELD_DRAFT_ID, fromDTO.getDraftId()); |
|
|
|
draftContentDao.deleteByMap(draftIdMap); |
|
|
|
if (!CollectionUtils.isEmpty(draftContentList)) { |
|
|
|
draftContentService.insertBatch(draftContentList); |
|
|
|
return draftId; |
|
|
|
} |
|
|
|
return new DraftContentSaveResultDTO(draftId); |
|
|
|
} |
|
|
|
|
|
|
|
private void buildPreviewContent(DraftContentFromDTO fromDTO, DraftEntity draftEntity) { |
|
|
|
if (CollectionUtils.isEmpty(fromDTO.getContentList())){ |
|
|
|
draftEntity.setPreviewContent(""); |
|
|
|
return; |
|
|
|
} |
|
|
|
for (int i = 0; i < fromDTO.getContentList().size(); i++) { |
|
|
|
if (DraftConstant.TEXT.equals(fromDTO.getContentList().get(i).getContentType())) { |
|
|
|
String content = fromDTO.getContentList().get(i).getContent(); |
|
|
|
if (content.length() > DraftConstant.PREVIEW_CONTENT_MAX_LENGTH) { |
|
|
|
content = content.substring(NumConstant.ZERO, DraftConstant.PREVIEW_CONTENT_MAX_LENGTH); |
|
|
|
} |
|
|
|
draftEntity.setPreviewContent(content); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -311,11 +305,12 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
} |
|
|
|
if (NumConstant.ONE_STR.equals(draftEntity.getDelFlag())) { |
|
|
|
log.warn("saveDraftAttr draftId:{} have deleted",draftId); |
|
|
|
throw new RenException("参数错误"); |
|
|
|
throw new RenException("草稿已删除"); |
|
|
|
} |
|
|
|
if (DraftConstant.PUBLISHED.equals(draftEntity.getStatusFlag())) { |
|
|
|
//只有为发布的才能保存修改
|
|
|
|
if (!DraftConstant.UNPUBLISH.equals(draftEntity.getStatusFlag())) { |
|
|
|
log.warn("saveDraftAttr draftId:{} publishStatus have published"); |
|
|
|
throw new RenException("参数错误"); |
|
|
|
throw new RenException("草稿发布状态错误"); |
|
|
|
} |
|
|
|
return draftEntity; |
|
|
|
} |
|
|
@ -323,7 +318,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
@Override |
|
|
|
public Boolean previewSaveDraftAttr(TokenDto tokenDto, DraftAttrFromDTO fromDTO) { |
|
|
|
//校验参数
|
|
|
|
if (fromDTO.getIsTop() == 1 && StringUtils.isBlank(fromDTO.getCoverImg())) { |
|
|
|
if (DraftConstant.TOP.equals(fromDTO.getIsTop()) && StringUtils.isBlank(fromDTO.getCoverImg())) { |
|
|
|
log.warn("saveOrUpdateAttr isTop=1 but coverImg is blank"); |
|
|
|
throw new RenException("文章封面不能为空"); |
|
|
|
} |
|
|
@ -354,7 +349,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void executeSaveDraftAttr(DraftEntity draftEntity, DraftCoverEntity coverEntity, List<DraftPublishRangeEntity> publishRangeEntityList) { |
|
|
|
Map<String,Object> draftIdMap = new HashMap<>(); |
|
|
|
draftIdMap.put("DRAFT_ID", draftEntity.getId()); |
|
|
|
draftIdMap.put(ModuleConstant.FIELD_DRAFT_ID, draftEntity.getId()); |
|
|
|
draftCoverDao.deleteByMap(draftIdMap); |
|
|
|
if (coverEntity != null){ |
|
|
|
draftCoverDao.insert(coverEntity); |
|
|
@ -394,9 +389,8 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
coverEntity.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
coverEntity.setDraftId(fromDTO.getDraftId()); |
|
|
|
coverEntity.setImgUrl(coverImg); |
|
|
|
coverEntity.setAuditStatus(ModuleConstant.AUDIT_STATUS_PASS); |
|
|
|
coverEntity.setAuditStatus(""); |
|
|
|
coverEntity.setAuditReason(""); |
|
|
|
coverEntity.setRevision(0); |
|
|
|
coverEntity.setDelFlag(NumConstant.ZERO_STR); |
|
|
|
return coverEntity; |
|
|
|
} |
|
|
@ -428,10 +422,10 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
draftPublishRangeEntity.setAgencyGridName(agencyGridName); |
|
|
|
draftPublishRangeEntity.setOffLineTime(null); |
|
|
|
draftPublishRangeEntity.setPublishStatus(DraftConstant.UNPUBLISH); |
|
|
|
draftPublishRangeEntity.setRevision(0); |
|
|
|
draftPublishRangeEntity.setDelFlag(NumConstant.ZERO_STR); |
|
|
|
draftPublishRangeEntity.setPids(articleGridResultDTO.getPids()); |
|
|
|
draftPublishRangeEntity.setAllParentName(articleGridResultDTO.getAllParentName()); |
|
|
|
draftPublishRangeEntity.setAgencyId(articleGridResultDTO.getAgencyId()); |
|
|
|
|
|
|
|
publishRangeEntityList.add(draftPublishRangeEntity); |
|
|
|
} |
|
|
@ -447,9 +441,12 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<DraftContentEntity> buildDraftContent(TokenDto tokenDto, DraftContentFromDTO fromDTO) { |
|
|
|
List<DraftContentFromDTO.DraftContentDTO> contentList = fromDTO.getContentList(); |
|
|
|
if (CollectionUtils.isEmpty(contentList)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<DraftContentEntity> newContentList = new ArrayList<>(); |
|
|
|
|
|
|
|
List<DraftContentFromDTO.DraftContentDTO> contentList = fromDTO.getContentList(); |
|
|
|
|
|
|
|
for (int i = 0; i < contentList.size(); i++) { |
|
|
|
DraftContentFromDTO.DraftContentDTO content = contentList.get(i); |
|
|
@ -459,10 +456,11 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
entity.setDraftId(fromDTO.getDraftId()); |
|
|
|
entity.setOrderNum(i + 1); |
|
|
|
//默认通过
|
|
|
|
entity.setAuditStatus(ModuleConstant.AUDIT_STATUS_PASS); |
|
|
|
entity.setAuditStatus(""); |
|
|
|
newContentList.add(entity); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return newContentList; |
|
|
|
} |
|
|
|
|
|
|
@ -909,7 +907,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
if (!NumConstant.ONE_STR.equals(draftEntity.getDelFlag())){ |
|
|
|
if (!NumConstant.ZERO_STR.equals(draftEntity.getDelFlag())){ |
|
|
|
log.error("scanContent draftId:{} delFlag:{} is not support 2 modify",draftId,draftEntity.getDelFlag()); |
|
|
|
return null; |
|
|
|
} |
|
|
@ -940,10 +938,16 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
//todo 执行审核
|
|
|
|
SyncScanResult imgSyncScanResult = ScanContentUtils.imgSyncScan(scanApiHost.concat(imgSyncScanMethod),imgScanParamDTO); |
|
|
|
SyncScanResult textSyncScanResult = ScanContentUtils.textSyncScan(scanApiHost.concat(textSyncScanMethod),textScanParamDTO); |
|
|
|
SyncScanResult imgSyncScanResult = null; |
|
|
|
SyncScanResult textSyncScanResult = null; |
|
|
|
try { |
|
|
|
imgSyncScanResult = ScanContentUtils.imgSyncScan(scanApiHost.concat(imgSyncScanMethod),imgScanParamDTO); |
|
|
|
textSyncScanResult = ScanContentUtils.textSyncScan(scanApiHost.concat(textSyncScanMethod),textScanParamDTO); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("scanContent exception",e); |
|
|
|
this.sendMsg(draftEntity.getTitle(),String.format(ModuleConstant.MSG_ARTICLE_PUBLISH_ERROR, draftEntity.getTitle()); |
|
|
|
this.updateDraftPublishStatus(draftId,DraftConstant.AUDITFAIL) |
|
|
|
} |
|
|
|
SyncScanResult result = new SyncScanResult(); |
|
|
|
if (imgSyncScanResult.isAllPass()){ |
|
|
|
result.setAllPass(imgSyncScanResult.isAllPass()); |
|
|
@ -983,6 +987,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("scanAllPassPublishArticle update db exception", e); |
|
|
|
this.sendMsg(draft.getTitle(), String.format(ModuleConstant.MSG_ARTICLE_PUBLISH_ERROR, draft.getTitle())); |
|
|
|
this.updateDraftPublishStatus(draftId,DraftConstant.AUDITFAIL) |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
@ -1000,6 +1005,19 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
draftContentDao.updateAuditStatusById(id,ModuleConstant.AUDIT_STATUS_FAIL); |
|
|
|
} |
|
|
|
}); |
|
|
|
List<String> successDataIds = syncScanResult.getSuccessDataIds(); |
|
|
|
successDataIds.forEach(id->{ |
|
|
|
if (id.indexOf(ModuleConstant.SCAN_COVER_PREFIX)>=0){ |
|
|
|
draftCoverDao.updateAuditStatusById(id,ModuleConstant.AUDIT_STATUS_PASS); |
|
|
|
}else{ |
|
|
|
draftContentDao.updateAuditStatusById(id,ModuleConstant.AUDIT_STATUS_PASS); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public DraftContentSaveResultDTO saveDraft(TokenDto tokenDto, DraftContentFromDTO fromDTO) { |
|
|
|
return this.saveOrUpdateContent(tokenDto, fromDTO, false); |
|
|
|
} |
|
|
|
|
|
|
|
public Result sendMsg(String title,String content) { |
|
|
@ -1011,10 +1029,13 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
formDTO.setTitle(String.format(ModuleConstant.MSG_TITLE,title)); |
|
|
|
formDTO.setMessageContent(content); |
|
|
|
formDTO.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
|
|
|
|
return epmetMessageOpenFeignClient.saveUserMessage(formDTO); |
|
|
|
} |
|
|
|
|
|
|
|
private void updateDraftPublishStatus(String draftId,String statusFlag){ |
|
|
|
draftDao.updateAuditStatusById(draftId,statusFlag); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 更新DB的标签使用次数 政府端 |
|
|
|
* @param draftId |
|
|
|