Browse Source

草稿微调

master
zxc 3 years ago
parent
commit
8c52b40e1a
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 20
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddOrSaveDraftFormDTO.java
  3. 12
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java
  4. 22
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java

1
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所需参数"),

20
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddOrSaveDraftFormDTO.java

@ -1,5 +1,6 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
@ -17,15 +18,16 @@ import java.util.List;
@Data
public class AddOrSaveDraftFormDTO implements Serializable {
public interface AddOrSaveDraftForm{}
public interface AddArticleForm{}
public interface AddDraftForm{}
/**
* 类型 发布文章article存草稿draft
*/
@NotBlank(message = "类型不能为空",groups = AddOrSaveDraftForm.class)
@NotBlank(message = "类型不能为空",groups = AddArticleForm.class)
private String type;
@NotBlank(message = "标题不能为空",groups = AddOrSaveDraftForm.class)
@NotBlank(message = "标题不能为空",groups = {AddArticleForm.class})
@Length(max = 50, message = "标题最长为50个字")
private String title;
@ -44,27 +46,27 @@ public class AddOrSaveDraftFormDTO implements Serializable {
*/
private List<String> tagNameList;
@NotBlank(message = "发布单位不能为空",groups = AddOrSaveDraftForm.class)
@NotBlank(message = "发布单位不能为空",groups = AddArticleForm.class)
private String publisher;
@NotBlank(message = "发布单位名称不能为空",groups = AddOrSaveDraftForm.class)
@NotBlank(message = "发布单位名称不能为空",groups = AddArticleForm.class)
private String publisherName;
/**
* 发布单位类型 机关:agency部门department网格grid
*/
@NotBlank(message = "发布单位类型不能为空",groups = AddOrSaveDraftForm.class)
@NotBlank(message = "发布单位类型不能为空",groups = AddArticleForm.class)
private String publisherType;
@NotBlank(message = "发布时间不能为空",groups = AddOrSaveDraftForm.class)
@NotBlank(message = "发布时间不能为空",groups = AddArticleForm.class)
private String publishDate;
@NotBlank(message = "文章内容不能为空",groups = AddOrSaveDraftForm.class)
@NotBlank(message = "文章内容不能为空",groups = {AddArticleForm.class})
private String content;
/**
* 是否置顶 1是0否
*/
private Integer isTop;
private Integer isTop = NumConstant.ZERO;
private String userId;

12
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java

@ -21,12 +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.*;
@ -34,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;
@ -440,7 +444,13 @@ public class ArticleController {
*/
@PostMapping("addOrSaveDraft")
public Result addOrSaveDraft(@LoginUser TokenDto tokenDto,@RequestBody AddOrSaveDraftFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, AddOrSaveDraftFormDTO.AddOrSaveDraftForm.class);
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);

22
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java

@ -1587,10 +1587,10 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
// 1.草稿
DraftEntity draft = ConvertUtils.sourceToTarget(formDTO, DraftEntity.class);
draft.setDepartmentId(customerId);
draft.setPreviewContent(getPreviewContent(formDTO.getContent()).length() > DraftConstant.PREVIEW_CONTENT_MAX_LENGTH ? getPreviewContent(formDTO.getContent()).substring(NumConstant.ZERO,DraftConstant.PREVIEW_CONTENT_MAX_LENGTH) : getPreviewContent(formDTO.getContent()));
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.setPublishRangeDesc(CollectionUtils.isEmpty(formDTO.getPublishRangeDesc()) ? "" : formDTO.getPublishRangeDesc().stream().collect(Collectors.joining("、")));
draft.setPublisherId(formDTO.getPublisher());
draft.setPublishDate(DateUtils.stringToDate(formDTO.getPublishDate(),DateUtils.DATE_PATTERN));
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()));
@ -1601,13 +1601,15 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
draft.setRichTextFlag(NumConstant.ONE_STR);
draftDao.insert(draft);
// 2.内容
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);
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<DraftPublishRangeEntity> rangeList = new ArrayList<>();

Loading…
Cancel
Save