Browse Source

党建声音 人工发布功能相关接口

dev_shibei_match
jianjun 5 years ago
parent
commit
8d76f18e54
  1. 5
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftDetailFormDTO.java
  2. 5
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftDetailResultDTO.java
  3. 5
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftListResultDTO.java
  4. 5
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/GovDraftContentDTO.java
  5. 10
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/ArticleConstant.java
  6. 38
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java
  7. 16
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/DraftController.java
  8. 5
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticleEntity.java
  9. 8
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java
  10. 40
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java
  11. 14
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/DraftServiceImpl.java
  12. 2
      epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.2__addAutoPublish.sql
  13. 8
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftDao.xml

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

@ -22,4 +22,9 @@ public class DraftDetailFormDTO implements Serializable {
*/
@NotBlank(message = "草稿id不能为空", groups = {DraftDetailFormDTO.AddUserInternalGroup.class})
private String draftId;
/**
* 是否展示封面
*/
private boolean showCover;
}

5
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftDetailResultDTO.java

@ -59,4 +59,9 @@ public class DraftDetailResultDTO implements Serializable {
* 标签名称数组
*/
private String[] tagNameList;
/**
* 封面信息
*/
private CoverImgDTO coverInfo;
}

5
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftListResultDTO.java

@ -31,4 +31,9 @@ public class DraftListResultDTO implements Serializable {
* 创建时间
*/
private Long createdTime;
/**
* 审核状态
*/
private String auditStatus;
}

5
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/GovDraftContentDTO.java

@ -24,4 +24,9 @@ public class GovDraftContentDTO implements Serializable {
*/
private String content;
/**
* 审核状态
*/
private String auditStatus;
}

10
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/ArticleConstant.java

@ -56,4 +56,14 @@ public interface ArticleConstant {
* 操作权限异常-自己发表的文章只有自己才能下线
*/
String SHIRO_EXCEPTION = "当前人员不是文章发布者,不能下线文章";
/**
* 发布方式 人工强制发布 不审核
*/
String PUBLISH_WAY_MANUAL = "manualNoAudit";
/**
* 发布方式 api审核后自动发布
*/
String PUBLISH_WAY_AUTO_AUDIT = "autoAudit";
}

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

