diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftContentSaveResultDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftContentSaveResultDTO.java new file mode 100644 index 0000000000..dadde8373d --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftContentSaveResultDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 政府端:保存文章内容 返回结果 + */ +@Data +public class DraftContentSaveResultDTO implements Serializable { + public DraftContentSaveResultDTO() { + super(); + } + public DraftContentSaveResultDTO(String draftId) { + this.draftId = draftId; + } + + /** + *草稿Id + */ + private String draftId; +} diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/DraftConstant.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/DraftConstant.java index 6788069282..25dbb4b000 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/DraftConstant.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/DraftConstant.java @@ -61,4 +61,9 @@ public interface DraftConstant { * 内容类型-文字 */ String TEXT = "text"; + + /** + * 草稿预览内容大小长度 + */ + Integer PREVIEW_CONTENT_MAX_LENGTH = 50; } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java index c00846c8eb..0be96038f4 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java @@ -75,9 +75,10 @@ public class ArticleController { */ @PostMapping("savecontent") @RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISH) - public Result saveOrUpdateContent(@LoginUser TokenDto tokenDto,@RequestBody DraftContentFromDTO fromDTO) throws Exception { + public Result saveOrUpdateContent(@LoginUser TokenDto tokenDto,@RequestBody DraftContentFromDTO fromDTO) throws Exception { String draftId = articleService.saveOrUpdateContent(tokenDto, fromDTO); - return new Result().ok(draftId); + DraftContentSaveResultDTO resultDTO = new DraftContentSaveResultDTO(draftId); + return new Result().ok(resultDTO); } /** diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java index f4013ebd58..d03f674c46 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java @@ -179,16 +179,8 @@ public class ArticleServiceImpl extends BaseServiceImpl 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 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 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 publishRangeEntityList) { Map 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); diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/utils/ModuleConstant.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/utils/ModuleConstant.java index d9cc1d429c..9da980ea8f 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/utils/ModuleConstant.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/utils/ModuleConstant.java @@ -39,6 +39,11 @@ public interface ModuleConstant { * */ String FIELD_ARTICLE_ID = "ARTICLE_ID"; + /** + * 数据库列名 - 草稿ID + * */ + String FIELD_DRAFT_ID = "DRAFT_ID"; + /** * 实体属性名 - 文章ID * */