From 82f49b25baecbedf5006caa3632cfa1ab65ef29b Mon Sep 17 00:00:00 2001 From: wangchao Date: Fri, 5 Jun 2020 12:27:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=8D=89=E7=A8=BF=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=96=87=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dao/DraftContentDao.java | 15 ++++- .../java/com/epmet/dao/DraftCoverDao.java | 15 ++++- .../com/epmet/dao/DraftPublishRangeDao.java | 14 ++++- .../com/epmet/service/ArticleService.java | 9 +++ .../service/impl/ArticleServiceImpl.java | 63 ++++++++++++++++++- .../java/com/epmet/utils/ModuleConstant.java | 15 +++++ .../main/resources/mapper/DraftContentDao.xml | 21 +++++++ .../main/resources/mapper/DraftCoverDao.xml | 18 ++++++ .../resources/mapper/DraftPublishRangeDao.xml | 17 +++++ 9 files changed, 181 insertions(+), 6 deletions(-) diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftContentDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftContentDao.java index 8d36568edf..3c7af386a0 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftContentDao.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftContentDao.java @@ -18,8 +18,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.DraftContentDTO; import com.epmet.entity.DraftContentEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 草稿内容表 @@ -29,5 +33,14 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface DraftContentDao extends BaseDao { - + + /** + * @Description 通过草稿Id获取草稿内容并按照orderNum排序,默认拿取所有状态 + * @param draftId + * @param auditStatus + * @return List + * @author wangc + * @date 2020.06.05 10:28 + **/ + List selectByDraftId(@Param("draftId")String draftId,@Param("auditStatus")String auditStatus); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftCoverDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftCoverDao.java index b625204667..bcf58361e1 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftCoverDao.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftCoverDao.java @@ -18,8 +18,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.DraftCoverDTO; import com.epmet.entity.DraftCoverEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 草稿封面表 @@ -29,5 +33,14 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface DraftCoverDao extends BaseDao { - + + /** + * @Description 通过草稿Id获取草稿封面且创建时间是为最新的 + * @param draftId + * @param auditStatus + * @return DraftCoverDTO + * @author wangc + * @date 2020.06.05 10:28 + **/ + DraftCoverDTO selectByDraftId(@Param("draftId")String draftId,@Param("auditStatus")String auditStatus); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftPublishRangeDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftPublishRangeDao.java index 98a6a65f8e..b3da6a7c4e 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftPublishRangeDao.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftPublishRangeDao.java @@ -18,8 +18,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.DraftPublishRangeDTO; import com.epmet.entity.DraftPublishRangeEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 草稿发布范围表 @@ -29,5 +33,13 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface DraftPublishRangeDao extends BaseDao { - + + /** + * @Description 通过草稿Id获取草稿发布范围 + * @param draftId + * @return List + * @author wangc + * @date 2020.06.05 10:28 + **/ + List selectByDraftId(@Param("draftId")String draftId); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java index 1fbeeadf2f..4e8613f908 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java @@ -230,4 +230,13 @@ public interface ArticleService extends BaseService { * @date 2020.06.03 18:28 **/ ArticleDetailResultDTO getArticleDetail(ResiArticleDetailFormDTO articleDetailFormDTO); + + /** + * @Description 草稿发布文章 + * @param draftId + * @return String 返回新发布文章的Id + * @author wangc + * @date 2020.06.05 09:10 + **/ + String publishDraftToArticle(String draftId); } \ No newline at end of file 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 5219c1de67..78817ea0fa 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 @@ -18,6 +18,7 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; @@ -36,9 +37,7 @@ import com.epmet.constant.ArticleConstant; import com.epmet.constant.DraftConstant; import com.epmet.constant.RoleKeyConstants; import com.epmet.dao.*; -import com.epmet.dto.ArticleDTO; -import com.epmet.dto.ArticleVisitRecordDTO; -import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.*; import com.epmet.dto.feign.GovOrgSelfFeignClient; import com.epmet.dto.form.*; import com.epmet.dto.result.*; @@ -92,6 +91,10 @@ public class ArticleServiceImpl extends BaseServiceImpl draftContents = draftContentDao.selectByDraftId(draftId,ModuleConstant.AUDIT_STATUS_PASS); + DraftCoverDTO draftCover = draftCoverDao.selectByDraftId(draftId,ModuleConstant.AUDIT_STATUS_PASS); + List draftPublishRange = draftPublishRangeDao.selectByDraftId(draftId); + + //3.生成文章以及相关记录 + ArticleEntity article = ConvertUtils.sourceToTarget(draft,ArticleEntity.class); + 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); + ArticleContentEntity contentToInsert = ConvertUtils.sourceToTarget(content,ArticleContentEntity.class); + contentToInsert.setArticleId(article.getId()); + contentToInsert.setId(null); + articleContentDao.insert(contentToInsert); + }); + } + if(null != draftPublishRange && draftPublishRange.size() > NumConstant.ZERO){ + draftPublishRange.forEach(range -> { + ArticlePublishRangeEntity rangeToInsert = ConvertUtils.sourceToTarget(range,ArticlePublishRangeEntity.class); + rangeToInsert.setArticleId(article.getId()); + rangeToInsert.setId(null); + articlePublishRangeDao.insert(rangeToInsert); + }); + if(null != draftCover){ + ArticleCoverEntity coverToInsert = ConvertUtils.sourceToTarget(draftCover,ArticleCoverEntity.class); + coverToInsert.setArticleId(article.getId()); + coverToInsert.setId(null); + articleCoverDao.insert(coverToInsert); + } + } + + return article.getId(); + } + + throw new RenException(String.format(ModuleConstant.SPECIFIED_DRAFT_NOT_FOUNT_EXCEPTION_TEMPLATE,draftId)); + } + } \ No newline at end of file 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 1aa334094d..e3df228591 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 @@ -49,4 +49,19 @@ public interface ModuleConstant { * */ String SPECIFIED_ARTICLE_NOT_FOUND_EXCEPTION_TEMPLATE = "未找到指定文章,文章Id:【%s】,发布网格Id:【%s】,可能原因:没有该文章或者请求网格不在该文章发布范围内。"; + /** + * 审核类型 通过 + * */ + String AUDIT_STATUS_PASS = "pass"; + + /** + * 审核类型 失败 + * */ + String AUDIT_STATUS_FAIL = "fail"; + + /** + * 草稿未找到异常模板 + * */ + String SPECIFIED_DRAFT_NOT_FOUNT_EXCEPTION_TEMPLATE = "未找到指定草稿,草稿Id:【%s】"; + } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftContentDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftContentDao.xml index ad230ebefc..271ba5b972 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftContentDao.xml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftContentDao.xml @@ -3,5 +3,26 @@ + + \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftCoverDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftCoverDao.xml index f514eeceb3..03f8a04596 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftCoverDao.xml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftCoverDao.xml @@ -3,5 +3,23 @@ + + \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftPublishRangeDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftPublishRangeDao.xml index 2d2c8df78a..afcb6f71a9 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftPublishRangeDao.xml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftPublishRangeDao.xml @@ -3,5 +3,22 @@ + + \ No newline at end of file From 5ba9e9aa8757273a1fcabb158e48a5eaf05127a7 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 5 Jun 2020 12:34:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=94=BF=E5=BA=9C=E7=AB=AF=E8=8D=89?= =?UTF-8?q?=E7=A8=BF=E9=A2=84=E8=A7=88=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/result/DraftDetailResultDTO.java | 62 +++++++++++++++++++ .../epmet/dto/result/GovDraftContentDTO.java | 27 ++++++++ .../epmet/controller/ArticleController.java | 14 +++++ .../src/main/java/com/epmet/dao/DraftDao.java | 38 +++++++++--- .../java/com/epmet/service/DraftService.java | 11 ++++ .../epmet/service/impl/DraftServiceImpl.java | 19 ++++-- .../src/main/resources/mapper/DraftDao.xml | 29 +++++++++ 7 files changed, 186 insertions(+), 14 deletions(-) create mode 100644 epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftDetailResultDTO.java create mode 100644 epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/GovDraftContentDTO.java diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftDetailResultDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftDetailResultDTO.java new file mode 100644 index 0000000000..ccd0e9918e --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftDetailResultDTO.java @@ -0,0 +1,62 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 政府端:文章预览接口返参DTO + * + * @author yinzuomei@elink-cn.com + * @date 2020/6/5 10:56 + */ +@Data +public class DraftDetailResultDTO implements Serializable { + + private static final long serialVersionUID = 6156947260878857897L; + /** + * 草稿Id + */ + private String draftId; + + /** + * 标题 + */ + private String title; + + /** + * 发布单位名称 + */ + private String publisherName; + + /** + * 发布日期 + */ + @JsonFormat(pattern="yyyy-MM-dd") + private Date publishDate; + + /** + * 访问量 + */ + private Integer visitRecordCount; + + /** + * 标签字符串 已废弃 + */ + @JsonIgnore + private String tags; + + /** + * 内容列表 + */ + private List articleContentList; + + /** + * 标签名称数组 + */ + private String[] tagNameList; +} diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/GovDraftContentDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/GovDraftContentDTO.java new file mode 100644 index 0000000000..1b0530e3e4 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/GovDraftContentDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 政府端:文章预览接口返参DTO-内容列表 + * + * @author yinzuomei@elink-cn.com + * @date 2020/6/5 12:10 + */ +@Data +public class GovDraftContentDTO implements Serializable { + private static final long serialVersionUID = 5653062658148122552L; + + /** + * 内容类型,图片:img;文字:text + */ + private String contentType; + + /** + * 内容 + */ + private String content; + +} 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 bb1013913f..fbd76b780f 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 @@ -347,4 +347,18 @@ public class ArticleController { ValidatorUtils.validateEntity(articleDetailFormDTO,ResiArticleDetailFormDTO.ResiArticleDetailInternalGroup.class); return new Result().ok(articleService.getArticleDetail(articleDetailFormDTO)); } + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author yinzuomei@elink-cn.com + * @description 政府端:文章预览 + * @date 2020/6/5 10:56 + **/ + @PostMapping("draftdetail") + public Result queryDraftDetail(@RequestBody DraftDetailFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GovArticleDetailFormDTO.AddUserInternalGroup.class); + DraftDetailResultDTO draftDetailResultDTO = draftService.queryDraftDetail(formDTO); + return new Result().ok(draftDetailResultDTO); + } } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftDao.java index 4daa493ba0..39b47a54f9 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftDao.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftDao.java @@ -36,40 +36,40 @@ public interface DraftDao extends BaseDao { /** * 政府端查询草稿内容详情 * - * @param draftId - * 草稿id + * @param draftId 草稿id + * @author yinzuomei */ DraftContentResultDTO selectDraftContent(String draftId); /** * 政府端查询草稿内容详情 * - * @param draftId - * 草稿id + * @param draftId 草稿id + * @author yinzuomei */ List selectDraftContentDetail(String draftId); /** * 政府端:选中草稿编辑,获取草稿属性 * - * @param draftId - * 草稿id + * @param draftId 草稿id + * @author yinzuomei */ DraftAttrResultDTO selectDraftAttr(String draftId); /** * 政府端:选中草稿编辑,获取草稿属性-封面信息 * - * @param draftId - * 草稿id + * @param draftId 草稿id + * @author yinzuomei */ CoverImgDTO selectDraftCoverImg(String draftId); /** * 政府端:选中草稿编辑,获取草稿属性-已选择发布网格 * - * @param draftId - * 草稿id + * @param draftId 草稿id + * @author yinzuomei */ List selectDraftGrids(String draftId); @@ -81,4 +81,22 @@ public interface DraftDao extends BaseDao { * @return java.util.List */ List selectDraftList(@Param("userId") String userId); + + /** + * @param draftId + * @return com.epmet.dto.result.DraftDetailResultDTO + * @author yinzuomei@elink-cn.com + * @description 文章预览-获取文章基本属性 + * @date 2020/6/5 12:23 + **/ + DraftDetailResultDTO selectDraftDetail(String draftId); + + /** + * @param draftId + * @return java.util.List + * @author yinzuomei@elink-cn.com + * @description 文章预览-获取文章内容列表 + * @date 2020/6/5 12:23 + **/ + List selectDraftContentList(String draftId); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/DraftService.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/DraftService.java index ad56f053a9..a11c1361a3 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/DraftService.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/DraftService.java @@ -26,6 +26,7 @@ import com.epmet.dto.form.DraftDetailFormDTO; import com.epmet.dto.form.DraftListFormDTO; import com.epmet.dto.result.DraftAttrResultDTO; import com.epmet.dto.result.DraftContentResultDTO; +import com.epmet.dto.result.DraftDetailResultDTO; import com.epmet.entity.DraftEntity; import java.util.List; @@ -137,4 +138,14 @@ public interface DraftService extends BaseService { * @return java.util.List */ PageData draftList(TokenDto tokenDto, DraftListFormDTO formDTO); + + /** + * 政府端:文章预览 + * + * @param formDTO + * @return com.epmet.dto.result.DraftContentResultDTO + * @author yinzuomei@elink-cn.com + * @date 2020-06-03 + */ + DraftDetailResultDTO queryDraftDetail(DraftDetailFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/DraftServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/DraftServiceImpl.java index 709da69d32..1cd8271353 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/DraftServiceImpl.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/DraftServiceImpl.java @@ -31,10 +31,7 @@ import com.epmet.dto.DraftDTO; import com.epmet.dto.form.DeleteDraftFormDTO; import com.epmet.dto.form.DraftDetailFormDTO; import com.epmet.dto.form.DraftListFormDTO; -import com.epmet.dto.result.CoverImgDTO; -import com.epmet.dto.result.DraftAttrResultDTO; -import com.epmet.dto.result.DraftContentResultDTO; -import com.epmet.dto.result.DraftListResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.DraftEntity; import com.epmet.redis.DraftRedis; import com.epmet.service.DraftService; @@ -159,4 +156,18 @@ public class DraftServiceImpl extends BaseServiceImpl imp return new PageData<>(resultList, pageInfo.getTotal()); } + @Override + public DraftDetailResultDTO queryDraftDetail(DraftDetailFormDTO formDTO) { + DraftDetailResultDTO draftDetailResultDTO=baseDao.selectDraftDetail(formDTO.getDraftId()); + if(null!=draftDetailResultDTO){ + List articleContentList=baseDao.selectDraftContentList(formDTO.getDraftId()); + draftDetailResultDTO.setArticleContentList(articleContentList); + if (StringUtils.isNoneBlank(draftDetailResultDTO.getTags())) { + String[] tagNames = draftDetailResultDTO.getTags().split("\\|"); + draftDetailResultDTO.setTagNameList(tagNames); + } + } + return draftDetailResultDTO; + } + } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftDao.xml index a74713fd55..0c1f84593f 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftDao.xml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftDao.xml @@ -96,4 +96,33 @@ AND (STATUS_FLAG = 'unpublish' OR STATUS_FLAG = 'auditfail') AND CREATED_BY = #{userId} + + + + \ No newline at end of file