Browse Source

封面图

master
zxc 3 years ago
parent
commit
daf8115a0e
  1. 5
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddOrSaveDraftFormDTO.java
  2. 48
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java

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

@ -74,4 +74,9 @@ public class AddOrSaveDraftFormDTO implements Serializable {
* 草稿ID * 草稿ID
*/ */
private String draftId; private String draftId;
/**
* 封面图地址
*/
private String imgUrl;
} }

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

@ -78,6 +78,8 @@ import org.springframework.util.CollectionUtils;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -1491,10 +1493,11 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void addOrSaveDraft(AddOrSaveDraftFormDTO formDTO) { public void addOrSaveDraft(AddOrSaveDraftFormDTO formDTO) {
if (StringUtils.isNotBlank(formDTO.getDraftId())){ if (StringUtils.isNotBlank(formDTO.getDraftId())){
// 删除草稿,草稿内容,草稿发布范围 // 删除草稿,草稿内容,草稿发布范围,封面图
draftDao.deleteDraft(formDTO.getDraftId()); draftDao.deleteDraft(formDTO.getDraftId());
draftContentDao.deleteByDraftId(formDTO.getDraftId()); draftContentDao.deleteByDraftId(formDTO.getDraftId());
draftPublishRangeDao.deleteByDraftId(formDTO.getDraftId()); draftPublishRangeDao.deleteByDraftId(formDTO.getDraftId());
draftCoverDao.deleteByDraftId(formDTO.getDraftId());
} }
String customerId = formDTO.getCustomerId(); String customerId = formDTO.getCustomerId();
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, formDTO.getUserId()); CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, formDTO.getUserId());
@ -1517,13 +1520,14 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
article.setGridId(formDTO.getPublisher()); article.setGridId(formDTO.getPublisher());
} }
article.setTitleAuditStatus(ArticleConstant.AUDIT_WAY_NO_AUDIT); article.setTitleAuditStatus(ArticleConstant.AUDIT_WAY_NO_AUDIT);
article.setPreviewContent(formDTO.getContent().length() > DraftConstant.PREVIEW_CONTENT_MAX_LENGTH ? formDTO.getContent().substring(NumConstant.ZERO,DraftConstant.PREVIEW_CONTENT_MAX_LENGTH) : formDTO.getContent()); 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.setPublishDate(DateUtils.stringToDate(formDTO.getPublishDate(),DateUtils.DATE_PATTERN));
article.setPublisherId(formDTO.getPublisher()); article.setPublisherId(formDTO.getPublisher());
article.setPublishRangeDesc(CollectionUtils.isEmpty(formDTO.getPublishRangeDesc()) ? "" : formDTO.getPublishRangeDesc().stream().collect(Collectors.joining("、"))); article.setPublishRangeDesc(CollectionUtils.isEmpty(formDTO.getPublishRangeDesc()) ? "" : formDTO.getPublishRangeDesc().stream().collect(Collectors.joining("、")));
article.setTags(CollectionUtils.isEmpty(formDTO.getTagNameList()) ? "" : formDTO.getTagNameList().stream().collect(Collectors.joining("|"))); article.setTags(CollectionUtils.isEmpty(formDTO.getTagNameList()) ? "" : formDTO.getTagNameList().stream().collect(Collectors.joining("|")));
article.setOrgId(staffInfo.getAgencyId()); 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.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); baseDao.insert(article);
// 2.内容 // 2.内容
ArticleContentEntity articleContent = ConvertUtils.sourceToTarget(article, ArticleContentEntity.class); ArticleContentEntity articleContent = ConvertUtils.sourceToTarget(article, ArticleContentEntity.class);
@ -1569,7 +1573,15 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
addArticleTagsV2(updateCustomerTagCacheDTO,customerId,article.getId()); addArticleTagsV2(updateCustomerTagCacheDTO,customerId,article.getId());
// 6.更新网格tag // 6.更新网格tag
List<UpdateGridTagCacheDTO> updateGridTagCacheDTOS = updateGridTagV2(updateCustomerTagCacheDTO, customerId, formDTO.getGridIdList(), formDTO.getUserId()); List<UpdateGridTagCacheDTO> updateGridTagCacheDTOS = updateGridTagV2(updateCustomerTagCacheDTO, customerId, formDTO.getGridIdList(), formDTO.getUserId());
// 7.更新redis // 7.文章封面
if (StringUtils.isNotBlank(formDTO.getImgUrl())){
ArticleCoverEntity articleCover = new ArticleCoverEntity();
articleCover.setCustomerId(customerId);
articleCover.setArticleId(article.getId());
articleCover.setImgUrl(formDTO.getImgUrl());
articleCoverDao.insert(articleCover);
}
// 8.更新redis
try { try {
this.updateCacheCustomerTag(updateCustomerTagCacheDTO); this.updateCacheCustomerTag(updateCustomerTagCacheDTO);
this.updateCacheGridTag(updateGridTagCacheDTOS); this.updateCacheGridTag(updateGridTagCacheDTOS);
@ -1582,7 +1594,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
DraftEntity draft = ConvertUtils.sourceToTarget(formDTO, DraftEntity.class); DraftEntity draft = ConvertUtils.sourceToTarget(formDTO, DraftEntity.class);
draft.setDepartmentId(customerId); draft.setDepartmentId(customerId);
draft.setTitleAuditStatus(ArticleConstant.AUDIT_WAY_NO_AUDIT); draft.setTitleAuditStatus(ArticleConstant.AUDIT_WAY_NO_AUDIT);
draft.setPreviewContent(formDTO.getContent().length() > DraftConstant.PREVIEW_CONTENT_MAX_LENGTH ? formDTO.getContent().substring(NumConstant.ZERO,DraftConstant.PREVIEW_CONTENT_MAX_LENGTH) : formDTO.getContent()); 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.setPublishRangeDesc(CollectionUtils.isEmpty(formDTO.getPublishRangeDesc()) ? "" : formDTO.getPublishRangeDesc().stream().collect(Collectors.joining("、"))); draft.setPublishRangeDesc(CollectionUtils.isEmpty(formDTO.getPublishRangeDesc()) ? "" : formDTO.getPublishRangeDesc().stream().collect(Collectors.joining("、")));
draft.setPublisherId(formDTO.getPublisher()); draft.setPublisherId(formDTO.getPublisher());
draft.setPublishDate(DateUtils.stringToDate(formDTO.getPublishDate(),DateUtils.DATE_PATTERN)); draft.setPublishDate(DateUtils.stringToDate(formDTO.getPublishDate(),DateUtils.DATE_PATTERN));
@ -1593,6 +1605,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
draft.setGridId(formDTO.getPublisher()); draft.setGridId(formDTO.getPublisher());
} }
draft.setStatusFlag(DraftConstant.UNPUBLISH); draft.setStatusFlag(DraftConstant.UNPUBLISH);
draft.setRichTextFlag(NumConstant.ONE_STR);
draftDao.insert(draft); draftDao.insert(draft);
// 2.内容 // 2.内容
DraftContentEntity draftContent = ConvertUtils.sourceToTarget(draft, DraftContentEntity.class); DraftContentEntity draftContent = ConvertUtils.sourceToTarget(draft, DraftContentEntity.class);
@ -1623,9 +1636,36 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
}); });
draftPublishRangeService.insertBatch(rangeList); draftPublishRangeService.insertBatch(rangeList);
} }
// 4.草稿封面
if (StringUtils.isNotBlank(formDTO.getImgUrl())){
DraftCoverEntity draftCover = new DraftCoverEntity();
draftCover.setCustomerId(customerId);
draftCover.setDraftId(draft.getId());
draftCover.setImgUrl(formDTO.getImgUrl());
draftCoverDao.insert(draftCover);
}
} }
} }
/**
* Desc: 获取内容中的汉字
* @param content
* @author zxc
* @date 2022/7/1 10:32
*/
public static String getPreviewContent(String content) {
if (StringUtils.isBlank(content)){
return "";
}
String regex = "[\\u4e00-\\u9fa5]";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(content);
StringBuffer sb = new StringBuffer();
while (m.find()) {
sb.append(m.group());
}
return sb.toString();
}
@Override @Override
public PageData<PublishedListResultDTO> articleListV2(ArticleListFormDTO formDTO) { public PageData<PublishedListResultDTO> articleListV2(ArticleListFormDTO formDTO) {

Loading…
Cancel
Save