|  |  | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
 |  |  | import com.github.pagehelper.PageHelper; | 
 |  |  | import com.github.pagehelper.PageInfo; | 
 |  |  | import doumeemes.config.shiro.ShiroToken; | 
 |  |  | import doumeemes.core.constants.ResponseStatus; | 
 |  |  | import doumeemes.core.exception.BusinessException; | 
 |  |  | import doumeemes.core.model.LoginUserInfo; | 
 |  |  | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.apache.commons.lang3.StringUtils; | 
 |  |  | import org.apache.shiro.SecurityUtils; | 
 |  |  | import org.apache.shiro.subject.Subject; | 
 |  |  | import org.springframework.beans.BeanUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.data.redis.core.RedisTemplate; | 
 |  |  | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  | import org.springframework.util.CollectionUtils; | 
 |  |  |  | 
 |  |  | import javax.annotation.PostConstruct; | 
 |  |  | import java.util.*; | 
 |  |  | import java.util.stream.Collectors; | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Department findOne(Department Department) { | 
 |  |  |         Wrapper<Department> wrapper = new QueryWrapper<>(Department); | 
 |  |  |         return departmentExtMapper.selectOne(wrapper); | 
 |  |  |         QueryWrapper<Department> wrapper = new QueryWrapper<>(Department); | 
 |  |  |         return departmentExtMapper.selectOne(wrapper.last("limit 1")); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |               throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起!只能切换到公司级部门!"); | 
 |  |  |           } | 
 |  |  |           user.setCurComDepartment(d); | 
 |  |  |           //更新会话数据信息 | 
 |  |  |           SecurityUtils.getSubject().login(new ShiroToken(user,1)); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |             //加入redis缓存,存储企业信息 | 
 |  |  |             RedisUtil.addObject(redisTemplate,Constants.RedisKeys.COM_DEPART_TREE_KEY+com.getId(),rootDepart); | 
 |  |  |     } | 
 |  |  |     @PostConstruct | 
 |  |  |     @Override | 
 |  |  |     public  void loadAllDepart() { | 
 |  |  |         QueryCompanyExtDTO dto = new QueryCompanyExtDTO(); | 
 |  |  | 
 |  |  |             for (Department department:departmentList ) { | 
 |  |  |                 this.dealDepartmentData(department,user); | 
 |  |  |             } | 
 |  |  |         }  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void dealDepartmentData(Department department,LoginUserInfo user){ |