|
|
@ -179,16 +179,8 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
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.setPreviewContent(""); |
|
|
|
buildPreviewContent(fromDTO, draftEntity); |
|
|
|
draftDao.updateById(draftEntity); |
|
|
|
|
|
|
|
} else { |
|
|
@ -211,16 +203,8 @@ 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; |
|
|
|
} |
|
|
|
} |
|
|
|
draftEntity.setPreviewContent(""); |
|
|
|
buildPreviewContent(fromDTO, draftEntity); |
|
|
|
draftDao.insert(draftEntity); |
|
|
|
} |
|
|
|
|
|
|
@ -233,12 +217,25 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, Object> draftIdMap = new HashMap<>(); |
|
|
|
draftIdMap.put("DRAFT_ID", fromDTO.getDraftId()); |
|
|
|
draftIdMap.put(ModuleConstant.FIELD_DRAFT_ID, fromDTO.getDraftId()); |
|
|
|
draftContentDao.deleteByMap(draftIdMap); |
|
|
|
draftContentService.insertBatch(draftContentList); |
|
|
|
return draftId; |
|
|
|
} |
|
|
|
|
|
|
|
private void buildPreviewContent(DraftContentFromDTO fromDTO, DraftEntity draftEntity) { |
|
|
|
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 |
|
|
|
public GovArticleDetailResultDTO queryGovArticleDetail(String articleId) { |
|
|
|
GovArticleDetailResultDTO articleDetail = baseDao.queryGovArticleDetail(articleId); |
|
|
@ -323,7 +320,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 +351,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); |
|
|
|