public User getUser(String id) {
return userDao.get(id);
}
public Page<User> findUser(Page<User> page, User user) {
User currentUser = UserUtils.getUser();
DetachedCriteria dc = userDao.createDetachedCriteria();
dc.createAlias("company", "company");
if (user.getCompany() != null && StringUtils.isNotBlank(user.getCompany().getId())){
dc.add(Restrictions.or(
Restrictions.eq("company.id", user.getCompany().getId()),
Restrictions.like("company.parentIds", "%," + user.getCompany().getId() + ",%")
));
}
dc.createAlias("office", "office");
if (user.getOffice() != null && StringUtils.isNotBlank(user.getOffice().getId())){
dc.add(Restrictions.or(
Restrictions.eq("office.id", user.getOffice().getId()),
Restrictions.like("office.parentIds", "%," + user.getOffice().getId() + ",%")
));
}
// 如果不是超级管理员,则不显示超级管理员用户
if (!currentUser.isAdmin()){
dc.add(Restrictions.ne("id", "1"));
}
dc.add(dataScopeFilter(currentUser, "office", ""));