77aab400c64dbe67e2f78272059b38218ced7525.svn-base 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="org.jeecg.modules.system.mapper.SysDepartMapper">
  4. <select id="queryUserDeparts" parameterType="String" resultType="org.jeecg.modules.system.entity.SysDepart">
  5. select * from sys_depart where id IN ( select dep_id from sys_user_depart where user_id = #{userId} )
  6. </select>
  7. <!-- 根据username查询所拥有的部门 -->
  8. <select id="queryDepartsByUsername" parameterType="String" resultType="org.jeecg.modules.system.entity.SysDepart">
  9. SELECT *
  10. FROM sys_depart
  11. WHERE id IN (
  12. SELECT dep_id
  13. FROM sys_user_depart
  14. WHERE user_id = (
  15. SELECT id
  16. FROM sys_user
  17. WHERE username = #{username}
  18. )
  19. )
  20. </select>
  21. <!-- 根据部门Id查询,当前和下级所有部门IDS -->
  22. <select id="getSubDepIdsByDepId" resultType="java.lang.String">
  23. select id from sys_depart where del_flag = '0' and org_code like concat((select org_code from sys_depart where id=#{departId}),'%')
  24. </select>
  25. <!--根据部门编码获取我的部门下所有部门ids -->
  26. <select id="getSubDepIdsByOrgCodes" resultType="java.lang.String">
  27. select id from sys_depart where del_flag = '0' and
  28. <foreach collection="orgCodes" item="item" index="index" open="(" separator="or" close=")">
  29. org_code LIKE CONCAT(#{item},'%')
  30. </foreach>
  31. </select>
  32. <!--根据parent_id查询下级部门-->
  33. <select id="queryTreeListByPid" parameterType="Object" resultType="org.jeecg.modules.system.entity.SysDepart">
  34. SELECT * FROM sys_depart where del_flag = '0'
  35. <choose>
  36. <when test="parentId != null and parentId != ''">
  37. AND parent_id = #{parentId,jdbcType=VARCHAR}
  38. </when>
  39. <otherwise>
  40. AND parent_id is null or parent_id=''
  41. </otherwise>
  42. </choose>
  43. order by depart_order
  44. </select>
  45. <!-- 根据OrgCod查询公司信息 -->
  46. <select id="queryCompByOrgCode" resultType="org.jeecg.modules.system.entity.SysDepart">
  47. select * from sys_depart where del_flag = '0' and org_category='1' and org_code= #{orgCode,jdbcType=VARCHAR}
  48. </select>
  49. </mapper>