DepartmentMapper.xml 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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="com.tofly.base.mapper.DepartmentMapper">
  4. <resultMap id="departmentMap" type="com.tofly.base.entity.Department">
  5. <id property="id" column="ID"/>
  6. <result property="name" column="NAME"/>
  7. <result property="sort" column="SORT"/>
  8. <result property="createTime" column="CREATE_TIME"/>
  9. <result property="updateTime" column="UPDATE_TIME"/>
  10. <result property="statusFlag" column="STATUS_FLAG"/>
  11. <result property="parentId" column="PARENT_ID"/>
  12. <result property="createUser" column="CREATE_USER"/>
  13. <result property="code" column="CODE"/>
  14. <result property="shortName" column="SHORT_NAME"/>
  15. <result property="companyId" column="COMPANY_ID"/>
  16. <result property="phone" column="PHONE"/>
  17. <association property="companyName" column="COMPANY_ID" select="getCompanyName"/>
  18. <association property="parentName" column="PARENT_ID" select="getBmName"/>
  19. <association property="statusName" column="ID" select="getStatus"/>
  20. <association property="userName" column="CREATE_USER" select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
  21. </resultMap>
  22. <select id="getCompanyName" resultType="string">
  23. select COMPANY_NAME as companyName
  24. from TF_SMPN_COMPANY_X
  25. where id = #{departmentId}
  26. </select>
  27. <select id="getStatus" resultType="string" parameterType="long">
  28. select decode(STATUS_FLAG, '1', '启用', '2', '禁用')
  29. from TF_SMPN_DEPARTMENT_X
  30. where ID = #{ID}
  31. </select>
  32. <select id="getBmName" resultType="string" parameterType="long">
  33. select NAME as parentName
  34. from TF_SMPN_DEPARTMENT_X
  35. where ID = #{PARENT_ID}
  36. and STATUS_FLAG = 1
  37. </select>
  38. <select id="listSourceByDept" parameterType="map" resultType="map" databaseId="oracle">
  39. select m.*,
  40. decode((select 1
  41. from tf_smpn_departmentsource_x ds
  42. where m.id = ds.source_id
  43. and ds.department_id = #{departmentId,jdbcType=NUMERIC}),
  44. 1,
  45. 'true',
  46. 'false') is_exists
  47. from tf_smpn_source_x m
  48. where pid = #{pid}
  49. </select>
  50. <select id="listSourceByDept" parameterType="map" resultType="map" databaseId="mysql">
  51. select m.*,
  52. case (select 1
  53. from TF_SMPN_DEPARTMENTSOURCE_X ds
  54. where m.id = ds.source_id
  55. and ds.department_id = #{departmentId,jdbcType=NUMERIC})
  56. when 1 then 'true'
  57. else 'false' end is_exists
  58. from TF_SMPN_SOURCE_X m
  59. where pid = #{pid}
  60. </select>
  61. <select id="subList" resultMap="departmentMap">
  62. select *
  63. from tf_smpn_department_x
  64. connect by prior id = parent_id
  65. <choose>
  66. <when test='returnSelf !=null and returnSelf =="0" '>
  67. start with parent_id = #{id}
  68. </when>
  69. <otherwise>
  70. start with id = #{id}
  71. </otherwise>
  72. </choose>
  73. </select>
  74. <select id="getRelatedDeptIds" resultType="long">
  75. select id
  76. from tf_smpn_department_x
  77. connect by prior id = parent_id
  78. start with id = #{id}
  79. </select>
  80. </mapper>