| 
					
				 | 
			
			
				@@ -2,12 +2,17 @@ package com.usky.website.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.toolkit.Wrappers; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.usky.common.core.exception.BusinessException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.usky.common.mybatis.core.AbstractCrudService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.usky.website.domain.SiteArticle; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.usky.website.domain.SiteCategory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.usky.website.mapper.SiteCategoryMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.usky.website.service.SiteArticleService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.usky.website.service.SiteCategoryService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -22,6 +27,9 @@ import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class SiteCategoryServiceImpl extends AbstractCrudService<SiteCategoryMapper, SiteCategory> implements SiteCategoryService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private SiteArticleService siteArticleService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<SiteCategory> siteCategoryList() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         LambdaQueryWrapper<SiteCategory> queryWrapper = Wrappers.lambdaQuery(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -40,10 +48,50 @@ public class SiteCategoryServiceImpl extends AbstractCrudService<SiteCategoryMap 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//    public void addSiteCategory(SiteCategory siteCategory){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        LambdaQueryWrapper<SiteCategory> queryWrapper = Wrappers.lambdaQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        queryWrapper.eq(SiteCategory::getStatus, 1).eq(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void addSiteCategory(SiteCategory siteCategory) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LambdaQueryWrapper<SiteCategory> queryWrapper = Wrappers.lambdaQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        queryWrapper.eq(SiteCategory::getStatus, 1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(SiteCategory::getPid, siteCategory.getPid()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(SiteCategory::getCategoryName, siteCategory.getCategoryName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<SiteCategory> list = this.list(queryWrapper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new BusinessException("栏目名称不能重复,请重新填写栏目名称"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        siteCategory.setCreatedate(LocalDateTime.now()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        siteCategory.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.save(siteCategory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void updateSiteCategory(SiteCategory siteCategory) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LambdaQueryWrapper<SiteCategory> queryWrapper = Wrappers.lambdaQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        queryWrapper.eq(SiteCategory::getStatus, 1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(SiteCategory::getPid, siteCategory.getPid()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(SiteCategory::getCategoryName, siteCategory.getCategoryName()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .ne(SiteCategory::getId, siteCategory.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<SiteCategory> list = this.list(queryWrapper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new BusinessException("栏目名称不能重复,请重新填写栏目名称"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        siteCategory.setModifydate(LocalDateTime.now()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.updateById(siteCategory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void delSiteCategory(Integer id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (id == null || id == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new BusinessException("ID不能等于空或者等于0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LambdaQueryWrapper<SiteArticle> queryWrapper = Wrappers.lambdaQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        queryWrapper.eq(SiteArticle::getCategoryid, id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<SiteArticle> list = siteArticleService.list(queryWrapper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new BusinessException("该栏目存在栏目内容不可删除"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.removeById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private List<SiteCategory> getChildrenData(SiteCategory root, List<SiteCategory> all) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<SiteCategory> children = all.stream().filter(subjectVO -> 
			 |