DeptDao.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package com.flow.dao;
  2. import com.flow.common.mybatis.dao.BaseDao;
  3. import com.flow.entity.Dept;
  4. import com.flow.entity.User;
  5. import org.apache.ibatis.annotations.Param;
  6. import org.apache.ibatis.annotations.Select;
  7. import java.util.List;
  8. public interface DeptDao extends BaseDao<Dept> {
  9. @Select("select * from sys_user where username = (select leader from sys_dept where id =#{id})")
  10. User getLeader(@Param("id") String id);
  11. @Select({
  12. "<script>",
  13. "select * from sys_user where username in (select leader from sys_dept where id in ",
  14. "<foreach item='id' collection='ids' open='(' separator=',' close=')'>",
  15. "#{id}",
  16. "</foreach>)",
  17. "</script>"
  18. })
  19. List<User> getLeader(@Param("ids") List<String> ids);
  20. @Select("select * from sys_user where dept_id = #{id}")
  21. List<User> getUsers(@Param("id") String id);
  22. @Select({
  23. "<script>",
  24. "select * from sys_user where dept_id in",
  25. "<foreach item='id' collection='ids' open='(' separator=',' close=')'>",
  26. "#{roleId}",
  27. "</foreach>",
  28. "</script>"
  29. })
  30. List<User> getUsers(@Param("ids") List<String> ids);
  31. @Select({
  32. "<script>",
  33. "select * from sys_user where dept_id in",
  34. "<foreach item='id' collection='ids' open='(' separator=',' close=')'>",
  35. "#{id}",
  36. "</foreach>",
  37. "and username in",
  38. "<foreach item='id' collection='roleIds' open='(' separator=',' close=')'>",
  39. "#{id}",
  40. "</foreach>",
  41. "</script>"
  42. })
  43. List<User> getRoleUsers(@Param("ids") List<String> ids, @Param("roleIds") List<String> roleIds);
  44. }