@ -75,6 +75,7 @@ public class ArticleController {
/**
* desc:政府端-点击返回按钮时点击保存草稿 无需校验参数
*
* @param fromDTO
* @throws Exception
*/
@ -87,6 +88,7 @@ public class ArticleController {
/**
* desc:保存或修改草稿内容
*
* @param fromDTO
* @throws Exception
*/
@ -155,6 +157,7 @@ public class ArticleController {
DraftAttrResultDTO draftAttrResultDTO = draftService.getDraftAttr(formDTO);
return new Result<DraftAttrResultDTO>().ok(draftAttrResultDTO);
}
/**
* @param tokenDTO
* @return
@ -183,6 +186,7 @@ public class ArticleController {
/**
* desc:保存草稿属性
*
* @param fromDTO
* @throws Exception
*/
@ -196,6 +200,7 @@ public class ArticleController {
/**
* desc:预览保存草稿属性
*
* @param fromDTO
* @throws Exception
*/
@ -209,6 +214,7 @@ public class ArticleController {
/**
* desc:发布文章
*
* @param formDTO
* @throws Exception
*/
@ -222,6 +228,19 @@ public class ArticleController {
return new Result<Boolean>().ok(isSuccess);
}
/**
* desc:人工确认无误后发布文章不走审核接口
*
* @param formDTO
* @throws Exception
*/
@PostMapping("manualpublish")
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISH)
public Result<Boolean> manualPublish(@LoginUser TokenDto tokenDto, @RequestBody PublishArticleFormDTO formDTO) throws Exception {
articleService.manualPublish(tokenDto, formDTO.getDraftId());
return new Result<Boolean>().ok(true);
}
@Async
public void scanContent(TokenDto tokenDto, String draftId) {
try {
@ -244,11 +263,12 @@ public class ArticleController {
/**
* 已发布文章列表
* @author zhaoqifeng
* @date 2020/6/3 16:19
*
* @param tokenDto
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.commons.tools.page.PageData>
* @author zhaoqifeng
* @date 2020/6/3 16:19
*/
@PostMapping("publishedarticlelist")
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISHED_LIST)
@ -261,11 +281,12 @@ public class ArticleController {
/**
* 已下线文章列表
* @author zhaoqifeng
* @date 2020/6/3 16:19
*
* @param tokenDto
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.commons.tools.page.PageData>
* @author zhaoqifeng
* @date 2020/6/3 16:19
*/
@PostMapping("offlinearticlelist")
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_OFFLINE_LIST)
@ -274,10 +295,11 @@ public class ArticleController {
List<OfflineListResultDTO> list = articleService.offlineList(tokenDto, formDTO).getList();
return new Result<List<OfflineListResultDTO>>().ok(list);
}
/**
* @Description 根据网格Id查找置顶文章的相关信息列表 用处:居民端首页轮播
* @param commonArticleListFormDTO :: getGridId :: getNum
* @return List<ArticleBannerResultDTO>
* @Description 根据网格Id查找置顶文章的相关信息列表 用处:居民端首页轮播
* @author wangc
* @date 2020.06.02 16:13
**/
@ -288,9 +310,9 @@ public class ArticleController {
}
/**
* @Description 根据网格Id查找最新文章的相关信息列表 用处:居民端首页最新文章列表
* @param commonArticleListFormDTO :: getGridId :: getNum
* @return List<ArticleLatestResultDTO>
* @Description 根据网格Id查找最新文章的相关信息列表 用处:居民端首页最新文章列表
* @author wangc
* @date 2020.06.03 09:53
**/
@ -301,9 +323,9 @@ public class ArticleController {
}
/**
* @Description 根据网格Id和标签列表查找文章的相关信息列表 用处:居民端党建声音列表
* @param articlePageFormDTO
* @return List<ArticleListResultDTO>
* @Description 根据网格Id和标签列表查找文章的相关信息列表 用处:居民端党建声音列表
* @author wangc
* @date 2020.06.03 14:19
**/
@ -330,9 +352,9 @@ public class ArticleController {
/**
* @Description 根绝文章Id查询出文章的内容封面等相关信息如果居民端传入的网格Id不在该文章的发布范围内则返回NULL
* @param articleDetailFormDTO
* @return ArticleDetailResultDTO
* @Description 根绝文章Id查询出文章的内容封面等相关信息如果居民端传入的网格Id不在该文章的发布范围内则返回NULL
* @author wangc
* @date 2020.06.03 18:28
**/

16
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/DraftController.java

@ -24,7 +24,10 @@ 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.result.DraftDetailResultDTO;
import com.epmet.dto.result.DraftListResultDTO;
import com.epmet.service.DraftService;
import org.springframework.beans.factory.annotation.Autowired;
@ -70,4 +73,17 @@ public class DraftController {
ValidatorUtils.validateEntity(formDTO);
return new Result<List<DraftListResultDTO>>().ok(draftService.draftList(tokenDto, formDTO).getList());
}
/**
* desc:政府端带封面的预览
* @param formDTO
* @return
*/
@PostMapping("detailwithcover")
public Result<DraftDetailResultDTO> detailWithCover(@RequestBody DraftDetailFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, GovArticleDetailFormDTO.AddUserInternalGroup.class);
formDTO.setShowCover(true);
DraftDetailResultDTO draftDetailResultDTO = draftService.queryDraftDetail(formDTO);
return new Result<DraftDetailResultDTO>().ok(draftDetailResultDTO);
}
}

5
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticleEntity.java

@ -103,6 +103,11 @@ public class ArticleEntity extends BaseEpmetEntity {
*/
private String tags;
/**
* 发布方式 自动审核后发布autoAudit;人工确认无误发布(不审核)manualNoAudit
*/
private String publishWay;
/**
* 组织ID
*/

8
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java

@ -206,4 +206,12 @@ public interface ArticleService extends BaseService<ArticleEntity> {
* @return
*/
void updateDraftPublishStatus(String draftId,String statusFlag);
/**
* desc:人工发布文章 不走审核接口
* @param tokenDto
* @param draftId
* @return
*/
void manualPublish(TokenDto tokenDto, String draftId);
}

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

@ -63,7 +63,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -888,7 +887,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
* @date 2020.06.05 09:10
**/
public ArticleEntity publishDraftToArticle(DraftEntity draft) {
public ArticleEntity publishDraftToArticle(DraftEntity draft, String publishWay) {
//1.查找草稿内容
if (null != draft) {
@ -904,6 +903,9 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
article.setId(null);
article.setDraftId(draftId);
article.setStatusFlag(DraftConstant.PUBLISHED);
if (StringUtils.isNotBlank(publishWay)) {
article.setPublishWay(publishWay);
}
baseDao.insert(article);
if (null != draftContents && draftContents.size() > NumConstant.ZERO) {
draftContents.forEach(content -> {
@ -1047,7 +1049,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
}
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
@Transactional(rollbackFor = Exception.class)
public void scanAllPassPublishArticle(TokenDto tokenDto, String draftId, SyncScanResult syncScanResult) {
DraftEntity draft = draftDao.selectById(draftId);
@ -1058,7 +1060,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
try {
//审核通过
this.updateAuditStatusFailById(draftId, syncScanResult);
ArticleEntity articleEntity = this.publishDraftToArticle(draft);
ArticleEntity articleEntity = this.publishDraftToArticle(draft, ArticleConstant.PUBLISH_WAY_AUTO_AUDIT);
UpdateCustomerTagCacheDTO updateCustomerTagCacheDTO = this.updateCustomerTag(tokenDto, draftId);
if (updateCustomerTagCacheDTO == null) {
return;
@ -1123,7 +1125,6 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
auditMsg = ModuleConstant.DRAFT_CONTENT;
} else if (coverFail) {
auditMsg = ModuleConstant.DRAFT_COVER;
;
}
this.sendMsg(draft.getCustomerId(), draft.getTitle(), String.format(ModuleConstant.MSG_AUDIT_CONTENT, draft.getTitle(), auditMsg));
}
@ -1157,6 +1158,35 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
draftDao.updateAuditStatusById(draftId, statusFlag);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void manualPublish(TokenDto tokenDto, String draftId) {
try {
//校验草稿状态 并更新为已发布
DraftEntity draftEntity = checkDraftStatus(draftId);
this.updateDraftPublishStatus(draftId, DraftConstant.PUBLISHED);
//复制 草稿到文章(草稿内容,封面,属性)
ArticleEntity articleEntity = this.publishDraftToArticle(draftEntity, ArticleConstant.PUBLISH_WAY_MANUAL);
UpdateCustomerTagCacheDTO updateCustomerTagCacheDTO = this.updateCustomerTag(tokenDto, draftId);
if (updateCustomerTagCacheDTO == null) {
return;
}
List<UpdateGridTagCacheDTO> updateGridTagCacheDTOS = this.updateGridTag(tokenDto, draftId, updateCustomerTagCacheDTO);
this.addArticleTags(updateCustomerTagCacheDTO, draftId, tokenDto, articleEntity.getCreatedTime());
//更新redis
try {
this.updateCacheCustomerTag(updateCustomerTagCacheDTO);
this.updateCacheGridTag(updateGridTagCacheDTOS);
} catch (Exception e) {
log.error("manualPublish update redis exception", e);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
}
} catch (RenException e) {
log.error("manualPublish exception", e);
}
}
/**
* @param draftId

14
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/DraftServiceImpl.java

@ -26,12 +26,14 @@ import com.epmet.commons.tools.page.PageData;
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.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.service.DraftService;
import com.github.pagehelper.PageHelper;
@ -39,6 +41,7 @@ import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -57,6 +60,8 @@ import java.util.Map;
public class DraftServiceImpl extends BaseServiceImpl<DraftDao, DraftEntity> implements DraftService {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private DraftCoverDao draftCoverDao;
@Override
public PageData<DraftDTO> page(Map<String, Object> params) {
IPage<DraftEntity> page = baseDao.selectPage(
@ -179,6 +184,15 @@ public class DraftServiceImpl extends BaseServiceImpl<DraftDao, DraftEntity> imp
}else{
draftDetailResultDTO.setTagNameList(new String[0]);
}
if (formDTO.isShowCover()){
DraftCoverEntity coverEntity = draftCoverDao.selectByDraftId(formDTO.getDraftId(), null);
if (coverEntity != null){
CoverImgDTO coverImgDTO = ConvertUtils.sourceToTarget(coverEntity, CoverImgDTO.class);
draftDetailResultDTO.setCoverInfo(coverImgDTO);
}else{
draftDetailResultDTO.setCoverInfo(new CoverImgDTO());
}
}
}
return draftDetailResultDTO;
}

2
epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.2__addAutoPublish.sql

@ -0,0 +1,2 @@
ALTER TABLE `epmet_gov_voice`.`article`
ADD COLUMN `PUBLISH_WAY` varchar(16) NOT NULL DEFAULT 'autoAudit' COMMENT '发布方式 自动审核后发布:autoAudit;人工确认无误发布(不审核):manualNoAudit' AFTER `TAGS`;

8
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftDao.xml

@ -142,7 +142,9 @@
ID AS "draftId",
TITLE AS "title",
IFNULL(PREVIEW_CONTENT, "") AS "content",
UNIX_TIMESTAMP(CREATED_TIME) AS "createdTime"
UNIX_TIMESTAMP(CREATED_TIME) AS "createdTime",
AUDIT_STATUS,
AUDIT_REASON
FROM draft
WHERE DEL_FLAG = '0'
AND (STATUS_FLAG = 'unpublish' OR STATUS_FLAG = 'auditfail')
@ -169,7 +171,9 @@
<select id="selectDraftContentList" parameterType="java.lang.String" resultType="com.epmet.dto.result.GovDraftContentDTO">
SELECT
dc.CONTENT_TYPE,
dc.CONTENT
dc.CONTENT,
dc.AUDIT_STATUS,
dc.AUDIT_REASON
FROM
draft_content dc
WHERE

Loading…
Cancel
Save