Browse Source

Merge remote-tracking branch 'origin/dev_voice' into dev_voice

dev_shibei_match
zhaoqifeng 5 years ago
parent
commit
26955dbf80
  1. 22
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java
  2. 9
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java
  3. 36
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java

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

@ -32,10 +32,6 @@ import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.ArticleDTO; import com.epmet.dto.ArticleDTO;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
import com.epmet.dto.result.ArticleGridResultDTO;
import com.epmet.dto.result.ArticleOperationResultDTO;
import com.epmet.dto.result.GovArticleDetailResultDTO;
import com.epmet.dto.result.PublishAgencyListResultDTO;
import com.epmet.excel.ArticleExcel; import com.epmet.excel.ArticleExcel;
import com.epmet.service.ArticleOperateRecordService; import com.epmet.service.ArticleOperateRecordService;
import com.epmet.service.ArticleService; import com.epmet.service.ArticleService;
@ -124,6 +120,7 @@ public class ArticleController {
* @throws Exception * @throws Exception
*/ */
@GetMapping("savecontent") @GetMapping("savecontent")
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISH)
public Result<String> saveOrUpdateContent(@LoginUser TokenDto tokenDto,@RequestBody DraftContentFromDTO fromDTO) throws Exception { public Result<String> saveOrUpdateContent(@LoginUser TokenDto tokenDto,@RequestBody DraftContentFromDTO fromDTO) throws Exception {
String draftId = articleService.saveOrUpdateContent(tokenDto, fromDTO); String draftId = articleService.saveOrUpdateContent(tokenDto, fromDTO);
return new Result<String>().ok(draftId); return new Result<String>().ok(draftId);
@ -221,9 +218,13 @@ public class ArticleController {
* @throws Exception * @throws Exception
*/ */
@GetMapping("saveattr") @GetMapping("saveattr")
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISH)
public Result<Boolean> saveDraftAttr(@LoginUser TokenDto tokenDto,@RequestBody DraftAttrFromDTO fromDTO) throws Exception { public Result<Boolean> saveDraftAttr(@LoginUser TokenDto tokenDto,@RequestBody DraftAttrFromDTO fromDTO) throws Exception {
ValidatorUtils.validateEntity(fromDTO, DefaultGroup.class); ValidatorUtils.validateEntity(fromDTO, DefaultGroup.class);
Boolean isSuccess = articleService.saveDraftAttr(tokenDto, fromDTO); Boolean isSuccess = articleService.saveDraftAttr(tokenDto, fromDTO);
if (isSuccess){
//TODO 异步校验内容
}
return new Result<Boolean>().ok(isSuccess); return new Result<Boolean>().ok(isSuccess);
} }
@ -233,12 +234,25 @@ public class ArticleController {
* @throws Exception * @throws Exception
*/ */
@GetMapping("previewsaveattr") @GetMapping("previewsaveattr")
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISH)
public Result<Boolean> previewSaveDraftAttr(@LoginUser TokenDto tokenDto,@RequestBody DraftAttrFromDTO fromDTO) throws Exception { public Result<Boolean> previewSaveDraftAttr(@LoginUser TokenDto tokenDto,@RequestBody DraftAttrFromDTO fromDTO) throws Exception {
ValidatorUtils.validateEntity(fromDTO, DefaultGroup.class); ValidatorUtils.validateEntity(fromDTO, DefaultGroup.class);
Boolean isSuccess = articleService.previewSaveDraftAttr(tokenDto, fromDTO); Boolean isSuccess = articleService.previewSaveDraftAttr(tokenDto, fromDTO);
return new Result<Boolean>().ok(isSuccess); return new Result<Boolean>().ok(isSuccess);
} }
/**
* desc:发布文章
* @param draftId
* @throws Exception
*/
@GetMapping("publish")
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISH)
public Result<Boolean> publishArticle(@LoginUser TokenDto tokenDto, String draftId) throws Exception {
Boolean isSuccess = articleService.publish(tokenDto, draftId);
return new Result<Boolean>().ok(isSuccess);
}
/** /**
* 已发布文章列表 * 已发布文章列表

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

@ -176,4 +176,13 @@ public interface ArticleService extends BaseService<ArticleEntity> {
* @return java.util.List<com.epmet.dto.result.OfflineListResultDTO> * @return java.util.List<com.epmet.dto.result.OfflineListResultDTO>
*/ */
PageData offlineList(TokenDto tokenDto, OfflineListFormDTO formDTO); PageData offlineList(TokenDto tokenDto, OfflineListFormDTO formDTO);
/**
* desc: 发布文章
* @param:draftId
* @return: Boolean
* date: 2020/6/3 16:34
* @author: jianjun liu
*/
Boolean publish(TokenDto tokenDto, String draftId);
} }

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

