|  | @@ -10,8 +10,10 @@ import com.keao.edu.im.api.client.ImFeignService;
 | 
	
		
			
				|  |  |  import com.keao.edu.im.api.entity.ImResult;
 | 
	
		
			
				|  |  |  import com.keao.edu.im.api.entity.ImUserModel;
 | 
	
		
			
				|  |  |  import com.keao.edu.user.dao.EmployeeDao;
 | 
	
		
			
				|  |  | +import com.keao.edu.user.dao.OrganizationDao;
 | 
	
		
			
				|  |  |  import com.keao.edu.user.dao.SysUserDao;
 | 
	
		
			
				|  |  |  import com.keao.edu.user.entity.Employee;
 | 
	
		
			
				|  |  | +import com.keao.edu.user.entity.Organization;
 | 
	
		
			
				|  |  |  import com.keao.edu.user.service.EmployeeService;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
	
		
			
				|  | @@ -19,7 +21,9 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Set;
 | 
	
		
			
				|  |  | +import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Service
 | 
	
		
			
				|  |  |  public class EmployeeServiceImpl extends BaseServiceImpl<Integer, Employee> implements EmployeeService {
 | 
	
	
		
			
				|  | @@ -27,6 +31,8 @@ public class EmployeeServiceImpl extends BaseServiceImpl<Integer, Employee> impl
 | 
	
		
			
				|  |  |  	@Autowired
 | 
	
		
			
				|  |  |  	private EmployeeDao employeeDao;
 | 
	
		
			
				|  |  |  	@Autowired
 | 
	
		
			
				|  |  | +	private OrganizationDao organizationDao;
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  |  	private ImFeignService imFeignService;
 | 
	
		
			
				|  |  |  	@Autowired
 | 
	
		
			
				|  |  |  	private SysUserDao sysUserDao;
 | 
	
	
		
			
				|  | @@ -118,10 +124,21 @@ public class EmployeeServiceImpl extends BaseServiceImpl<Integer, Employee> impl
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		employeeDao.update(employee);
 | 
	
		
			
				|  |  | -		//删除当前用户角色
 | 
	
		
			
				|  |  | -		sysUserDao.delEmployeeRole(sysUser.getId());
 | 
	
		
			
				|  |  | -		//新增用户角色
 | 
	
		
			
				|  |  | -		sysUserDao.batchAddEmployeeRole(sysUser.getId(),sysUser.getRoles());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		Organization organization = organizationDao.findByUserId(employee.getUserId());
 | 
	
		
			
				|  |  | +		if(organization != null){
 | 
	
		
			
				|  |  | +			List<Organization> childOrgans = organizationDao.getChildOrgans(organization.getParentOrganIdTag());
 | 
	
		
			
				|  |  | +			childOrgans.add(organization);
 | 
	
		
			
				|  |  | +			List<Integer> userIds = childOrgans.stream().map(e -> e.getUserId()).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			sysUserDao.batchAddEmployeeRoles(userIds,sysUser.getRoles());
 | 
	
		
			
				|  |  | +			if(sysUser.getRoles() != null && sysUser.getRoles().size() > 0){
 | 
	
		
			
				|  |  | +				sysUserDao.batchAddEmployeeRoles(userIds,sysUser.getRoles());
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}else {
 | 
	
		
			
				|  |  | +			sysUserDao.delEmployeeRole(sysUser.getId());
 | 
	
		
			
				|  |  | +			sysUserDao.batchAddEmployeeRole(sysUser.getId(),sysUser.getRoles());
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  |  		sysUserDao.update(sysUser);
 | 
	
		
			
				|  |  |  		imFeignService.update(new ImUserModel(sysUser.getId().toString(),sysUser.getRealName(),sysUser.getAvatar()));
 | 
	
		
			
				|  |  |  	}
 |