SysDeptMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.weather.mapper.SysDeptMapper">
  4. <resultMap type="SysDept" id="SysDeptResult">
  5. <id property="deptId" column="dept_id" />
  6. <result property="parentId" column="parent_id" />
  7. <result property="ancestors" column="ancestors" />
  8. <result property="deptName" column="dept_name" />
  9. <result property="orderNum" column="order_num" />
  10. <result property="leader" column="leader" />
  11. <result property="phone" column="phone" />
  12. <result property="email" column="email" />
  13. <result property="status" column="status" />
  14. <result property="delFlag" column="del_flag" />
  15. <result property="parentName" column="parent_name" />
  16. <result property="createBy" column="create_by" />
  17. <result property="createTime" column="create_time" />
  18. <result property="updateBy" column="update_by" />
  19. <result property="updateTime" column="update_time" />
  20. </resultMap>
  21. <sql id="selectDeptVo">
  22. select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
  23. from sys_dept d
  24. </sql>
  25. <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
  26. <include refid="selectDeptVo"/>
  27. where d.del_flag = '0'
  28. <if test="deptId != null and deptId != 0">
  29. AND dept_id = #{deptId}
  30. </if>
  31. <if test="parentId != null and parentId != 0">
  32. AND parent_id = #{parentId}
  33. </if>
  34. <if test="deptName != null and deptName != ''">
  35. AND dept_name like concat('%', #{deptName}, '%')
  36. </if>
  37. <if test="status != null and status != ''">
  38. AND status = #{status}
  39. </if>
  40. <!-- 数据范围过滤 -->
  41. ${params.dataScope}
  42. order by d.parent_id, d.order_num
  43. </select>
  44. <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
  45. <include refid="selectDeptVo"/>
  46. where dept_id = #{deptId}
  47. </select>
  48. <insert id="insertDept" parameterType="SysDept">
  49. insert into sys_dept(
  50. <if test="deptId != null and deptId != 0">dept_id,</if>
  51. <if test="parentId != null and parentId != 0">parent_id,</if>
  52. <if test="deptName != null and deptName != ''">dept_name,</if>
  53. <if test="ancestors != null and ancestors != ''">ancestors,</if>
  54. <if test="orderNum != null">order_num,</if>
  55. <if test="leader != null and leader != ''">leader,</if>
  56. <if test="phone != null and phone != ''">phone,</if>
  57. <if test="email != null and email != ''">email,</if>
  58. <if test="status != null">status,</if>
  59. <if test="createBy != null and createBy != ''">create_by,</if>
  60. create_time
  61. )values(
  62. <if test="deptId != null and deptId != 0">#{deptId},</if>
  63. <if test="parentId != null and parentId != 0">#{parentId},</if>
  64. <if test="deptName != null and deptName != ''">#{deptName},</if>
  65. <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
  66. <if test="orderNum != null">#{orderNum},</if>
  67. <if test="leader != null and leader != ''">#{leader},</if>
  68. <if test="phone != null and phone != ''">#{phone},</if>
  69. <if test="email != null and email != ''">#{email},</if>
  70. <if test="status != null">#{status},</if>
  71. <if test="createBy != null and createBy != ''">#{createBy},</if>
  72. NOW()
  73. )
  74. </insert>
  75. <update id="updateDept" parameterType="SysDept">
  76. update sys_dept
  77. <set>
  78. <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
  79. <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
  80. <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
  81. <if test="orderNum != null">order_num = #{orderNum},</if>
  82. <if test="leader != null">leader = #{leader},</if>
  83. <if test="phone != null">phone = #{phone},</if>
  84. <if test="email != null">email = #{email},</if>
  85. <if test="status != null and status != ''">status = #{status},</if>
  86. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  87. update_time = NOW()
  88. </set>
  89. where dept_id = #{deptId}
  90. </update>
  91. </mapper>