|
|
@ -235,10 +235,11 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Boolean saveOrUpdateAttr(TokenDto tokenDto, DraftAttrFromDTO fromDTO) { |
|
|
|
public Boolean saveDraftAttr(TokenDto tokenDto, DraftAttrFromDTO fromDTO) { |
|
|
|
log.debug("saveDraftAttr param:{}",JSON.toJSONString(fromDTO)); |
|
|
|
DraftEntity draftEntity = draftDao.selectById(fromDTO.getDraftId()); |
|
|
|
if (draftEntity == null) { |
|
|
|
log.warn("saveOrUpdateAttr draftId is not exist in db"); |
|
|
|
log.warn("saveDraftAttr draftId is not exist in db"); |
|
|
|
throw new RenException("参数错误"); |
|
|
|
} |
|
|
|
|
|
|
@ -256,10 +257,11 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
//发布单位
|
|
|
|
String publisher = fromDTO.getPublisher(); |
|
|
|
String publisherType = fromDTO.getPublisherType(); |
|
|
|
//TODO 根据分布类型 获取对应的名称
|
|
|
|
//TODO 根据发布类型 获取对应的名称
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
@ -271,29 +273,55 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Boolean previewSaveDraftAttr(TokenDto tokenDto, DraftAttrFromDTO fromDTO) { |
|
|
|
//校验参数
|
|
|
|
if (fromDTO.getIsTop() == 1 && StringUtils.isBlank(fromDTO.getCoverImg())) { |
|
|
|
log.warn("saveOrUpdateAttr isTop=1 but coverImg is blank"); |
|
|
|
throw new RenException("文章封面不能为空"); |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(fromDTO.getGridIdList())) { |
|
|
|
log.warn("saveOrUpdateAttr gridIdList is empty"); |
|
|
|
throw new RenException("发布范围不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isBlank(fromDTO.getPublisher())) { |
|
|
|
log.warn("saveOrUpdateAttr publisher is blank"); |
|
|
|
throw new RenException("发布单位不能为空"); |
|
|
|
} |
|
|
|
return saveDraftAttr(tokenDto, fromDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void executeSaveDraftAttr(DraftEntity draftEntity, DraftCoverEntity coverEntity, List<DraftPublishRangeEntity> publishRangeEntityList) { |
|
|
|
Map<String,Object> draftIdMap = new HashMap<>(); |
|
|
|
draftIdMap.put("DRAFT_ID", draftEntity.getId()); |
|
|
|
draftCoverDao.deleteByMap(draftIdMap); |
|
|
|
draftCoverDao.insert(coverEntity); |
|
|
|
if (coverEntity != null){ |
|
|
|
draftCoverDao.insert(coverEntity); |
|
|
|
} |
|
|
|
|
|
|
|
draftPublishRangeDao.deleteByMap(draftIdMap); |
|
|
|
if (CollectionUtils.isEmpty(publishRangeEntityList)){ |
|
|
|
log.warn("saveOrUpdateAttr publishRangeEntityList is empty"); |
|
|
|
throw new RenException("参数错误"); |
|
|
|
} |
|
|
|
publishRangeEntityList.forEach(publishRange->draftPublishRangeDao.insert(publishRange)); |
|
|
|
if (!CollectionUtils.isEmpty(publishRangeEntityList)){ |
|
|
|
publishRangeEntityList.forEach(publishRange->draftPublishRangeDao.insert(publishRange)); |
|
|
|
} |
|
|
|
draftDao.updateById(draftEntity); |
|
|
|
} |
|
|
|
|
|
|
|
private List<DraftPublishRangeEntity> buildDraftPublishRange(DraftEntity draftEntity, TokenDto tokenDto, DraftAttrFromDTO fromDTO) { |
|
|
|
if (CollectionUtils.isEmpty(fromDTO.getGridIdList())){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<DraftPublishRangeEntity> publishRangeEntityList = new ArrayList<>(); |
|
|
|
List<String> agencyGridNameList = new ArrayList<>(); |
|
|
|
|
|
|
|
ArticleGridResultDTO articleGridResultDTO = agencyGridList(tokenDto); |
|
|
|
if (articleGridResultDTO == null) { |
|
|
|
log.warn("saveOrUpdateAttr userId:{} have not right access publishRange", tokenDto.getUserId()); |
|
|
|
log.warn("saveDraftAttr userId:{} have not right access publishRange", tokenDto.getUserId()); |
|
|
|
throw new RenException("参数错误"); |
|
|
|
} |
|
|
|
buildName(tokenDto,agencyGridNameList,publishRangeEntityList, fromDTO, articleGridResultDTO); |
|
|
@ -304,6 +332,9 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
|
|
|
|
private DraftCoverEntity buildCoverEntity(TokenDto tokenDto, DraftAttrFromDTO fromDTO) { |
|
|
|
String coverImg = fromDTO.getCoverImg(); |
|
|
|
if (StringUtils.isBlank(coverImg)){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
DraftCoverEntity coverEntity = new DraftCoverEntity(); |
|
|
|
coverEntity.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
coverEntity.setDraftId(fromDTO.getDraftId()); |
|
|
|