| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -18,6 +18,7 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					package com.epmet.service.impl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.alibaba.fastjson.JSON; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.baomidou.mybatisplus.core.conditions.Wrapper; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.baomidou.mybatisplus.core.metadata.IPage; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -36,9 +37,7 @@ import com.epmet.constant.ArticleConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.constant.DraftConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.constant.RoleKeyConstants; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dao.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.ArticleDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.ArticleVisitRecordDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.CustomerStaffDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.feign.GovOrgSelfFeignClient; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.form.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.result.*; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -92,6 +91,10 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private DraftCoverDao draftCoverDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Autowired | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private DraftPublishRangeDao draftPublishRangeDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Autowired | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private ArticleContentDao articleContentDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Autowired | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private ArticleCoverDao articleCoverDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private static final String AGENCY = "agency"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private static final String GRID = "grid"; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -683,4 +686,58 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return articleInfo; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						/** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Description 草稿发布文章 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @param draftId | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @return String 返回新发布文章的Id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @author wangc | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @date 2020.06.05 09:10 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public String publishDraftToArticle(String draftId) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//1.查找草稿内容
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							DraftEntity draft = draftDao.selectById(draftId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if(null != draft){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//2.查找草稿内容、封面、发布范围
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								List<DraftContentDTO> draftContents = draftContentDao.selectByDraftId(draftId,ModuleConstant.AUDIT_STATUS_PASS); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								DraftCoverDTO draftCover = draftCoverDao.selectByDraftId(draftId,ModuleConstant.AUDIT_STATUS_PASS); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								List<DraftPublishRangeDTO> draftPublishRange = draftPublishRangeDao.selectByDraftId(draftId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//3.生成文章以及相关记录
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								ArticleEntity article = ConvertUtils.sourceToTarget(draft,ArticleEntity.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								article.setId(null); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								article.setDraftId(draftId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								baseDao.insert(article); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								int order = NumConstant.ONE; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if(null != draftContents && draftContents.size() > NumConstant.ZERO){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									draftContents.forEach(content -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										content.setOrderNum(order+NumConstant.ONE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										ArticleContentEntity contentToInsert = ConvertUtils.sourceToTarget(content,ArticleContentEntity.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										contentToInsert.setArticleId(article.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										contentToInsert.setId(null); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										articleContentDao.insert(contentToInsert); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if(null != draftPublishRange && draftPublishRange.size() > NumConstant.ZERO){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									draftPublishRange.forEach(range -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										ArticlePublishRangeEntity rangeToInsert = ConvertUtils.sourceToTarget(range,ArticlePublishRangeEntity.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										rangeToInsert.setArticleId(article.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										rangeToInsert.setId(null); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										articlePublishRangeDao.insert(rangeToInsert); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									if(null != draftCover){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										ArticleCoverEntity coverToInsert = ConvertUtils.sourceToTarget(draftCover,ArticleCoverEntity.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										coverToInsert.setArticleId(article.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										coverToInsert.setId(null); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										articleCoverDao.insert(coverToInsert); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return article.getId(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							throw new RenException(String.format(ModuleConstant.SPECIFIED_DRAFT_NOT_FOUNT_EXCEPTION_TEMPLATE,draftId)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} |