@ -24,7 +24,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage; 
			
		
	
		
		
			
				
					import  com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl ; import  com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl ;  
			
		
	
		
		
			
				
					import  com.elink.esua.epdc.commons.tools.constant.FieldConstant ; import  com.elink.esua.epdc.commons.tools.constant.FieldConstant ;  
			
		
	
		
		
			
				
					import  com.elink.esua.epdc.commons.tools.constant.NumConstant ; import  com.elink.esua.epdc.commons.tools.constant.NumConstant ;  
			
		
	
		
		
			
				
					import  com.elink.esua.epdc.commons.tools.exception.ErrorCode ;  
			
		
	
		
		
			
				
					import  com.elink.esua.epdc.commons.tools.exception.RenException ; import  com.elink.esua.epdc.commons.tools.exception.RenException ;  
			
		
	
		
		
			
				
					import  com.elink.esua.epdc.commons.tools.page.PageData ; import  com.elink.esua.epdc.commons.tools.page.PageData ;  
			
		
	
		
		
			
				
					import  com.elink.esua.epdc.commons.tools.utils.ConvertUtils ; import  com.elink.esua.epdc.commons.tools.utils.ConvertUtils ;  
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -76,6 +75,14 @@ public class ModuleCategoryServiceImpl extends BaseServiceImpl<ModuleCategoryDao 
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					        return  TreeUtils . build ( dtoList ) ;         return  TreeUtils . build ( dtoList ) ;  
			
		
	
		
		
			
				
					    }     }  
			
		
	
		
		
			
				
					    @Override  
			
		
	
		
		
			
				
					    public  List < ModuleCategoryDTO >  getListToShow ( Map < String ,  Object >  params )  {  
			
		
	
		
		
			
				
					        List < ModuleCategoryEntity >  entityList  =  baseDao . getListToShow ( params ) ;  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					        List < ModuleCategoryDTO >  dtoList  =  ConvertUtils . sourceToTarget ( entityList ,  ModuleCategoryDTO . class ) ;  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					        return  TreeUtils . build ( dtoList ) ;  
			
		
	
		
		
			
				
					    }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    private  QueryWrapper < ModuleCategoryEntity >  getWrapper ( Map < String ,  Object >  params ) {     private  QueryWrapper < ModuleCategoryEntity >  getWrapper ( Map < String ,  Object >  params ) {  
			
		
	
		
		
			
				
					        String  id  =  ( String ) params . get ( FieldConstant . ID_HUMP ) ;         String  id  =  ( String ) params . get ( FieldConstant . ID_HUMP ) ;  
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -185,7 +192,7 @@ public class ModuleCategoryServiceImpl extends BaseServiceImpl<ModuleCategoryDao 
			
		
	
		
		
			
				
					        ModuleCategoryEntity  entity  =  ConvertUtils . sourceToTarget ( dto ,  ModuleCategoryEntity . class ) ;         ModuleCategoryEntity  entity  =  ConvertUtils . sourceToTarget ( dto ,  ModuleCategoryEntity . class ) ;  
			
		
	
		
		
			
				
					        //上级部门不能为自身
         //上级部门不能为自身
  
			
		
	
		
		
			
				
					        if  ( entity . getId ( ) . equals ( entity . getPid ( ) ) )  {         if  ( entity . getId ( ) . equals ( entity . getPid ( ) ) )  {  
			
		
	
		
		
			
				
					
					            throw  new  RenException ( ErrorCode . SUPERIOR_DEPT_ERROR ) ;             throw  new  RenException ( "上级分类不能为自身" ) ;  
			
				
				
			
		
	
		
		
	
		
		
			
				
					        }         }  
			
		
	
		
		
			
				
					        List < ModuleCategoryEntity >  list  =  getPidListByPid ( entity . getPid ( ) ) ;         List < ModuleCategoryEntity >  list  =  getPidListByPid ( entity . getPid ( ) ) ;  
			
		
	
		
		
			
				
					        if  ( list . size ( )  = =  0 )  {         if  ( list . size ( )  = =  0 )  {  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -201,14 +208,39 @@ public class ModuleCategoryServiceImpl extends BaseServiceImpl<ModuleCategoryDao 
			
		
	
		
		
			
				
					            }             }  
			
		
	
		
		
			
				
					            entity . setPids ( pids ) ;             entity . setPids ( pids ) ;  
			
		
	
		
		
			
				
					        }         }  
			
		
	
		
		
			
				
					        //更新启用标识 : 是,则更新上级为是   否 则下级全为否
  
			
		
	
		
		
			
				
					        if ( "1" . equals ( entity . getEnableFlag ( ) ) ) {  
			
		
	
		
		
			
				
					            ModuleCategoryEntity  pModuleCategoryEntity  =  selectById ( entity . getPid ( ) ) ;  
			
		
	
		
		
			
				
					            if ( pModuleCategoryEntity ! = null ) {  
			
		
	
		
		
			
				
					                pModuleCategoryEntity . setEnableFlag ( "1" ) ;  
			
		
	
		
		
			
				
					                updateById ( pModuleCategoryEntity ) ;  
			
		
	
		
		
			
				
					            }  
			
		
	
		
		
			
				
					        }  else  if ( "0" . equals ( entity . getEnableFlag ( ) ) )  {  
			
		
	
		
		
			
				
					            List < String >  subModuleCategoryIdList  =  baseDao . getSubModuleCategoryIdList ( "%" + entity . getId ( ) + "%" ) ;  
			
		
	
		
		
			
				
					            if ( subModuleCategoryIdList ! = null  & &  subModuleCategoryIdList . size ( )  >  0 ) {  
			
		
	
		
		
			
				
					                List < ModuleCategoryEntity >  moduleCategoryEntities  =  baseDao . selectBatchIds ( subModuleCategoryIdList ) ;  
			
		
	
		
		
			
				
					                moduleCategoryEntities . forEach ( moduleCategoryEntity  - >  moduleCategoryEntity . setEnableFlag ( "0" ) ) ;  
			
		
	
		
		
			
				
					                updateBatchById ( moduleCategoryEntities ) ;  
			
		
	
		
		
			
				
					            }  
			
		
	
		
		
			
				
					        }  
			
		
	
		
		
			
				
					        updateById ( entity ) ;         updateById ( entity ) ;  
			
		
	
		
		
			
				
					    }     }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    @Override     @Override  
			
		
	
		
		
			
				
					    @Transactional ( rollbackFor  =  Exception . class )     @Transactional ( rollbackFor  =  Exception . class )  
			
		
	
		
		
			
				
					
					    public  void  delete ( String [ ]  ids )  {     public  void  delete ( String  id )  {  
			
				
				
			
		
	
		
		
			
				
					
					        // 逻辑删除(@TableLogic 注解)
         //判断是否有子部门
  
			
				
				
			
		
	
		
		
			
				
					
					        baseDao . deleteBatchIds ( Arrays . asList ( ids ) ) ;         List < String >  subList  =  SubModuleCategoryIdList ( id ) ;  
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					        if  ( subList . size ( )  >  1 )  {  
			
		
	
		
		
			
				
					            throw  new  RenException ( "请先删除下级分类" ) ;  
			
		
	
		
		
			
				
					        }  
			
		
	
		
		
			
				
					        baseDao . deleteBatchIds ( Arrays . asList ( new  String [ ] { id } ) ) ;  
			
		
	
		
		
			
				
					    }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    private  List < String >  SubModuleCategoryIdList ( String  id )  {  
			
		
	
		
		
			
				
					        List < String >  subCategoryIdList  =  baseDao . getSubModuleCategoryIdList ( "%"  +  id  +  "%" ) ;  
			
		
	
		
		
			
				
					        subCategoryIdList . add ( id ) ;  
			
		
	
		
		
			
				
					        return  subCategoryIdList ;  
			
		
	
		
		
			
				
					    }     }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    @Override     @Override