diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddOrSaveDraftFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddOrSaveDraftFormDTO.java index 207fb75bcc..aef08ba3ff 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddOrSaveDraftFormDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddOrSaveDraftFormDTO.java @@ -1,13 +1,12 @@ package com.epmet.dto.form; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -18,7 +17,7 @@ import java.util.List; @Data public class AddOrSaveDraftFormDTO implements Serializable { - public interface AddArticleForm{} + public interface AddArticleForm extends CustomerClientShowGroup {} public interface AddDraftForm{} /** @@ -31,7 +30,7 @@ public class AddOrSaveDraftFormDTO implements Serializable { @Length(max = 50, message = "标题最长为50个字") private String title; - @NotBlank(message = "栏目分类不能为空",groups = {AddArticleForm.class}) + // @NotBlank(message = "所属栏目不能为空",groups = {AddArticleForm.class}) private String category; /** @@ -84,4 +83,18 @@ public class AddOrSaveDraftFormDTO implements Serializable { * 封面图地址 */ private String imgUrl; + + /** + * 内容列表 + */ + private List fileList; + + @Data + public static class ContentDTO { + public ContentDTO() { + } + private String fileId; + private String content; + private String fileName; + } } diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/ArticleListFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/ArticleListFormDTO.java index 0a601e9802..aad4177f65 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/ArticleListFormDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/ArticleListFormDTO.java @@ -14,6 +14,16 @@ import java.util.List; public class ArticleListFormDTO implements Serializable { private static final long serialVersionUID = 6397877545890473794L; + /** + * 栏目 + */ + private String category; + + /** + * 子栏目列表 + */ + private List subCategories; + /** * 文章标题 */ diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/UpdateArticleFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/UpdateArticleFormDTO.java index 860e0fd6e6..9c01032aff 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/UpdateArticleFormDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/UpdateArticleFormDTO.java @@ -28,7 +28,7 @@ public class UpdateArticleFormDTO { @NotBlank(message = "articleId不能为空", groups = {AddUserInternalGroup.class}) private String articleId; - @NotBlank(message = "栏目不能为空", groups = {AddUserInternalGroup.class}) + // @NotBlank(message = "所属栏目不能为空", groups = {AddUserShowGroup.class}) private String category; @NotBlank(message = "文章标题不能为空", groups = {AddUserShowGroup.class}) @@ -91,5 +91,19 @@ public class UpdateArticleFormDTO { */ @NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) private String customerId; + + /** + * 内容列表 + */ + private List fileList; + + @Data + public static class ContentDTO { + public ContentDTO() { + } + private String fileId; + private String content; + private String fileName; + } } diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftPcListResultDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftPcListResultDTO.java index 814d1e797c..3aed178f5f 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftPcListResultDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftPcListResultDTO.java @@ -110,6 +110,11 @@ public class DraftPcListResultDTO implements Serializable { */ private List contentList; + /** + * 文章内容 + */ + private List fileList; + @Data public static class Content { /** diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/PublishedListResultDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/PublishedListResultDTO.java index 78ff5fe7f9..0e25e4fd03 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/PublishedListResultDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/PublishedListResultDTO.java @@ -26,6 +26,11 @@ public class PublishedListResultDTO implements Serializable { * 分类 */ private String category; + + /** + * 栏目名称 + */ + private String categoryName; /** * 组织Id */ @@ -112,6 +117,11 @@ public class PublishedListResultDTO implements Serializable { */ private List contentList; + /** + * 附件列表 + */ + private List fileList; + @Data public static class Content { /** 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 49c9350819..d2fdb3a7e8 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 @@ -131,6 +131,9 @@ public class ArticleServiceImpl extends BaseServiceImpl rangeList = new ArrayList<>(); @@ -1728,6 +1762,20 @@ public class ArticleServiceImpl extends BaseServiceImpl subCategories; + if (StringUtils.isNotBlank(categoryId = formDTO.getCategory())) { + LambdaQueryWrapper cq = new LambdaQueryWrapper<>(); + cq.eq(CategoryDictEntity::getPid, categoryId); + List subCtgs = categoryDictDao.selectList(cq); + if (! CollectionUtils.isEmpty(subCtgs)) { + subCategories = subCtgs.stream().map(CategoryDictEntity::getId).collect(Collectors.toList()); + formDTO.setSubCategories(subCategories); + } + } + List list = baseDao.selectAllArticle(formDTO); PageInfo pageInfo = new PageInfo<>(list); @@ -1773,12 +1821,23 @@ public class ArticleServiceImpl extends BaseServiceImpl tWrapper1 = new LambdaQueryWrapper<>(); tWrapper1.eq(ArticleContentEntity::getArticleId, formDTO.getArticleId()); tWrapper1.eq(ArticleContentEntity::getDelFlag, NumConstant.ZERO_STR); + tWrapper1.ne(ArticleContentEntity::getContentType,"file"); tWrapper1.orderByDesc(ArticleContentEntity::getOrderNum); List contentEntityList = articleContentDao.selectList(tWrapper1); if (!CollectionUtils.isEmpty(contentEntityList)) { List contentList = ConvertUtils.sourceToTarget(contentEntityList, PublishedListResultDTO.Content.class); resultDTO.setContentList(contentList); } + LambdaQueryWrapper fileWrapper = new LambdaQueryWrapper<>(); + fileWrapper.eq(ArticleContentEntity::getArticleId, formDTO.getArticleId()); + fileWrapper.eq(ArticleContentEntity::getDelFlag, NumConstant.ZERO_STR); + fileWrapper.eq(ArticleContentEntity::getContentType,"file"); + fileWrapper.orderByDesc(ArticleContentEntity::getOrderNum); + List fileContentEntityList = articleContentDao.selectList(fileWrapper); + if (!CollectionUtils.isEmpty(fileContentEntityList)) { + List fileList = ConvertUtils.sourceToTarget(fileContentEntityList, PublishedListResultDTO.Content.class); + resultDTO.setFileList(fileList); + } //标签列表 LambdaQueryWrapper tWrapper2 = new LambdaQueryWrapper<>(); @@ -1790,6 +1849,12 @@ public class ArticleServiceImpl extends BaseServiceImpl del=new LambdaQueryWrapper<>(); + del.eq(ArticleContentEntity::getArticleId,formDTO.getArticleId()) + .ne(ArticleContentEntity::getContent,"rich_text"); + articleContentDao.delete(del); + int orderNum=2; + for(UpdateArticleFormDTO.ContentDTO file:formDTO.getFileList()){ + ArticleContentEntity fileDto=new ArticleContentEntity(); + fileDto.setCustomerId(formDTO.getCustomerId()); + fileDto.setArticleId(formDTO.getArticleId()); + fileDto.setContent(file.getContent()); + fileDto.setFileName(file.getFileName()); + fileDto.setContentType("file"); + fileDto.setOrderNum(orderNum); + articleContentDao.insert(fileDto); + orderNum++; + } + } + //内容类型 图片:img;文字:text;文件:file 富文本:rich_text 如果是工作端小程序发布的文章,在pc编辑后,img和text删除。 + LambdaUpdateWrapper updateWrapper=new LambdaUpdateWrapper<>(); + updateWrapper.eq(ArticleContentEntity::getArticleId,formDTO.getArticleId()) + .ne(ArticleContentEntity::getContentType,"rich_text") + .ne(ArticleContentEntity::getContentType,"file") + .set(ArticleContentEntity::getDelFlag,NumConstant.ONE_STR) + .set(ArticleContentEntity::getUpdatedBy,EpmetRequestHolder.getLoginUserId()) + .set(ArticleContentEntity::getUpdatedTime,new Date()); + articleContentDao.update(null,updateWrapper); + // 3.操作记录 ArticleOperateRecordEntity articleOperateRecord = new ArticleOperateRecordEntity(); articleOperateRecord.setCustomerId(formDTO.getCustomerId()); 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 5d786be693..27111b4545 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 @@ -266,7 +266,8 @@ public class DraftServiceImpl extends BaseServiceImpl imp //查询文章内容 LambdaQueryWrapper tWrapper1 = new LambdaQueryWrapper<>(); tWrapper1.eq(DraftContentEntity::getDraftId, formDTO.getDraftId()); - tWrapper1.eq(DraftContentEntity::getDelFlag, NumConstant.ZERO_STR); + tWrapper1.eq(DraftContentEntity::getDelFlag, NumConstant.ZERO_STR) + .ne(DraftContentEntity::getContentType,"file"); tWrapper1.orderByDesc(DraftContentEntity::getOrderNum); List contentEntityList = draftContentDao.selectList(tWrapper1); if (!CollectionUtils.isEmpty(contentEntityList)) { @@ -274,6 +275,16 @@ public class DraftServiceImpl extends BaseServiceImpl imp resultDTO.setContentList(contentList); } + LambdaQueryWrapper fileWrapper = new LambdaQueryWrapper<>(); + fileWrapper.eq(DraftContentEntity::getDraftId, formDTO.getDraftId()); + fileWrapper.eq(DraftContentEntity::getDelFlag, NumConstant.ZERO_STR) + .eq(DraftContentEntity::getContentType,"file"); + fileWrapper.orderByDesc(DraftContentEntity::getOrderNum); + List fileContentEntityList = draftContentDao.selectList(fileWrapper); + if (!CollectionUtils.isEmpty(fileContentEntityList)) { + List fileContentList = ConvertUtils.sourceToTarget(fileContentEntityList, DraftPcListResultDTO.Content.class); + resultDTO.setFileList(fileContentList); + } //标签列表 if(!CollectionUtils.isEmpty(resultDTO.getTagNameList())){ LambdaQueryWrapper tWrapper2 = new LambdaQueryWrapper<>(); diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleContentDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleContentDao.xml index 52007cee9e..300b4d14bc 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleContentDao.xml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleContentDao.xml @@ -12,6 +12,7 @@ WHERE ac.DEL_FLAG = '0' AND ac.ID = #{articleId} + and ac.CONTENT_TYPE ='rich_text' \ No newline at end of file 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 19daac0379..ba1667da70 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 @@ -437,6 +437,7 @@ a.org_id AS "agencyId", a.title AS "title", a.category AS "category", + cd.CATEGORY_NAME, IFNULL(a.preview_content, "") AS "previewContent", a.publish_range_desc AS "publishRangeDesc", a.publisher_id AS "publisher", @@ -453,9 +454,25 @@ ac.img_url AS "imgUrl" FROM article a + inner join category_dict cd on (cd.DEL_FLAG = 0 and a.CATEGORY = cd.ID) LEFT JOIN article_cover ac ON a.id = ac.article_id AND ac.del_flag = '0' WHERE a.del_flag = '0' + + + and ( + + a.CATEGORY in ( + + #{ctg} + + ) or + + + a.CATEGORY = #{category} + + ) + AND a.id = #{articleId}