From f0c722f203ee6578659f44d0a163a5188ac702f7 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 9 Jun 2020 13:32:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E7=A9=BA=E5=80=BC=EF=BC=9B=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=97=B6=E8=BF=94=E5=9B=9E=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/result/DraftContentSaveResultDTO.java | 23 ++++++++++ .../com/epmet/constant/DraftConstant.java | 5 +++ .../epmet/controller/ArticleController.java | 5 ++- .../service/impl/ArticleServiceImpl.java | 43 +++++++++---------- .../java/com/epmet/utils/ModuleConstant.java | 5 +++ 5 files changed, 56 insertions(+), 25 deletions(-) create mode 100644 epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftContentSaveResultDTO.java 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 * */ From f3e1ffd68529c29e3d4cc9c2f3e9e848fe7ce604 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 9 Jun 2020 14:10:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/controller/DraftController.java | 2 +- .../src/main/java/com/epmet/dao/ArticleDao.java | 6 +++--- .../src/main/resources/mapper/ArticleDao.xml | 16 +++++++++++----- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/DraftController.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/DraftController.java index 3656c16f6e..89acd7d3d2 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/DraftController.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/DraftController.java @@ -115,7 +115,7 @@ public class DraftController { @PostMapping("draftlist") @RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_DRAFT_LIST) - public Result> draftList(@LoginUser TokenDto tokenDto, DraftListFormDTO formDTO) { + public Result> draftList(@LoginUser TokenDto tokenDto, @RequestBody DraftListFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); return new Result>().ok(draftService.draftList(tokenDto, formDTO).getList()); } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleDao.java index a09cc3927d..f444f878f7 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleDao.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleDao.java @@ -83,9 +83,9 @@ public interface ArticleDao extends BaseDao { * @param gridList * @return java.util.List */ - @DataFilter(tableAliases = {"a", "apr"}, gridIdsArgName = "gridList") List selectArticleListForGrid(@Param("customerId") String customerId, - @Param("tagIdList") List tagIdList, Set gridList); + @Param("tagIdList") List tagIdList, + @Param("gridList")Set gridList); /** * 已下线文章列表 @@ -94,7 +94,7 @@ public interface ArticleDao extends BaseDao { * @param gridList * @return java.util.List */ - @DataFilter(tableAliases = "apr", gridIdsArgName = "gridList") + @DataFilter(tableAliases = "a", gridIdsArgName = "gridList") List selectOfflineList(Set gridList); diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml index d3be4c7e2f..42ba89d7fc 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml @@ -96,6 +96,9 @@ WHERE a.DEL_FLAG = '0' AND a.STATUS_FLAG = 'published' AND a.CUSTOMER_ID = #{customerId} + + a.GRID_ID = #{gridId} + UNION SELECT DISTINCT aa.ID AS "articleId", @@ -109,7 +112,11 @@ INNER JOIN article_publish_range apr ON aa.ID = apr.ARTICLE_ID AND apr.DEL_FLAG = 0 AND apr.PUBLISH_STATUS = 'published' WHERE aa.DEL_FLAG = '0' AND aa.STATUS_FLAG = 'published' - AND aa.CUSTOMER_ID = #{customerId}) t + AND aa.CUSTOMER_ID = #{customerId} + + apr.GRID_ID = #{gridId} + + ) t AND EXISTS ( SELECT DISTINCT @@ -131,12 +138,11 @@ a.TITLE AS "title", IFNULL(a.PREVIEW_CONTENT, "") AS "previewContent", a.PUBLISHER_NAME AS "publisherName", - a.PUBLISH_DATE AS "publishDate" + a.OFF_LINE_TIME AS "publishDate" FROM article a - INNER JOIN article_publish_range apr ON a.ID = apr.ARTICLE_ID AND apr.DEL_FLAG = '0' WHERE a.DEL_FLAG = '0' - AND apr.PUBLISH_STATUS = 'offline' - ORDER BY apr.OFF_LINE_TIME DESC + AND a.STATUS_FLAG = 'offline' + ORDER BY a.OFF_LINE_TIME DESC