@ -241,11 +241,8 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
@Override @Override
public Boolean saveDraftAttr(TokenDto tokenDto, DraftAttrFromDTO fromDTO) { public Boolean saveDraftAttr(TokenDto tokenDto, DraftAttrFromDTO fromDTO) {
log.debug("saveDraftAttr param:{}",JSON.toJSONString(fromDTO)); log.debug("saveDraftAttr param:{}",JSON.toJSONString(fromDTO));
DraftEntity draftEntity = draftDao.selectById(fromDTO.getDraftId());
if (draftEntity == null) { DraftEntity draftEntity = checkDraftStatus(fromDTO.getDraftId());
log.warn("saveDraftAttr draftId is not exist in db");
throw new RenException("参数错误");
}
//构建标签 //构建标签
if (!CollectionUtils.isEmpty(fromDTO.getTagNameList())) { if (!CollectionUtils.isEmpty(fromDTO.getTagNameList())) {
@ -277,6 +274,23 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
return true; return true;
} }
private DraftEntity checkDraftStatus(String draftId) {
DraftEntity draftEntity = draftDao.selectById(draftId);
if (draftEntity == null) {
log.warn("saveDraftAttr draftId:{} is not exist in db",draftId);
throw new RenException("参数错误");
}
if (NumConstant.ONE_STR.equals(draftEntity.getDelFlag())) {
log.warn("saveDraftAttr draftId:{} have deleted",draftId);
throw new RenException("参数错误");
}
if (DraftConstant.PUBLISHED.equals(draftEntity.getStatusFlag())) {
log.warn("saveDraftAttr draftId:{} publishStatus have published");
throw new RenException("参数错误");
}
return draftEntity;
}
@Override @Override
public Boolean previewSaveDraftAttr(TokenDto tokenDto, DraftAttrFromDTO fromDTO) { public Boolean previewSaveDraftAttr(TokenDto tokenDto, DraftAttrFromDTO fromDTO) {
//校验参数 //校验参数
@ -296,6 +310,18 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
return saveDraftAttr(tokenDto, fromDTO); return saveDraftAttr(tokenDto, fromDTO);
} }
@Override
public Boolean publish(TokenDto tokenDto, String draftId) {
if (StringUtils.isBlank(draftId)){
log.warn("publish param error draftId is blank");
throw new RenException("草稿Id不能为空");
}
DraftEntity draftEntity = checkDraftStatus(draftId);
draftEntity.setStatusFlag(DraftConstant.AUDITING);
draftDao.updateById(draftEntity);
return true;
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void executeSaveDraftAttr(DraftEntity draftEntity, DraftCoverEntity coverEntity, List<DraftPublishRangeEntity> publishRangeEntityList) { public void executeSaveDraftAttr(DraftEntity draftEntity, DraftCoverEntity coverEntity, List<DraftPublishRangeEntity> publishRangeEntityList) {
Map<String,Object> draftIdMap = new HashMap<>(); Map<String,Object> draftIdMap = new HashMap<>();

Loading…
Cancel
Save