diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 425417c7d5..4995291154 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -160,6 +160,7 @@ public enum EpmetErrorCode { ERROR_DATE(8533, "不合理日期"), CHECK_PHONE_ERROR(8534, "号码不合法"), + TITLE_AND_CONTENT_ERROR(8535, "标题和内容不能同时为空"), // 该错误不会提示给前端,只是后端传输错误信息用。 ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"), diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml index 56bde19105..dc505b1985 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -275,6 +275,7 @@ lb://epmet-admin-server lb://epmet-oss-server + lb://epmet-message-server diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java index 7ad89d1728..e0a3760bed 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java @@ -688,6 +688,9 @@ public class EpmetUserServiceImpl implements EpmetUserService { //1.分页查询排好序的工作人员Id列表【原本1/2步可以用一个sql,但涉及2需要按1的顺序排序,sql复杂且效率低,所以拆开】 LinkedList staffIds = customerStaffDao.selectOrderRole(formDTO); //2.批量查询工作人员信息,按传入顺序排序 + if(CollectionUtils.isEmpty(staffIds)){ + return new ArrayList<>(); + } List resultList = customerStaffDao.selectStaffList(staffIds); return resultList; } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml index 3efcdfb3dc..9ac36b2509 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml @@ -116,16 +116,18 @@ customer_staff WHERE del_flag = '0' - AND user_id IN - - #{staffId} - - ORDER BY field( - user_id, - + + AND user_id IN + #{staffId} - ) + ORDER BY field( + user_id, + + #{staffId} + + ) + + + + diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java index b265308eaf..8946e7e73a 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java @@ -158,7 +158,7 @@ public class OssController { */ @PostMapping("compressuploadimg") public Result compressUploadImg(@RequestParam("file") MultipartFile file) { - return ossService.compressUploadImg(file, null); + return ossService.compressUploadImg(file, null,200L); } @PostMapping("uploadwximg") @@ -254,15 +254,19 @@ public class OssController { throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); } + } + Result result =null; + String originFileName = file.getOriginalFilename(); + String format = "-" + originFileName.substring(originFileName.lastIndexOf(".") + NumConstant.ONE) + "-"; + format = format.toLowerCase(); + int compressSize = 2 * 1024 * 1024; + // 如果是图片,超过2M的压缩一下 + if (ModuleConstant.PROJECT_FILE_IMAGE.contains(format) && file.getSize() > compressSize) { + // 单个图片10M + result= ossService.compressUploadImg(file, null, 2 * 1024); } else { - // 校验文件大小,不超过2m - long maxSize = 2 * 1024 * 1024; - if (size > maxSize) { - throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() - , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); - } + result=ossService.uploadImg(file, null); } - Result result = ossService.uploadImg(file, null); if (result != null && result.success() ){ UploadImgResultDTO data = result.getData(); if ( data!= null && StringUtils.isNotBlank(data.getUrl())){ @@ -350,7 +354,13 @@ public class OssController { if (size > maxSize) { throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode(), EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); } - + // 如果是图片,超过2M的压缩一下 + if (ModuleConstant.PROJECT_FILE_IMAGE.contains(format)) {//单个图片10M + int compressSize = 2 * 1024 * 1024; + if(file.getSize()>compressSize){ + return ossService.compressUploadImg(file, null,2 * 1024); + } + } return ossService.uploadVariedFile(file); } @@ -410,7 +420,11 @@ public class OssController { throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode() , EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg()); } - + //如果图片大于2M压缩一下 + int compressSize = 2 * 1024 * 1024; + if(file.getSize()>compressSize){ + return ossService.compressUploadImg(file, null,2 * 1024); + } return ossService.uploadImgV2(file, PrivacyType.EXTERNAL, customerId); } diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/OssService.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/OssService.java index d9e210c006..531cf986fb 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/OssService.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/OssService.java @@ -31,7 +31,7 @@ public interface OssService extends BaseService { Result uploadImg(MultipartFile file, String privacy); - Result compressUploadImg(MultipartFile file, String privacy); + Result compressUploadImg(MultipartFile file, String privacy,long desFileSize); Result extUpload(MultipartFile file, String fileName, String privacy); diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/impl/OssServiceImpl.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/impl/OssServiceImpl.java index 40d5d7b492..d55751762c 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/impl/OssServiceImpl.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/impl/OssServiceImpl.java @@ -101,7 +101,7 @@ public class OssServiceImpl extends BaseServiceImpl implement } @Override - public Result compressUploadImg(MultipartFile file, String privacy) { + public Result compressUploadImg(MultipartFile file, String privacy,long desFileSize) { if (file.isEmpty()) { return new Result().error(ModuleErrorCode.UPLOAD_FILE_EMPTY); } @@ -110,7 +110,7 @@ public class OssServiceImpl extends BaseServiceImpl implement String url = null; String ossDomain = null; try { - byte[] fileBytes = compressPicCycle(file.getBytes(),200L,0.3); + byte[] fileBytes = compressPicCycle(file.getBytes(),desFileSize,0.3); AbstractCloudStorageService storageService = OssFactory.build(); url = storageService.uploadSuffix(fileBytes, extension, privacy); ossDomain = storageService.getOssDomain(privacy); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java index 6d46ba3b3a..5839114b8b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java @@ -710,6 +710,9 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl gridIdList; + + /** + * 发布范围Names + */ + private String publishRangeDesc; + + /** + * 文章标签 + */ + private List tagNameList; + + @NotBlank(message = "发布单位不能为空",groups = AddArticleForm.class) + private String publisher; + + @NotBlank(message = "发布单位名称不能为空",groups = AddArticleForm.class) + private String publisherName; + /** + * 发布单位类型 机关:agency;部门:department;网格:grid + */ + @NotBlank(message = "发布单位类型不能为空",groups = AddArticleForm.class) + private String publisherType; + + @NotBlank(message = "发布时间不能为空",groups = AddArticleForm.class) + private String publishDate; + + @NotBlank(message = "文章内容不能为空",groups = {AddArticleForm.class}) + private String content; + + /** + * 是否置顶 1是;0否; + */ + private Integer isTop = NumConstant.ZERO; + + private String userId; + + private String customerId; + + /** + * 草稿ID + */ + private String draftId; + + /** + * 封面图地址 + */ + private String imgUrl; +} 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 new file mode 100644 index 0000000000..0a601e9802 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/ArticleListFormDTO.java @@ -0,0 +1,60 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2021/7/15 4:34 下午 + * @DESC + */ +@Data +public class ArticleListFormDTO implements Serializable { + private static final long serialVersionUID = 6397877545890473794L; + + /** + * 文章标题 + */ + private String title; + /** + * 标签Id集合 + */ + private List tagIds; + /** + * 上下线状态,上线:published,下线:offline + */ + private String statusFlag; + /** + * 发布范围类型,组织:agency,网格:grid + */ + private String publishRangeType; + /** + * 发布范围Id==网格Id + */ + private String publishRangeId; + /** + * 开始日期 yyyy-MM-dd + */ + private String startDate; + /** + * 结束日期 yyyy-MM-dd + */ + private String endDate; + /** + * 页码 + */ + private Integer pageNo = 1; + /** + * 每页显示数量 + */ + private Integer pageSize = 20; + + private Boolean isPage = true; + private String articleId; + private String customerId; + private String agencyId; + private String staffId; + +} diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftListFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftListFormDTO.java index 02dd80d4df..51e659bdd0 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftListFormDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftListFormDTO.java @@ -12,12 +12,31 @@ import java.io.Serializable; @Data public class DraftListFormDTO implements Serializable { private static final long serialVersionUID = 7957826609741967502L; + + /** + * 文章标题 + */ + private String title; + /** + * 开始日期 yyyy-MM-dd + */ + private String startDate; + /** + * 结束日期 yyyy-MM-dd + */ + private String endDate; /** * 页码 */ - private Integer pageNo; + private Integer pageNo = 1; /** * 每页显示数量 */ - private Integer pageSize; + private Integer pageSize = 20; + + private Boolean isPage = true; + private String draftId; + private String customerId; + private String agencyId; + private String staffId; } diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/PublishGridListFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/PublishGridListFormDTO.java index a9ad61ecc6..3b35533d99 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/PublishGridListFormDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/PublishGridListFormDTO.java @@ -25,4 +25,8 @@ public class PublishGridListFormDTO implements Serializable { * token中人员Id */ private String staffId; + /** + * token中客户ID + */ + private String customerId; } 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 new file mode 100644 index 0000000000..2f14da3dc6 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftPcListResultDTO.java @@ -0,0 +1,128 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author sun + */ +@NoArgsConstructor +@Data +public class DraftPcListResultDTO implements Serializable { + + private static final long serialVersionUID = -8525181219822398750L; + /** + * 文章草稿ID + */ + private String draftId; + /** + * 组织Id + */ + private String agencyId; + /** + * 文章标题 + */ + private String title; + /** + * 是否置顶 1是;0否; + */ + private String isTop; + /** + * 是否置顶 1是;0否; + */ + private String isTopName; + /** + * 发布单位ID + */ + private String publisher; + /** + * 发布单位 + */ + private String publisherName; + /** + * 发布单位类型 机关:agency;部门:department;网格:grid + */ + private String publisherType; + /** + * 发布时间 + */ + private String publishDate; + /** + * 创建时间 + */ + private String createdTime; + /** + * 文章标签串 + */ + @JsonIgnore + private String tags; + /** + * 文章标签名列表 + */ + private List tagNameList; + /** + * 文章标签Id列表 + */ + private List tagIdList; + /** + * 概要内容 + */ + private String previewContent; + /** + * 上下线状态,上线:published,下线:offline + */ + private String statusFlag; + /** + * 是不是我发布 + */ + private Boolean isMePublished; + /** + * 发布范围 + */ + private String publishRangeDesc; + /** + * 1:是否富文本类型【】富文本;0:不是】 + */ + private String richTextFlag; + /** + * 文章创建人 + */ + private String createdBy; + /** + * 封面图片url + */ + private String imgUrl; + /** + * 发布范围网格Id集合 + */ + private List gridIdList; + /** + * 文章内容 + */ + private List contentList; + + @Data + public static class Content { + /** + * 内容 + */ + private String content; + /** + * 内容类型 图片:img;文字:text;文件:file;视频:video;富文本:rich_text + */ + private String contentType; + /** + * 文件名称 + */ + private String fileName; + /** + * 内容顺序 从1开始 + */ + private Integer orderNum; + } + +} 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 c566028269..e73acb6294 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 @@ -21,14 +21,34 @@ public class PublishedListResultDTO implements Serializable { * 文章ID */ private String articleId; + /** + * 组织Id + */ + private String agencyId; /** * 文章标题 */ private String title; + /** + * 是否置顶 1是;0否; + */ + private String isTop; + /** + * 是否置顶 1是;0否; + */ + private String isTopName; + /** + * 发布单位ID + */ + private String publisher; /** * 发布单位 */ private String publisherName; + /** + * 发布单位类型 机关:agency;部门:department;网格:grid + */ + private String publisherType; /** * 发布时间 */ @@ -39,11 +59,71 @@ public class PublishedListResultDTO implements Serializable { @JsonIgnore private String tags; /** - * 文章标签列表 + * 文章标签名列表 */ private List tagNameList; + /** + * 文章标签Id列表 + */ + private List tagIdList; /** * 概要内容 */ private String previewContent; + /** + * 上下线状态,上线:published,下线:offline + */ + private String statusFlag; + /** + * 上下线状态,已发布:published,已下线:offline + */ + private String statusFlagName; + /** + * 是不是我发布 + */ + private Boolean isMePublished; + /** + * 发布范围 + */ + private String publishRangeDesc; + /** + * 1:是否富文本类型【】富文本;0:不是】 + */ + private String richTextFlag; + /** + * 文章创建人 + */ + private String createdBy; + /** + * 封面图片url + */ + private String imgUrl; + /** + * 发布范围网格Id集合 + */ + private List gridIdList; + /** + * 文章内容 + */ + private List contentList; + + @Data + public static class Content { + /** + * 内容 + */ + private String content; + /** + * 内容类型 图片:img;文字:text;文件:file;视频:video;富文本:rich_text + */ + private String contentType; + /** + * 文件名称 + */ + private String fileName; + /** + * 内容顺序 从1开始 + */ + private Integer orderNum; + } } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/ArticleConstant.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/ArticleConstant.java index 65a7f54855..29d8bca111 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/ArticleConstant.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/ArticleConstant.java @@ -19,6 +19,8 @@ public interface ArticleConstant { * 发布状态-已发布 */ String PUBLISHED = "published"; + String PUBLISH = "publish"; + String PUBLISH_CONTENT = "发布文章"; /** * 发布状态-已下线 */ @@ -66,4 +68,12 @@ public interface ArticleConstant { * 发布方式 api审核后自动发布 */ String PUBLISH_WAY_AUTO_AUDIT = "autoAudit"; + + /** + * 未审核 + */ + String AUDIT_WAY_NO_AUDIT = "noAudit"; + + String SAVE_TYPE_ARTICLE = "article"; + String SAVE_TYPE_DRAFT = "draft"; } 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 4c7457f4c3..56b92b7d5c 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 @@ -21,11 +21,15 @@ import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.RequirePermission; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.enums.RequirePermissionEnum; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.scan.result.SyncScanResult; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.constant.ArticleConstant; import com.epmet.constant.DraftConstant; import com.epmet.dto.form.*; import com.epmet.dto.result.*; @@ -33,6 +37,7 @@ import com.epmet.service.ArticleOperateRecordService; import com.epmet.service.ArticleService; import com.epmet.service.DraftService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.web.bind.annotation.PostMapping; @@ -177,7 +182,7 @@ public class ArticleController { * @Description 党建声音-政府端-下线文章 **/ @PostMapping("offlinearticle") - @RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_OFFLINE) + //@RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_OFFLINE) public Result offLineArticle(@LoginUser TokenDto tokenDTO, @RequestBody OffLineArticleFormDTO formDTO) { formDTO.setStaffId(tokenDTO.getUserId()); ValidatorUtils.validateEntity(formDTO, OffLineArticleFormDTO.AddUserInternalGroup.class); @@ -346,6 +351,7 @@ public class ArticleController { **/ @PostMapping("publishgridlist") public Result publishGridList(@LoginUser TokenDto tokenDTO, @RequestBody PublishGridListFormDTO formDTO) { + formDTO.setCustomerId(tokenDTO.getCustomerId()); formDTO.setStaffId(tokenDTO.getUserId()); ValidatorUtils.validateEntity(formDTO, PublishGridListFormDTO.AddUserInternalGroup.class); ArticleAgencyGridListResultDTO agencyGridList = new ArticleAgencyGridListResultDTO(); @@ -405,4 +411,50 @@ public class ArticleController { return new Result>().ok(articleService.subjectList(formDTO)); } + /** + * @param tokenDTO + * @return + * @Author sun + * @Description 数字平台-党建声音-文章列表 + **/ + @PostMapping("articleListV2") + public Result> articleListV2(@LoginUser TokenDto tokenDTO, @RequestBody ArticleListFormDTO formDTO) { + formDTO.setCustomerId(tokenDTO.getCustomerId()); + formDTO.setStaffId(tokenDTO.getUserId()); + return new Result>().ok(articleService.articleListV2(formDTO)); + } + + /** + * @param tokenDTO + * @return + * @Author sun + * @Description 数字平台-党建声音-文章详情 + **/ + @PostMapping("detailV2") + public Result detailV2(@LoginUser TokenDto tokenDTO, @RequestBody ArticleListFormDTO formDTO) { + formDTO.setCustomerId(tokenDTO.getCustomerId()); + formDTO.setStaffId(tokenDTO.getUserId()); + return new Result().ok(articleService.detailV2(formDTO)); + } + + /** + * Desc: 发布文章/存草稿 + * @param formDTO + * @author zxc + * @date 2022/6/30 14:03 + */ + @PostMapping("addOrSaveDraft") + public Result addOrSaveDraft(@LoginUser TokenDto tokenDto,@RequestBody AddOrSaveDraftFormDTO formDTO){ + if (formDTO.getType().equals(ArticleConstant.SAVE_TYPE_ARTICLE)){ + ValidatorUtils.validateEntity(formDTO, AddOrSaveDraftFormDTO.AddArticleForm.class); + }else { + if (StringUtils.isBlank(formDTO.getTitle()) && StringUtils.isBlank(formDTO.getContent())){ + throw new EpmetException(EpmetErrorCode.TITLE_AND_CONTENT_ERROR.getCode()); + } + } + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + articleService.addOrSaveDraft(formDTO); + return new Result(); + } } 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 b7ffc4a382..6cf5a28000 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 @@ -20,15 +20,15 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.RequirePermission; import com.epmet.commons.tools.enums.RequirePermissionEnum; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.form.DeleteDraftFormDTO; -import com.epmet.dto.form.DraftDetailFormDTO; -import com.epmet.dto.form.DraftListFormDTO; -import com.epmet.dto.form.GovArticleDetailFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.DraftDetailResultDTO; import com.epmet.dto.result.DraftListResultDTO; +import com.epmet.dto.result.DraftPcListResultDTO; +import com.epmet.dto.result.PublishedListResultDTO; import com.epmet.service.DraftService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -86,4 +86,31 @@ public class DraftController { DraftDetailResultDTO draftDetailResultDTO = draftService.queryDraftDetail(formDTO); return new Result().ok(draftDetailResultDTO); } + + /** + * @param tokenDTO + * @return + * @Author sun + * @Description 数字平台-党建声音-草稿列表 + **/ + @PostMapping("draftListV2") + public Result> draftListV2(@LoginUser TokenDto tokenDTO, @RequestBody DraftListFormDTO formDTO) { + formDTO.setCustomerId(tokenDTO.getCustomerId()); + formDTO.setStaffId(tokenDTO.getUserId()); + return new Result>().ok(draftService.draftListV2(formDTO)); + } + + /** + * @param tokenDTO + * @return + * @Author sun + * @Description 数字平台-党建声音-草稿详情 + **/ + @PostMapping("detailV2") + public Result detailV2(@LoginUser TokenDto tokenDTO, @RequestBody DraftListFormDTO formDTO) { + formDTO.setCustomerId(tokenDTO.getCustomerId()); + formDTO.setStaffId(tokenDTO.getUserId()); + return new Result().ok(draftService.detailV2(formDTO)); + } + } \ No newline at end of file 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 79b63f91f6..2c19c2aa38 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 @@ -16,6 +16,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.annotation.DataFilter; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.ArticleListFormDTO; import com.epmet.dto.form.ResiTagListFormDTO; import com.epmet.dto.result.*; import com.epmet.entity.ArticleEntity; @@ -160,4 +161,6 @@ public interface ArticleDao extends BaseDao { * @date 2021/7/16 10:29 上午 */ List subjectList(@Param("pidList")List pidList); + + List selectAllArticle(ArticleListFormDTO formDTO); } 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 470ec938b6..0b5a30084a 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 @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.DraftListFormDTO; import com.epmet.dto.result.*; import com.epmet.entity.DraftEntity; import org.apache.ibatis.annotations.Mapper; @@ -112,4 +113,6 @@ public interface DraftDao extends BaseDao { * @return */ int updateAuditStatusById(@Param("draftId") String draftId, @Param("statusFlag") String statusFlag, @Param("titleAuditStatus") String titleAuditStatus); + + List selectAllDraft(DraftListFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticleContentEntity.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticleContentEntity.java index 29661c7350..f5d571ec75 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticleContentEntity.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticleContentEntity.java @@ -51,7 +51,7 @@ public class ArticleContentEntity extends BaseEpmetEntity { private String content; /** - * 内容类型 图片:img;文字:text;文件:file + * 内容类型 图片:img;文字:text;文件:file 富文本:rich_text */ private String contentType; diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticleEntity.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticleEntity.java index 13dc5bd83e..87a4c76078 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticleEntity.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticleEntity.java @@ -131,5 +131,9 @@ public class ArticleEntity extends BaseEpmetEntity { * 部门ID 数据权限使用 */ private String departmentId; + /** + * 1:富文本;0:不是 + */ + private String richTextFlag; } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/DraftContentEntity.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/DraftContentEntity.java index 15a7ba4e76..bf93f1b2c8 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/DraftContentEntity.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/DraftContentEntity.java @@ -51,7 +51,7 @@ public class DraftContentEntity extends BaseEpmetEntity { private String content; /** - * 内容类型 图片:img;文字:text;文件:file + * 内容类型 图片:img;文字:text;文件:file 富文本:rich_text */ private String contentType; diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/DraftEntity.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/DraftEntity.java index 04e1b22158..1c93cfc7cf 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/DraftEntity.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/DraftEntity.java @@ -117,4 +117,9 @@ public class DraftEntity extends BaseEpmetEntity { */ private String departmentId; + /** + * 1:富文本;0:不是 + */ + private String richTextFlag; + } 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 db03b3a0c5..127e7422ee 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 @@ -243,4 +243,16 @@ public interface ArticleService extends BaseService { * @return java.util.List */ List getArticleListByTag(String tagId, Integer pageNo, Integer pageSize); + + /** + * Desc: 发布文章/存草稿 + * @param formDTO + * @author zxc + * @date 2022/6/30 14:03 + */ + void addOrSaveDraft(AddOrSaveDraftFormDTO formDTO); + + PageData articleListV2(ArticleListFormDTO formDTO); + + PublishedListResultDTO detailV2(ArticleListFormDTO formDTO); } \ 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 a11c1361a3..f34898f749 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 @@ -27,6 +27,7 @@ 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.dto.result.DraftPcListResultDTO; import com.epmet.entity.DraftEntity; import java.util.List; @@ -148,4 +149,8 @@ public interface DraftService extends BaseService { * @date 2020-06-03 */ DraftDetailResultDTO queryDraftDetail(DraftDetailFormDTO formDTO); + + PageData draftListV2(DraftListFormDTO formDTO); + + DraftPcListResultDTO detailV2(DraftListFormDTO formDTO); } \ 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 e63c58590f..3a01001543 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,15 +18,22 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.scan.param.ImgScanParamDTO; import com.epmet.commons.tools.scan.param.ImgTaskDTO; import com.epmet.commons.tools.scan.param.TextScanParamDTO; @@ -41,10 +48,7 @@ import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.*; import com.epmet.dao.*; -import com.epmet.dto.ArticleVisitRecordDTO; -import com.epmet.dto.CustomerStaffDTO; -import com.epmet.dto.DraftCoverDTO; -import com.epmet.dto.DraftDTO; +import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.*; @@ -70,6 +74,8 @@ import org.springframework.util.CollectionUtils; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -122,6 +128,10 @@ public class ArticleServiceImpl extends BaseServiceImpl resultDTOResult = epmetUserOpenFeignClient.getLoginUserDetails(loginUserDetailsFormDTO); - String agencyId = resultDTOResult.getData().getOrgIdPath().substring(resultDTOResult.getData().getOrgIdPath().lastIndexOf(":") + NumConstant.ONE); + String agencyId = resultDTOResult.getData().getOrgIdPath().substring(resultDTOResult.getData().getOrgIdPath().lastIndexOf(":") + NumConstant.ONE);*/ + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + if (null == staffInfo) { + throw new EpmetException("获取工作人员信息失败"); + } + String agencyId = staffInfo.getAgencyId(); //存放树的每一个节点对象,用于将同一节点下的网格列表合并(主键:agencyId 值:节点对象) Map map = new HashMap<>(); //3:循环可下线网格列表,根据pids组织每一个树节点对象信息 @@ -1258,9 +1275,18 @@ public class ArticleServiceImpl extends BaseServiceImpl tagsInfo = formDto.getTagsInfo(); String customerId = formDto.getCustomerId(); //更新缓存标签使用数量 @@ -1314,13 +1341,20 @@ public class ArticleServiceImpl extends BaseServiceImpl tagsInfo = formDto.getTagsInfo(); String userId = tokenDto.getUserId(); //根据草稿id查询发布范围id集合 List gridIds = draftPublishRangeDao.selectGridIdByDraftId(draftId); if (gridIds.size() == NumConstant.ZERO) { throw new RenException(TagConstant.SELECT_GRIDIDLIST_FAILURE); } + return updateGridTagV2(formDto,customerId,gridIds,userId); + } + + public List updateGridTagV2(UpdateCustomerTagCacheDTO formDto,String customerId,List gridIds,String userId){ + if ( null == formDto || CollectionUtils.isEmpty(formDto.getTagsInfo()) || CollectionUtils.isEmpty(gridIds)){ + return new ArrayList<>(); + } + List tagsInfo = formDto.getTagsInfo(); List gridTags = new ArrayList<>(); List gridTagCache = new ArrayList<>(); gridIds.forEach(gridId -> { @@ -1348,6 +1382,9 @@ public class ArticleServiceImpl extends BaseServiceImpl gridTagCache) { + if (CollectionUtils.isEmpty(gridTagCache)){ + return; + } //更新 网格下 标签使用数量 List gridTagCacheCopy = new ArrayList<>(); gridTagCache.forEach(cacheDTO -> { @@ -1376,23 +1413,26 @@ public class ArticleServiceImpl extends BaseServiceImpl addArticleTags = new ArrayList<>(); - List tagsInfo = formDto.getTagsInfo(); DraftDTO draft = draftService.get(draftId); String customerId = draft.getCustomerId(); - String userId = tokenDto.getUserId(); String articleId = articleDao.getArticleIdByDraftId(draftId); + addArticleTagsV2(formDto,customerId,articleId); + } + + public void addArticleTagsV2(UpdateCustomerTagCacheDTO formDto,String customerId,String articleId){ + List articleTags = new ArrayList<>(); + + if (null == formDto || CollectionUtils.isEmpty(formDto.getTagsInfo())){ + return; + } + List tagsInfo = formDto.getTagsInfo(); tagsInfo.forEach(resultDTO -> { - AddArticleTagsFormDTO addArticleTag = new AddArticleTagsFormDTO(); - addArticleTag.setCreatedBy(userId); - addArticleTag.setUpdatedBy(userId); - addArticleTag.setCustomerId(customerId); - addArticleTag.setArticleId(articleId); - BeanUtils.copyProperties(resultDTO, addArticleTag); - addArticleTag.setCreatedTime(createdTime); - addArticleTags.add(addArticleTag); + ArticleTagsEntity e = ConvertUtils.sourceToTarget(resultDTO, ArticleTagsEntity.class); + e.setCustomerId(customerId); + e.setArticleId(articleId); + articleTags.add(e); }); - articleTagsDao.addArticleTags(addArticleTags); + articleTagsService.insertBatch(articleTags); } /** @@ -1449,4 +1489,290 @@ public class ArticleServiceImpl extends BaseServiceImpl getArticleListByTag(String tagId, Integer pageNo, Integer pageSize) { return baseDao.selectArticleListByTag(tagId, pageNo, pageSize); } + + /** + * Desc: 发布文章/存草稿 + * @param formDTO + * @author zxc + * @date 2022/6/30 14:03 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void addOrSaveDraft(AddOrSaveDraftFormDTO formDTO) { + if (StringUtils.isNotBlank(formDTO.getDraftId())){ + // 删除草稿,草稿内容,草稿发布范围,封面图 + draftDao.deleteDraft(formDTO.getDraftId()); + draftContentDao.deleteByDraftId(formDTO.getDraftId()); + draftPublishRangeDao.deleteByDraftId(formDTO.getDraftId()); + draftCoverDao.deleteByDraftId(formDTO.getDraftId()); + } + String customerId = formDTO.getCustomerId(); + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, formDTO.getUserId()); + if (null == staffInfo){ + throw new EpmetException("未查询到当前工作人员信息:"+formDTO.getUserId()); + } + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(staffInfo.getAgencyId()); + if (null == agencyInfo){ + throw new EpmetException("未查询到组织信息:"+staffInfo.getAgencyId()); + } + // 发文章 + if (formDTO.getType().equals(ArticleConstant.SAVE_TYPE_ARTICLE)){ + // 1.文章 + ArticleEntity article = ConvertUtils.sourceToTarget(formDTO, ArticleEntity.class); + // 按照之前逻辑存成客户ID + article.setDepartmentId(customerId); + article.setStatusFlag(DraftConstant.PUBLISHED); + article.setPublishWay(ArticleConstant.PUBLISH_WAY_MANUAL); + if (formDTO.getPublisherType().equals(DraftConstant.GRID)){ + article.setGridId(formDTO.getPublisher()); + } + article.setPreviewContent(getPreviewContent(formDTO.getContent()).length() > DraftConstant.PREVIEW_CONTENT_MAX_LENGTH ? getPreviewContent(formDTO.getContent()).substring(NumConstant.ZERO,DraftConstant.PREVIEW_CONTENT_MAX_LENGTH) : getPreviewContent(formDTO.getContent())); + article.setPublishDate(DateUtils.stringToDate(formDTO.getPublishDate(),DateUtils.DATE_PATTERN)); + article.setPublisherId(formDTO.getPublisher()); + article.setTags(CollectionUtils.isEmpty(formDTO.getTagNameList()) ? "" : formDTO.getTagNameList().stream().collect(Collectors.joining("|"))); + article.setOrgId(staffInfo.getAgencyId()); + article.setOrgIdPath(StringUtils.isBlank(agencyInfo.getPids()) || agencyInfo.getPids().equals(NumConstant.ZERO_STR) ? agencyInfo.getId() : agencyInfo.getPids().concat(":").concat(agencyInfo.getId())); + article.setRichTextFlag(NumConstant.ONE_STR); + baseDao.insert(article); + // 2.内容 + ArticleContentEntity articleContent = ConvertUtils.sourceToTarget(article, ArticleContentEntity.class); + articleContent.setCustomerId(customerId); + articleContent.setArticleId(article.getId()); + articleContent.setContent(formDTO.getContent()); + articleContent.setContentType("rich_text"); + articleContent.setOrderNum(NumConstant.ZERO); + articleContentDao.insert(articleContent); + // 3.操作记录 + ArticleOperateRecordEntity articleOperateRecord = new ArticleOperateRecordEntity(); + articleOperateRecord.setCustomerId(customerId); + articleOperateRecord.setArticleId(article.getId()); + articleOperateRecord.setGridIds(CollectionUtils.isEmpty(formDTO.getGridIdList()) ? "" : formDTO.getGridIdList().stream().collect(Collectors.joining(":"))); + articleOperateRecord.setOpUser(staffInfo.getAgencyName().concat("-").concat(staffInfo.getRealName())); + articleOperateRecord.setContent(articleOperateRecord.getOpUser() + "发布文章【" +formDTO.getTitle() + "】"); + articleOperateRecord.setOpType(ArticleConstant.PUBLISH); + articleOperateRecord.setOpTime(new Date()); + articleOperateRecordService.insert(articleOperateRecord); + // 4.发布范围 + if (!CollectionUtils.isEmpty(formDTO.getGridIdList())){ + List rangeList = new ArrayList<>(); + formDTO.getGridIdList().forEach(g -> { + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(g); + if (null == gridInfo){ + throw new EpmetException("未查询到网格信息:"+g); + } + ArticlePublishRangeEntity articlePublishRange = ConvertUtils.sourceToTarget(gridInfo,ArticlePublishRangeEntity.class); + articlePublishRange.setCustomerId(customerId); + articlePublishRange.setArticleId(article.getId()); + articlePublishRange.setGridId(g); + articlePublishRange.setAgencyGridName(gridInfo.getGridNamePath()); + articlePublishRange.setAgencyId(gridInfo.getPid()); + AgencyInfoCache info = CustomerOrgRedis.getAgencyInfo(gridInfo.getPid()); + if (null == info){ + throw new EpmetException("未查询到组织信息:"+gridInfo.getPid()); + } + articlePublishRange.setPids(info.getPids()); + articlePublishRange.setPublishStatus(ArticleConstant.PUBLISHED); + articlePublishRange.setId(null); + rangeList.add(articlePublishRange); + }); + articlePublishRangeService.insertBatch(rangeList); + } + // 5.文章标签 + UpdateCustomerTagCacheDTO updateCustomerTagCacheDTO = updateCustomerTagV2(formDTO.getUserId(), formDTO.getCustomerId(), StringUtils.isBlank(article.getTags()) ? "" : article.getTags()); + if (null != updateCustomerTagCacheDTO){ + addArticleTagsV2(updateCustomerTagCacheDTO,customerId,article.getId()); + } + // 6.更新网格tag + List updateGridTagCacheDTOS = updateGridTagV2(updateCustomerTagCacheDTO, customerId, formDTO.getGridIdList(), formDTO.getUserId()); + // 7.文章封面 + if (StringUtils.isNotBlank(formDTO.getImgUrl())){ + ArticleCoverEntity articleCover = new ArticleCoverEntity(); + articleCover.setCustomerId(customerId); + articleCover.setArticleId(article.getId()); + articleCover.setImgUrl(formDTO.getImgUrl()); + articleCover.setAuditStatus("pass"); + articleCoverDao.insert(articleCover); + } + // 8.更新redis + try { + this.updateCacheCustomerTag(updateCustomerTagCacheDTO); + this.updateCacheGridTag(updateGridTagCacheDTOS); + } catch (Exception e) { + log.error("scanAllPassPublishArticle update redis exception", e); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); + } + }else {// 存草稿 + // 1.草稿 + DraftEntity draft = ConvertUtils.sourceToTarget(formDTO, DraftEntity.class); + draft.setDepartmentId(customerId); + draft.setPreviewContent(StringUtils.isBlank(formDTO.getContent()) ? "" : getPreviewContent(formDTO.getContent()).length() > DraftConstant.PREVIEW_CONTENT_MAX_LENGTH ? getPreviewContent(formDTO.getContent()).substring(NumConstant.ZERO,DraftConstant.PREVIEW_CONTENT_MAX_LENGTH) : getPreviewContent(formDTO.getContent())); + draft.setPublisherId(StringUtils.isBlank(formDTO.getPublisher()) ? "" : formDTO.getPublisher()); + draft.setPublishDate(StringUtils.isBlank(formDTO.getPublishDate()) ? null : DateUtils.stringToDate(formDTO.getPublishDate(),DateUtils.DATE_PATTERN)); + draft.setTags(CollectionUtils.isEmpty(formDTO.getTagNameList()) ? "" : formDTO.getTagNameList().stream().collect(Collectors.joining("|"))); + draft.setOrgId(staffInfo.getAgencyId()); + draft.setOrgIdPath(StringUtils.isBlank(agencyInfo.getPids()) || agencyInfo.getPids().equals(NumConstant.ZERO_STR) ? agencyInfo.getId() : agencyInfo.getPids().concat(":").concat(agencyInfo.getId())); + if (formDTO.getPublisherType().equals(DraftConstant.GRID)){ + draft.setGridId(formDTO.getPublisher()); + } + draft.setStatusFlag(DraftConstant.UNPUBLISH); + draft.setRichTextFlag(NumConstant.ONE_STR); + draftDao.insert(draft); + // 2.内容 + if (StringUtils.isNotBlank(formDTO.getContent())){ + DraftContentEntity draftContent = ConvertUtils.sourceToTarget(draft, DraftContentEntity.class); + draftContent.setCustomerId(customerId); + draftContent.setDraftId(draft.getId()); + draftContent.setContent(formDTO.getContent()); + draftContent.setContentType("rich_text"); + draftContent.setOrderNum(NumConstant.ZERO); + draftContentDao.insert(draftContent); + } + // 3.发布范围 + if (!CollectionUtils.isEmpty(formDTO.getGridIdList())){ + List rangeList = new ArrayList<>(); + formDTO.getGridIdList().forEach(g -> { + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(g); + if (null == gridInfo){ + throw new EpmetException("未查询到网格信息:"+g); + } + DraftPublishRangeEntity draftPublishRange = ConvertUtils.sourceToTarget(gridInfo,DraftPublishRangeEntity.class); + draftPublishRange.setCustomerId(customerId); + draftPublishRange.setDraftId(draft.getId()); + draftPublishRange.setGridId(g); + draftPublishRange.setAgencyGridName(gridInfo.getGridNamePath()); + draftPublishRange.setAgencyId(gridInfo.getPid()); + AgencyInfoCache info = CustomerOrgRedis.getAgencyInfo(gridInfo.getPid()); + if (null == info){ + throw new EpmetException("未查询到组织信息:"+gridInfo.getPid()); + } + draftPublishRange.setPids(info.getPids()); + draftPublishRange.setPublishStatus(DraftConstant.UNPUBLISH); + draftPublishRange.setId(null); + rangeList.add(draftPublishRange); + }); + draftPublishRangeService.insertBatch(rangeList); + } + // 4.草稿封面 + if (StringUtils.isNotBlank(formDTO.getImgUrl())){ + DraftCoverEntity draftCover = new DraftCoverEntity(); + draftCover.setCustomerId(customerId); + draftCover.setDraftId(draft.getId()); + draftCover.setImgUrl(formDTO.getImgUrl()); + draftCover.setAuditStatus("pass"); + draftCoverDao.insert(draftCover); + } + } + } + + /** + * Desc: 获取内容中的汉字 + * @param content + * @author zxc + * @date 2022/7/1 10:32 + */ + public String getPreviewContent(String content) { + // 定义script的正则表达式 + String regEx_script = "]*?>[\\s\\S]*?<\\/script>"; + // 定义style的正则表达式 + String regEx_style = "]*?>[\\s\\S]*?<\\/style>"; + // 定义HTML标签的正则表达式 + String regEx_html = "<[^>]+>"; + //定义空格回车换行符 + String regEx_space = "\\s*|\t|\r|\n"; + Pattern p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE); + Matcher m_script = p_script.matcher(content); + // 过滤script标签 + content = m_script.replaceAll(""); + Pattern p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE); + Matcher m_style = p_style.matcher(content); + // 过滤style标签 + content = m_style.replaceAll(""); + Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE); + Matcher m_html = p_html.matcher(content); + // 过滤html标签 + content = m_html.replaceAll(""); + Pattern p_space = Pattern.compile(regEx_space, Pattern.CASE_INSENSITIVE); + Matcher m_space = p_space.matcher(content); + // 过滤空格回车标签 + content = m_space.replaceAll(""); + //去空格 + content = content.replaceAll(" ", ""); + return content.trim(); + } + + @Override + public PageData articleListV2(ArticleListFormDTO formDTO) { + //1.获取工作人员缓存信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + if (null == staffInfo) { + throw new EpmetException("获取工作人员信息失败"); + } + //查询当前组织及下级数据 + formDTO.setAgencyId(staffInfo.getAgencyId()); + //列表查询 + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()); + List list = baseDao.selectAllArticle(formDTO); + PageInfo pageInfo = new PageInfo<>(list); + + //封装数据 + if (!CollectionUtils.isEmpty(list)) { + list.forEach(l->{ + l.setTagNameList(StringUtils.isNotBlank(l.getTags())?Arrays.asList(l.getTags().split("[|]")):new ArrayList<>()); + l.setIsMePublished(l.getCreatedBy().equals(formDTO.getStaffId())?true:false); + }); + } + + return new PageData<>(list, pageInfo.getTotal()); + } + + @Override + public PublishedListResultDTO detailV2(ArticleListFormDTO formDTO) { + PublishedListResultDTO resultDTO = new PublishedListResultDTO(); + //1.查询文章主表信息 + List list = baseDao.selectAllArticle(formDTO); + + if (!CollectionUtils.isEmpty(list)) { + resultDTO = list.get(NumConstant.ZERO); + resultDTO.setTagNameList(StringUtils.isNotBlank(resultDTO.getTags())?Arrays.asList(resultDTO.getTags().split("[|]")):new ArrayList<>()); + resultDTO.setIsMePublished(resultDTO.getCreatedBy().equals(formDTO.getStaffId())?true:false); + //查询文章涉及的发布范围网络Id列表 + LambdaQueryWrapper tWrapper = new LambdaQueryWrapper<>(); + tWrapper.eq(ArticlePublishRangeEntity::getArticleId, formDTO.getArticleId()); + tWrapper.eq(ArticlePublishRangeEntity::getDelFlag, NumConstant.ZERO_STR); + //【文章下线的查所有发布范围,文章没下线的只查还没下线的发布范围】 + if("offline".equals(resultDTO.getStatusFlag())){ + tWrapper.eq(ArticlePublishRangeEntity::getPublishStatus, "offline"); + }else { + tWrapper.eq(ArticlePublishRangeEntity::getPublishStatus, "published"); + } + List entityList = articlePublishRangeDao.selectList(tWrapper); + if (!CollectionUtils.isEmpty(entityList)) { + List contentList = entityList.stream().map(ArticlePublishRangeEntity::getGridId).collect(Collectors.toList()); + resultDTO.setGridIdList(contentList); + } + + //查询文章内容 + LambdaQueryWrapper tWrapper1 = new LambdaQueryWrapper<>(); + tWrapper1.eq(ArticleContentEntity::getArticleId, formDTO.getArticleId()); + tWrapper1.eq(ArticleContentEntity::getDelFlag, NumConstant.ZERO_STR); + 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 tWrapper2 = new LambdaQueryWrapper<>(); + tWrapper2.eq(ArticleTagsEntity::getArticleId, formDTO.getArticleId()); + tWrapper2.eq(ArticleTagsEntity::getDelFlag, NumConstant.ZERO_STR); + List tagsEntityList = articleTagsDao.selectList(tWrapper2); + if (!CollectionUtils.isEmpty(tagsEntityList)) { + List contentList = tagsEntityList.stream().map(ArticleTagsEntity::getTagId).collect(Collectors.toList()); + resultDTO.setTagIdList(contentList); + } + } + + return resultDTO; + } } 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 c2f755e901..5d786be693 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 @@ -17,24 +17,26 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.DraftConstant; -import com.epmet.dao.DraftCoverDao; -import com.epmet.dao.DraftDao; +import com.epmet.dao.*; 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.*; -import com.epmet.entity.DraftCoverEntity; -import com.epmet.entity.DraftEntity; +import com.epmet.entity.*; import com.epmet.service.DraftService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -44,11 +46,13 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 草稿表 @@ -62,6 +66,13 @@ public class DraftServiceImpl extends BaseServiceImpl imp @Autowired private DraftCoverDao draftCoverDao; + @Autowired + private DraftPublishRangeDao draftPublishRangeDao; + @Autowired + private DraftContentDao draftContentDao; + @Autowired + private TagCustomerDao tagCustomerDao; + @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -201,4 +212,84 @@ public class DraftServiceImpl extends BaseServiceImpl imp return draftDetailResultDTO; } + @Override + public PageData draftListV2(DraftListFormDTO formDTO) { + //1.获取工作人员缓存信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + if (null == staffInfo) { + throw new EpmetException("获取工作人员信息失败"); + } + //查询当前组织及下级数据 + formDTO.setAgencyId(staffInfo.getAgencyId()); + //列表查询 + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()); + List list = baseDao.selectAllDraft(formDTO); + PageInfo pageInfo = new PageInfo<>(list); + + //封装数据 + if (!CollectionUtils.isEmpty(list)) { + list.forEach(l->{ + l.setTagNameList(StringUtils.isNotBlank(l.getTags())?Arrays.asList(l.getTags().split("[|]")):new ArrayList<>()); + l.setIsMePublished(l.getCreatedBy().equals(formDTO.getStaffId())?true:false); + }); + } + + return new PageData<>(list, pageInfo.getTotal()); + } + + @Override + public DraftPcListResultDTO detailV2(DraftListFormDTO formDTO) { + DraftPcListResultDTO resultDTO = new DraftPcListResultDTO(); + //1.查询文章主表信息 + List list = baseDao.selectAllDraft(formDTO); + + if (!CollectionUtils.isEmpty(list)) { + resultDTO = list.get(NumConstant.ZERO); + resultDTO.setTagNameList(StringUtils.isNotBlank(resultDTO.getTags())?Arrays.asList(resultDTO.getTags().split("[|]")):new ArrayList<>()); + resultDTO.setIsMePublished(resultDTO.getCreatedBy().equals(formDTO.getStaffId())?true:false); + //查询文章涉及的发布范围网络Id列表 + LambdaQueryWrapper tWrapper = new LambdaQueryWrapper<>(); + tWrapper.eq(DraftPublishRangeEntity::getDraftId, formDTO.getDraftId()); + tWrapper.eq(DraftPublishRangeEntity::getDelFlag, NumConstant.ZERO_STR); + //【文章下线的查所有发布范围,文章没下线的只查还没下线的发布范围】 + if("unpublish".equals(resultDTO.getStatusFlag())){ + tWrapper.eq(DraftPublishRangeEntity::getPublishStatus, "unpublish"); + }else { + tWrapper.eq(DraftPublishRangeEntity::getPublishStatus, "published"); + } + List entityList = draftPublishRangeDao.selectList(tWrapper); + if (!CollectionUtils.isEmpty(entityList)) { + List contentList = entityList.stream().map(DraftPublishRangeEntity::getGridId).collect(Collectors.toList()); + resultDTO.setGridIdList(contentList); + } + + //查询文章内容 + LambdaQueryWrapper tWrapper1 = new LambdaQueryWrapper<>(); + tWrapper1.eq(DraftContentEntity::getDraftId, formDTO.getDraftId()); + tWrapper1.eq(DraftContentEntity::getDelFlag, NumConstant.ZERO_STR); + tWrapper1.orderByDesc(DraftContentEntity::getOrderNum); + List contentEntityList = draftContentDao.selectList(tWrapper1); + if (!CollectionUtils.isEmpty(contentEntityList)) { + List contentList = ConvertUtils.sourceToTarget(contentEntityList, DraftPcListResultDTO.Content.class); + resultDTO.setContentList(contentList); + } + + //标签列表 + if(!CollectionUtils.isEmpty(resultDTO.getTagNameList())){ + LambdaQueryWrapper tWrapper2 = new LambdaQueryWrapper<>(); + tWrapper2.eq(TagCustomerEntity::getCustomerId, formDTO.getCustomerId()); + tWrapper2.in(TagCustomerEntity::getTagName, resultDTO.getTagNameList()); + tWrapper2.eq(TagCustomerEntity::getDelFlag, NumConstant.ZERO_STR); + List tagEntityList = tagCustomerDao.selectList(tWrapper2); + if (!CollectionUtils.isEmpty(tagEntityList)) { + List contentList = tagEntityList.stream().map(TagCustomerEntity::getId).collect(Collectors.toList()); + resultDTO.setTagIdList(contentList); + } + } + + } + + return resultDTO; + } + } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.10__alert_new_article_and_draft.sql b/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.10__alert_new_article_and_draft.sql new file mode 100644 index 0000000000..00d77ca9fe --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.10__alert_new_article_and_draft.sql @@ -0,0 +1,6 @@ +ALTER TABLE `draft` ADD COLUMN `RICH_TEXT_FLAG` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1:富文本;0:不是' AFTER `DEPARTMENT_ID`; +ALTER TABLE `draft_content` MODIFY COLUMN `CONTENT_TYPE` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '内容类型 图片:img;文字:text;文件:file;\r\n富文本:rich_text' AFTER `CONTENT`; +ALTER TABLE `article` ADD COLUMN `RICH_TEXT_FLAG` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1:富文本;0:不是' AFTER `DEPARTMENT_ID`; +ALTER TABLE `article_content` + MODIFY COLUMN `CONTENT` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '内容' AFTER `ARTICLE_ID`, + MODIFY COLUMN `CONTENT_TYPE` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '内容类型 图片:img;文字:text;文件:file;视频:video;富文本:rich_text' AFTER `CONTENT`; diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.11__alert_article_draft_id.sql b/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.11__alert_article_draft_id.sql new file mode 100644 index 0000000000..073cc6362f --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.11__alert_article_draft_id.sql @@ -0,0 +1 @@ +ALTER TABLE `article` MODIFY COLUMN `DRAFT_ID` varchar(64) NULL COMMENT '草稿ID'; \ 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 732bf2683a..94f7798cf8 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 @@ -25,8 +25,8 @@ + + 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 a6675ddb4e..bad753cd78 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 @@ -26,9 +26,9 @@ + + + update draft set DEL_FLAG='1' where id=#{draftId} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditInfoFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditInfoFormDTO.java index e8eb4249fa..7917113509 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditInfoFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditInfoFormDTO.java @@ -37,11 +37,13 @@ public class EditInfoFormDTO implements Serializable { * 姓 */ @NotBlank(message = "姓不能为空",groups = AddUserShowGroup.class) + @Length(max = 10,groups =AddUserShowGroup.class ,message = "姓不能超过10个字") private String surname; /** * 名 */ @NotBlank(message = "名不能为空",groups = AddUserShowGroup.class) + @Length(max = 10,groups =AddUserShowGroup.class ,message = "名不能超过10个字") private String name; //@NotBlank(message = "身份证号不能为空") diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java index 5970d78788..6785817934 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java @@ -378,6 +378,8 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -420,6 +422,7 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl