Browse Source

创建文章提示调整

dev
= 5 years ago
parent
commit
e572285a15
  1. 5
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java
  2. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  3. 6
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftAttrFromDTO.java
  4. 4
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftContentFromDTO.java
  5. 93
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java
  6. 35
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/utils/ModuleConstant.java

5
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java

@ -43,4 +43,9 @@ public interface StrConstant {
* 冒号
*/
String COLON = ":";
/**
* 中文顿号
*/
String COMMA_ZH = "、";
}

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -67,6 +67,8 @@ public enum EpmetErrorCode {
OPER_UPLOAD_FILE_OVER_SIZE(8707, "文件体积过大"),
OPER_UPLOAD_FILE_TYPE_ERROR(8708, "文件类型错误"),
// 党建声音 前端提示 88段
DRAFT_CONTENT_IS_NULL(8801, "至少需要添加一个段落"),
ARTICLE_PUBLISH_ERROR(8801, "发布文章失败,请刷新重试"),
CUSTOMER_VALIDATE_ERROR(8999, "内部数据校验异常");

6
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftAttrFromDTO.java

@ -20,6 +20,7 @@ package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
@ -34,7 +35,6 @@ import java.util.List;
@Data
public class DraftAttrFromDTO implements Serializable {
private static final long serialVersionUID = 6463906402283515172L;
/**
* 草稿ID
@ -61,11 +61,13 @@ public class DraftAttrFromDTO implements Serializable {
/**
* 网格Id数组
*/
@NotEmpty(message = "发布范围不能为空")
private List<String> gridIdList;
/**
* 发布单位Id 类型不同 id含义不同
*/
@NotBlank(message = "发布单位不能为空")
private String publisher;
/**
@ -76,7 +78,7 @@ public class DraftAttrFromDTO implements Serializable {
/**
* 发布日期
*/
@NotBlank(message = "发布日期不能为空")
@NotBlank(message = "发布时间不能为空")
private String publishDate;
/**

4
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftContentFromDTO.java

@ -44,13 +44,13 @@ public class DraftContentFromDTO implements Serializable {
/**
* 文章标题
*/
@NotBlank(message = "文章标题不能为空")
@NotBlank(message = "请输入标题")
private String title;
/**
* 内容列表
*/
@NotEmpty(message = "文章内容不能为空")
@NotEmpty(message = "至少添加一个段落")
private List<DraftContentDTO> contentList;
@Data

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

@ -56,6 +56,7 @@ import com.epmet.service.*;
import com.epmet.utils.ModuleConstant;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sun.javafx.binding.StringConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.helper.StringUtil;
@ -67,6 +68,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.swing.text.StringContent;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@ -173,12 +175,6 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
log.debug("saveOrUpdateContent param:{}", JSON.toJSONString(fromDTO));
if (required) {
ValidatorUtils.validateEntity(fromDTO);
if (StringUtils.isBlank(fromDTO.getTitle())){
throw new RenException(ModuleConstant.ARTICLE_TITLE_IS_NULL);
}
if (CollectionUtils.isEmpty(fromDTO.getContentList())){
throw new RenException(ModuleConstant.ARTICLE_CONTENT_IS_NULL);
}
}
DraftEntity draftEntity = null;
@ -196,7 +192,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
Result<LoginUserDetailsResultDTO> loginUserDetails = epmetUserOpenFeignClient.getLoginUserDetails(detailsFormDTO);
if (loginUserDetails == null || loginUserDetails.getData() == null) {
log.warn("saveOrUpdateContent getloginUserDetails return null");
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), ModuleConstant.GET_USER_DETAIL_ERROR);
}
draftEntity = new DraftEntity();
draftEntity.setTitle(fromDTO.getTitle());
@ -287,23 +283,18 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
draftEntity.setIsTop(fromDTO.getIsTop());
//发布单位
if (StringUtils.isNotBlank(fromDTO.getPublisher())){
String publisherType = fromDTO.getPublisherType();
String publisherName = fromDTO.getPublisherName();
if (StringUtils.isBlank(publisherType) || StringUtils.isBlank(publisherName)) {
log.warn("saveDraftAttr publisher info is illegal,publisher:{},publisherType:{},publisherName:{}",fromDTO.getPublisher(),publisherType,publisherName);
throw new RenException("发布单位不能为空");
}
}
draftEntity.setPublisherName(fromDTO.getPublisherName());
draftEntity.setPublisherId(fromDTO.getPublisher());
draftEntity.setPublisherType(fromDTO.getPublisherType());
//TODO ? 如果为机关 不设置?
if(DraftConstant.GRID.equals(fromDTO.getPublisherType())) {
draftEntity.setGridId(fromDTO.getPublisher());
}
draftEntity.setPublishDate(DateUtils.stringToDate(fromDTO.getPublishDate(),DateUtils.DATE_PATTERN));
if (StringUtils.isNotBlank(fromDTO.getPublishDate())){
draftEntity.setPublishDate(DateUtils.stringToDate(fromDTO.getPublishDate(),DateUtils.DATE_PATTERN));
}
//封面
DraftCoverEntity coverEntity = buildCoverEntity(tokenDto, fromDTO);
@ -319,16 +310,16 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
DraftEntity draftEntity = draftDao.selectById(draftId);
if (draftEntity == null) {
log.warn("saveDraftAttr draftId:{} is not exist in db",draftId);
throw new RenException("参数错误");
throw new RenException(ModuleConstant.DRAFT_ID_IS_NOT_EXIST);
}
if (NumConstant.ONE_STR.equals(draftEntity.getDelFlag())) {
log.warn("saveDraftAttr draftId:{} have deleted",draftId);
throw new RenException("草稿已删除");
throw new RenException(ModuleConstant.DRAFT_STATUS_IS_DEL);
}
//只有为发布的才能保存修改
//只有未发布的和审核失败的才能修改
if (DraftConstant.AUDITING.equals(draftEntity.getStatusFlag()) || DraftConstant.PUBLISHED.equals(draftEntity.getStatusFlag())) {
log.warn("saveDraftAttr draftId:{} publishStatus have published",draftId);
throw new RenException("草稿发布状态错误");
throw new RenException(ModuleConstant.DRAFT_STATUS_IS_NOT_ALLOW_MODIFY);
}
return draftEntity;
}
@ -336,23 +327,21 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
@Override
public Boolean previewSaveDraftAttr(TokenDto tokenDto, DraftAttrFromDTO fromDTO) {
//校验参数
ValidatorUtils.validateEntity(fromDTO);
if (DraftConstant.TOP.equals(fromDTO.getIsTop()) && StringUtils.isBlank(fromDTO.getCoverImg())) {
log.warn("saveOrUpdateAttr isTop=1 but coverImg is blank");
throw new RenException("文章封面不能为空");
throw new RenException(ModuleConstant.DRAFT_CONTENT_IS_NULL);
}
if (CollectionUtils.isEmpty(fromDTO.getGridIdList())) {
log.warn("saveOrUpdateAttr gridIdList is empty");
throw new RenException("发布范围不能为空");
if (StringUtils.isBlank(fromDTO.getPublisherName()) || StringUtils.isBlank(fromDTO.getPublisherType())) {
throw new RenException(ModuleConstant.DRAFT_PUBLISHER_IS_NULL);
}
if (StringUtils.isBlank(fromDTO.getPublisher())) {
log.warn("saveOrUpdateAttr publisher is blank");
throw new RenException("发布单位不能为空");
if (fromDTO.getIsTop() == null || fromDTO.getIsTop() > 1 || fromDTO.getIsTop() < 0) {
throw new RenException(ModuleConstant.DRAFT_IS_TOP_ERROR);
}
if (StringUtils.isBlank(fromDTO.getPublishDate())) {
log.warn("saveOrUpdateAttr publishDate is blank");
throw new RenException("发布时间不能为空");
if ( fromDTO.getPublisherType() != DraftConstant.AGENCY && fromDTO.getPublisherType() != DraftConstant.DEPARTMENT
&&fromDTO.getPublisherType() != DraftConstant.GRID) {
throw new RenException(ModuleConstant.DRAFT_PUBLISHER_TYPE_ERROR);
}
return saveDraftAttr(tokenDto, fromDTO);
}
@ -361,7 +350,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
public Boolean publish(TokenDto tokenDto, String draftId) {
if (StringUtils.isBlank(draftId)){
log.warn("publish param error draftId is blank");
throw new RenException("草稿Id不能为空");
throw new RenException(ModuleConstant.DRAFT_ID_IS_NULL);
}
DraftEntity draftEntity = checkDraftStatus(draftId);
draftEntity.setStatusFlag(DraftConstant.AUDITING);
@ -395,11 +384,11 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
ArticleGridResultDTO articleGridResultDTO = this.agencyGridList(tokenDto);
if (articleGridResultDTO == null) {
log.warn("saveDraftAttr userId:{} have not right access publishRange", tokenDto.getUserId());
throw new RenException("参数错误");
throw new RenException(ModuleConstant.GET_USER_CAN_SELECT_GRID_ERROR);
}
buildName(tokenDto,agencyGridNameList,publishRangeEntityList, fromDTO, articleGridResultDTO);
buildAgencyGridNames(tokenDto,agencyGridNameList,publishRangeEntityList, fromDTO, articleGridResultDTO);
draftEntity.setPublishRangeDesc(StringUtils.join(agencyGridNameList,"、"));
draftEntity.setPublishRangeDesc(StringUtils.join(agencyGridNameList, StrConstant.COMMA_ZH));
return publishRangeEntityList;
}
@ -436,7 +425,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
if (!CollectionUtils.isEmpty(gridList)&&!CollectionUtils.isEmpty(gridIdList)) {
gridList.forEach(grid -> {
if (gridIdList.contains(grid.getGridId())) {
String agencyGridName = articleGridResultDTO.getAgencyName().concat("-").concat(grid.getGridName());
String agencyGridName = articleGridResultDTO.getAgencyName().concat(StrConstant.HYPHEN).concat(grid.getGridName());
agencyGridNameList.add(agencyGridName);
DraftPublishRangeEntity draftPublishRangeEntity = new DraftPublishRangeEntity();
draftPublishRangeEntity.setCustomerId(tokenDto.getCustomerId());
@ -471,19 +460,17 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
List<DraftContentEntity> newContentList = new ArrayList<>();
for (int i = 0; i < contentList.size(); i++) {
for (int i = NumConstant.ZERO; i < contentList.size(); i++) {
DraftContentFromDTO.DraftContentDTO content = contentList.get(i);
DraftContentEntity entity = ConvertUtils.sourceToTarget(content, DraftContentEntity.class);
entity.setId(content.getDraftContentId());
entity.setCustomerId(tokenDto.getCustomerId());
entity.setDraftId(fromDTO.getDraftId());
entity.setOrderNum(i + 1);
//默认通过
entity.setOrderNum(i + NumConstant.ONE);
//默认为空
entity.setAuditStatus("");
newContentList.add(entity);
}
return newContentList;
}
@ -543,16 +530,16 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
ArticleEntity entity = new ArticleEntity();
entity.setId(formDTO.getArticleId());
StringBuffer publishRangeDesc = new StringBuffer();
if (null == publishedList || publishedList.size() < NumConstant.ONE) {
if (CollectionUtils.isEmpty(publishedList)) {
entity.setStatusFlag(ArticleConstant.OFFLINE);
entity.setOffLineTime(date);
rangeEntityList.forEach(range -> {
publishRangeDesc.append(publishRangeDesc.length() > NumConstant.ZERO ? "、" : "");
publishRangeDesc.append(publishRangeDesc.length() > NumConstant.ZERO ? StrConstant.COMMA_ZH : "");
publishRangeDesc.append(range.getAgencyGridName());
});
} else {
publishedList.forEach(pub -> {
publishRangeDesc.append(publishRangeDesc.length() > NumConstant.ZERO ? "、" : "");
publishRangeDesc.append(publishRangeDesc.length() > NumConstant.ZERO ? StrConstant.COMMA_ZH : "");
publishRangeDesc.append(pub.getAgencyGridName());
});
}
@ -566,7 +553,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
ArticleOperateRecordEntity recordEntity = new ArticleOperateRecordEntity();
recordEntity.setCustomerId(articleEntity.getCustomerId());
recordEntity.setArticleId(formDTO.getArticleId());
recordEntity.setOpUser(articleEntity.getPublisherName() + "-" + staffDTO.getRealName());
recordEntity.setOpUser(articleEntity.getPublisherName() + StrConstant.HYPHEN + staffDTO.getRealName());
//下线文案,分为全部下线和部分下线
String content = "";
if (null == publishedList || publishedList.size() < NumConstant.ONE) {
@ -574,7 +561,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
} else {
StringBuffer offLineRangeDesc = new StringBuffer();
offLineList.forEach(off -> {
offLineRangeDesc.append(offLineRangeDesc.length() > NumConstant.ZERO ? "、" : "");
offLineRangeDesc.append(offLineRangeDesc.length() > NumConstant.ZERO ? StrConstant.COMMA_ZH : "");
offLineRangeDesc.append(off.getAgencyGridName());
});
content = String.format(ArticleConstant.OFF_LINE_ARTICLE_MSG, articleEntity.getPublisherName(), staffDTO.getRealName(), articleEntity.getTitle(), offLineRangeDesc);
@ -721,9 +708,9 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
//当前网格的所有机关id
String gridPids = range.getPids() + ":" + range.getAgencyId();
//当前网格的所有机关名称
String gridAgencyNames = range.getAllParentName() + "-" + range.getAgencyGridName().substring(NumConstant.ZERO, range.getAgencyGridName().lastIndexOf("-"));
String gridAgencyNames = range.getAllParentName() + StrConstant.HYPHEN + range.getAgencyGridName().substring(NumConstant.ZERO, range.getAgencyGridName().lastIndexOf(StrConstant.HYPHEN));
String[] pids = gridPids.split(":");
String[] names = gridAgencyNames.split("-");
String[] names = gridAgencyNames.split(StrConstant.HYPHEN);
//倒序遍历
for (int i = (pids.length - NumConstant.ONE); i >= NumConstant.ZERO; i--) {
//遍历到当前人员所属组织的上一级组织时停止遍历
@ -742,7 +729,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
List<AgencyGridListResultDTO> gridList = new ArrayList<>();
AgencyGridListResultDTO gridDto = new AgencyGridListResultDTO();
gridDto.setGridId(range.getGridId());
gridDto.setGridName(range.getAgencyGridName().substring(range.getAgencyGridName().lastIndexOf("-") + NumConstant.ONE));
gridDto.setGridName(range.getAgencyGridName().substring(range.getAgencyGridName().lastIndexOf(StrConstant.HYPHEN) + NumConstant.ONE));
gridList.add(gridDto);
dto.setGridList(gridList);
}
@ -753,7 +740,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
List<AgencyGridListResultDTO> gridList = dto1.getGridList();
AgencyGridListResultDTO gridDto = new AgencyGridListResultDTO();
gridDto.setGridId(range.getGridId());
gridDto.setGridName(range.getAgencyGridName().substring(range.getAgencyGridName().lastIndexOf("-") + NumConstant.ONE));
gridDto.setGridName(range.getAgencyGridName().substring(range.getAgencyGridName().lastIndexOf(StrConstant.HYPHEN) + NumConstant.ONE));
gridList.add(gridDto);
dto1.setGridList(gridList);
map.put(pids[i], dto1);
@ -1099,11 +1086,11 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
if (coverFail || contentFail){
String auditMsg = "";
if (coverFail&&contentFail){
auditMsg = "内容和封面";
auditMsg = ModuleConstant.DRAFT_CONTENT_AND_COVER;
}else if (contentFail){
auditMsg = "内容";
auditMsg = ModuleConstant.DRAFT_CONTENT;
}else if (coverFail){
auditMsg = "封面";
auditMsg = ModuleConstant.DRAFT_COVER;;
}
this.sendMsg(draft.getCustomerId(), draft.getTitle(), String.format(ModuleConstant.MSG_AUDIT_CONTENT, draft.getTitle(),auditMsg));
}

35
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/utils/ModuleConstant.java

@ -90,13 +90,40 @@ public interface ModuleConstant {
String MSG_ARTICLE_PUBLISH_ERROR = "您好,你发布的【%s】文章由于网络错误未发布成功,请重新发布,谢谢。";
/**
* 文章内容不能为空
* 草稿Id不存在
* */
String ARTICLE_CONTENT_IS_NULL = "文章内容不能为空";
String DRAFT_ID_IS_NOT_EXIST = "草稿ID不存在";
/**
* 文章标题不能为空
* 草稿已删除
* */
String ARTICLE_TITLE_IS_NULL = "文章标题不能为空";
String DRAFT_STATUS_IS_DEL = "草稿已删除";
String GET_USER_DETAIL_ERROR = "获取用户详情失败";
String GET_USER_CAN_SELECT_GRID_ERROR = "获取用户可选网格失败";
String DRAFT_STATUS_IS_NOT_ALLOW_MODIFY = "草稿状态不允许修改";
String DRAFT_PUBLISHER_IS_NULL = "发布单位不能为空";
String DRAFT_PUBLISHER_TYPE_ERROR = "发布单位类型不合法";
String DRAFT_PUBLISH_RANGE_IS_NULL = "发布范围不能为空";
String DRAFT_PUBLISH_DATE_IS_NULL = "发布时间不能为空";
String DRAFT_ID_IS_NULL = "草稿ID不能为空";
String DRAFT_CONTENT_AND_COVER = "内容和封面";
String DRAFT_CONTENT = "内容";
String DRAFT_COVER = "封面";
String DRAFT_CONTENT_IS_NULL = "文章封面不能为空";
String DRAFT_IS_TOP_ERROR = "是否置顶参数不合法";
}

Loading…
Cancel
Save