|
|
@ -847,16 +847,16 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
article.setId(null); |
|
|
|
article.setDraftId(draftId); |
|
|
|
baseDao.insert(article); |
|
|
|
int order = NumConstant.ONE; |
|
|
|
if(null != draftContents && draftContents.size() > NumConstant.ZERO){ |
|
|
|
draftContents.forEach(content -> { |
|
|
|
content.setOrderNum(order+NumConstant.ONE); |
|
|
|
content.setAuditStatus(ModuleConstant.AUDIT_STATUS_PASS); |
|
|
|
|
|
|
|
content.setOrderNum(content.getOrderNum()); |
|
|
|
ArticleContentEntity contentToInsert = ConvertUtils.sourceToTarget(content,ArticleContentEntity.class); |
|
|
|
contentToInsert.setArticleId(article.getId()); |
|
|
|
contentToInsert.setId(null); |
|
|
|
articleContentDao.insert(contentToInsert); |
|
|
|
|
|
|
|
content.setAuditStatus(ModuleConstant.AUDIT_STATUS_PASS); |
|
|
|
draftContentDao.updateById(content); |
|
|
|
}); |
|
|
|
} |
|
|
@ -868,12 +868,13 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
articlePublishRangeDao.insert(rangeToInsert); |
|
|
|
}); |
|
|
|
if(null != draftCover){ |
|
|
|
draftCover.setAuditStatus(ModuleConstant.AUDIT_STATUS_PASS); |
|
|
|
|
|
|
|
ArticleCoverEntity coverToInsert = ConvertUtils.sourceToTarget(draftCover,ArticleCoverEntity.class); |
|
|
|
coverToInsert.setArticleId(article.getId()); |
|
|
|
coverToInsert.setId(null); |
|
|
|
articleCoverDao.insert(coverToInsert); |
|
|
|
|
|
|
|
draftCover.setAuditStatus(ModuleConstant.AUDIT_STATUS_PASS); |
|
|
|
draftCoverDao.updateById(draftCover); |
|
|
|
} |
|
|
|
} |
|
|
@ -898,86 +899,96 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
@Override |
|
|
|
public SyncScanResult scanContent(TokenDto tokenDto, String draftId) { |
|
|
|
DraftEntity draftEntity = draftDao.selectById(draftId); |
|
|
|
if (draftEntity == null){ |
|
|
|
log.error("scanContent draftId:{} is not exist",draftId); |
|
|
|
return null; |
|
|
|
boolean isOk = true; |
|
|
|
if (draftEntity == null) { |
|
|
|
log.error("scanContent draftId:{} is not exist", draftId); |
|
|
|
isOk = false; |
|
|
|
} |
|
|
|
if (!DraftConstant.AUDITING.equals(draftEntity.getStatusFlag())){ |
|
|
|
log.error("scanContent draftId:{} statusFlag:{} is not support 2 modify",draftId,draftEntity.getStatusFlag()); |
|
|
|
return null; |
|
|
|
if (!DraftConstant.AUDITING.equals(draftEntity.getStatusFlag())) { |
|
|
|
log.error("scanContent draftId:{} statusFlag:{} is not support 2 modify", draftId, draftEntity.getStatusFlag()); |
|
|
|
isOk = false; |
|
|
|
} |
|
|
|
|
|
|
|
if (!NumConstant.ZERO_STR.equals(draftEntity.getDelFlag())){ |
|
|
|
log.error("scanContent draftId:{} delFlag:{} is not support 2 modify",draftId,draftEntity.getDelFlag()); |
|
|
|
return null; |
|
|
|
if (!NumConstant.ZERO_STR.equals(draftEntity.getDelFlag())) { |
|
|
|
log.error("scanContent draftId:{} delFlag:{} is not support 2 modify", draftId, draftEntity.getDelFlag()); |
|
|
|
isOk = false; |
|
|
|
} |
|
|
|
|
|
|
|
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); |
|
|
|
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); |
|
|
|
DraftCoverDTO draftCoverDTO = draftCoverDao.selectCoverIdAndUrlByDraftId(draftId); |
|
|
|
if (draftCoverDTO != null){ |
|
|
|
ImgTaskDTO taskDTO = new ImgTaskDTO(); |
|
|
|
taskDTO.setDataId(ModuleConstant.SCAN_COVER_PREFIX.concat(draftCoverDTO.getId())); |
|
|
|
taskDTO.setUrl(draftCoverDTO.getImgUrl()); |
|
|
|
imgScanParamDTO.getTasks().add(taskDTO); |
|
|
|
} |
|
|
|
List<DraftContentEntity> contentDTOList = draftContentDao.selectScanContentByDraftId(draftId); |
|
|
|
if(!CollectionUtils.isEmpty(contentDTOList)){ |
|
|
|
contentDTOList.forEach(content->{ |
|
|
|
String contentType = content.getContentType(); |
|
|
|
if (DraftConstant.TEXT.equals(contentType)){ |
|
|
|
//todo 内容叠加审核吧 id拼起来
|
|
|
|
TextTaskDTO textTaskDTO = new TextTaskDTO(); |
|
|
|
textTaskDTO.setDataId(content.getId()); |
|
|
|
textTaskDTO.setContent(content.getContent()); |
|
|
|
textScanParamDTO.getTasks().add(textTaskDTO); |
|
|
|
}else if (DraftConstant.IMG.equals(contentType)){ |
|
|
|
ImgTaskDTO taskDTO = new ImgTaskDTO(); |
|
|
|
taskDTO.setDataId(content.getId()); |
|
|
|
taskDTO.setUrl(content.getContent()); |
|
|
|
imgScanParamDTO.getTasks().add(taskDTO); |
|
|
|
} |
|
|
|
}); |
|
|
|
if (!isOk) { |
|
|
|
this.sendMsg(draftEntity.getTitle(), String.format(ModuleConstant.MSG_ARTICLE_PUBLISH_ERROR, draftEntity.getTitle())); |
|
|
|
this.updateDraftPublishStatus(draftId, DraftConstant.AUDITFAIL); |
|
|
|
return null; |
|
|
|
} |
|
|
|
SyncScanResult imgSyncScanResult = null; |
|
|
|
SyncScanResult textSyncScanResult = null; |
|
|
|
SyncScanResult result = null; |
|
|
|
try { |
|
|
|
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); |
|
|
|
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); |
|
|
|
DraftCoverDTO draftCoverDTO = draftCoverDao.selectCoverIdAndUrlByDraftId(draftId); |
|
|
|
if (draftCoverDTO != null) { |
|
|
|
ImgTaskDTO taskDTO = new ImgTaskDTO(); |
|
|
|
taskDTO.setDataId(ModuleConstant.SCAN_COVER_PREFIX.concat(draftCoverDTO.getId())); |
|
|
|
taskDTO.setUrl(draftCoverDTO.getImgUrl()); |
|
|
|
imgScanParamDTO.getTasks().add(taskDTO); |
|
|
|
} |
|
|
|
List<DraftContentEntity> contentDTOList = draftContentDao.selectScanContentByDraftId(draftId); |
|
|
|
if (!CollectionUtils.isEmpty(contentDTOList)) { |
|
|
|
contentDTOList.forEach(content -> { |
|
|
|
String contentType = content.getContentType(); |
|
|
|
if (DraftConstant.TEXT.equals(contentType)) { |
|
|
|
//todo 内容叠加审核吧 id拼起来
|
|
|
|
TextTaskDTO textTaskDTO = new TextTaskDTO(); |
|
|
|
textTaskDTO.setDataId(content.getId()); |
|
|
|
textTaskDTO.setContent(content.getContent()); |
|
|
|
textScanParamDTO.getTasks().add(textTaskDTO); |
|
|
|
} else if (DraftConstant.IMG.equals(contentType)) { |
|
|
|
ImgTaskDTO taskDTO = new ImgTaskDTO(); |
|
|
|
taskDTO.setDataId(content.getId()); |
|
|
|
taskDTO.setUrl(content.getContent()); |
|
|
|
imgScanParamDTO.getTasks().add(taskDTO); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
SyncScanResult imgSyncScanResult = null; |
|
|
|
SyncScanResult textSyncScanResult = null; |
|
|
|
|
|
|
|
log.info("scanContent imgScanParamDTO:{}", JSON.toJSONString(imgScanParamDTO)); |
|
|
|
log.info("scanContent textScanParamDTO:{}", JSON.toJSONString(textScanParamDTO)); |
|
|
|
imgSyncScanResult = ScanContentUtils.imgSyncScan(scanApiHost.concat(imgSyncScanMethod),imgScanParamDTO); |
|
|
|
textSyncScanResult = ScanContentUtils.textSyncScan(scanApiHost.concat(textSyncScanMethod),textScanParamDTO); |
|
|
|
imgSyncScanResult = ScanContentUtils.imgSyncScan(scanApiHost.concat(imgSyncScanMethod), imgScanParamDTO); |
|
|
|
textSyncScanResult = ScanContentUtils.textSyncScan(scanApiHost.concat(textSyncScanMethod), textScanParamDTO); |
|
|
|
|
|
|
|
result = new SyncScanResult(); |
|
|
|
if (imgSyncScanResult.isAllPass()) { |
|
|
|
result.setAllPass(imgSyncScanResult.isAllPass()); |
|
|
|
result.getSuccessDataIds().addAll(imgSyncScanResult.getSuccessDataIds()); |
|
|
|
result.getFailDataIds().addAll(imgSyncScanResult.getFailDataIds()); |
|
|
|
} |
|
|
|
if (textSyncScanResult.isAllPass()) { |
|
|
|
result.setAllPass(result.isAllPass() ? textSyncScanResult.isAllPass() : false); |
|
|
|
result.getSuccessDataIds().addAll(textSyncScanResult.getSuccessDataIds()); |
|
|
|
result.getFailDataIds().addAll(textSyncScanResult.getFailDataIds()); |
|
|
|
} |
|
|
|
} 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()); |
|
|
|
result.getSuccessDataIds().addAll(imgSyncScanResult.getSuccessDataIds()); |
|
|
|
result.getFailDataIds().addAll(imgSyncScanResult.getFailDataIds()); |
|
|
|
log.error("scanContent exception", e); |
|
|
|
this.sendMsg(draftEntity.getTitle(), String.format(ModuleConstant.MSG_ARTICLE_PUBLISH_ERROR, draftEntity.getTitle())); |
|
|
|
this.updateDraftPublishStatus(draftId, DraftConstant.AUDITFAIL); |
|
|
|
} |
|
|
|
if (textSyncScanResult.isAllPass()){ |
|
|
|
result.setAllPass(result.isAllPass()?textSyncScanResult.isAllPass():false); |
|
|
|
result.getSuccessDataIds().addAll(textSyncScanResult.getSuccessDataIds()); |
|
|
|
result.getFailDataIds().addAll(textSyncScanResult.getFailDataIds()); |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void scanAllPassPublishArticle(TokenDto tokenDto, String draftId){ |
|
|
|
|
|
|
|
DraftEntity draft = draftDao.selectById(draftId); |
|
|
|
if (draft == null){ |
|
|
|
throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode(),EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); |
|
|
|
if (draft == null) { |
|
|
|
log.error("scanAllPassPublishArticle draftId:{} is not exist in db", draftId); |
|
|
|
throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); |
|
|
|
} |
|
|
|
try { |
|
|
|
//审核通过
|
|
|
|
ArticleEntity articleEntity = this.publishDraftToArticle(draft); |
|
|
|
this.publishDraftToArticle(draft); |
|
|
|
UpdateCustomerTagCacheDTO updateCustomerTagCacheDTO = this.updateCustomerTag(tokenDto, draftId); |
|
|
|
List<UpdateGridTagCacheDTO> updateGridTagCacheDTOS = this.updateGridTag(tokenDto, draftId, updateCustomerTagCacheDTO); |
|
|
|
this.addArticleTags(updateCustomerTagCacheDTO,draftId,tokenDto); |
|
|
|
this.addArticleTags(updateCustomerTagCacheDTO, draftId, tokenDto); |
|
|
|
|
|
|
|
//更新redis
|
|
|
|
try { |
|
|
@ -990,32 +1001,42 @@ 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); |
|
|
|
this.updateDraftPublishStatus(draftId, DraftConstant.AUDITFAIL); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void updateAuditStatusFailById(String draftId,SyncScanResult syncScanResult) { |
|
|
|
List<String> failDataIds = syncScanResult.getFailDataIds(); |
|
|
|
failDataIds.forEach(id->{ |
|
|
|
if (id.indexOf(ModuleConstant.SCAN_COVER_PREFIX)>=0){ |
|
|
|
draftCoverDao.updateAuditStatusById(id,ModuleConstant.AUDIT_STATUS_FAIL); |
|
|
|
}else{ |
|
|
|
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); |
|
|
|
} |
|
|
|
}); |
|
|
|
DraftEntity draft = draftDao.selectById(draftId); |
|
|
|
if (draft == null) { |
|
|
|
log.error("updateAuditStatusFailById draftId:{} is not exist in db", draftId); |
|
|
|
throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); |
|
|
|
} |
|
|
|
try { |
|
|
|
List<String> failDataIds = syncScanResult.getFailDataIds(); |
|
|
|
failDataIds.forEach(id -> { |
|
|
|
if (id.indexOf(ModuleConstant.SCAN_COVER_PREFIX) >= NumConstant.ZERO) { |
|
|
|
draftCoverDao.updateAuditStatusById(id, ModuleConstant.AUDIT_STATUS_FAIL); |
|
|
|
} else { |
|
|
|
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); |
|
|
|
} |
|
|
|
}); |
|
|
|
} 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()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -1158,7 +1179,6 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
* @param formDto |
|
|
|
* @author zxc |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void addArticleTags(UpdateCustomerTagCacheDTO formDto,String draftId,TokenDto tokenDto){ |
|
|
|
List<AddArticleTagsFormDTO> addArticleTags = new ArrayList<>(); |
|
|
|
List<UpdateTagUseCountsResultDTO> tagsInfo = formDto.getTagsInfo(); |
|
|
|