HospitalDeptMapper.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.hospital.mapper.HospitalDeptMapper">
  6. <resultMap type="HospitalDept" id="HospitalDeptResult">
  7. <result property="deptId" column="dept_id" />
  8. <result property="parentId" column="parent_id" />
  9. <result property="ancestors" column="ancestors" />
  10. <result property="deptName" column="dept_name" />
  11. <result property="orderNum" column="order_num" />
  12. <result property="leader" column="leader" />
  13. <result property="phone" column="phone" />
  14. <result property="email" column="email" />
  15. <result property="status" column="status" />
  16. <result property="isDel" column="is_del" />
  17. <result property="createBy" column="create_by" />
  18. <result property="createTime" column="create_time" />
  19. <result property="updateBy" column="update_by" />
  20. <result property="updateTime" column="update_time" />
  21. <result property="hospitalId" column="hospital_id" />
  22. </resultMap>
  23. <sql id="selectHospitalDeptVo">
  24. select dept_id, parent_id, ancestors, dept_name, order_num, leader, phone, email, status, is_del, create_by, create_time, update_by, update_time, hospital_id from hospital_dept
  25. </sql>
  26. <select id="selectHospitalDeptList" parameterType="HospitalDept" resultMap="HospitalDeptResult">
  27. <include refid="selectHospitalDeptVo"/>
  28. <where>
  29. <if test="parentId != null "> and parent_id = #{parentId}</if>
  30. <if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
  31. <if test="deptName != null and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
  32. <if test="orderNum != null "> and order_num = #{orderNum}</if>
  33. <if test="leader != null and leader != ''"> and leader = #{leader}</if>
  34. <if test="phone != null and phone != ''"> and phone = #{phone}</if>
  35. <if test="email != null and email != ''"> and email = #{email}</if>
  36. <if test="status != null "> and status = #{status}</if>
  37. <if test="isDel != null "> and is_del = #{isDel}</if>
  38. <if test="hospitalId != null "> and hospital_id = #{hospitalId}</if>
  39. </where>
  40. </select>
  41. <select id="selectHospitalDeptByDeptId" parameterType="Long" resultMap="HospitalDeptResult">
  42. <include refid="selectHospitalDeptVo"/>
  43. where dept_id = #{deptId}
  44. </select>
  45. <insert id="insertHospitalDept" parameterType="HospitalDept" useGeneratedKeys="true" keyProperty="deptId">
  46. insert into hospital_dept
  47. <trim prefix="(" suffix=")" suffixOverrides=",">
  48. <if test="parentId != null">parent_id,</if>
  49. <if test="ancestors != null">ancestors,</if>
  50. <if test="deptName != null">dept_name,</if>
  51. <if test="orderNum != null">order_num,</if>
  52. <if test="leader != null">leader,</if>
  53. <if test="phone != null">phone,</if>
  54. <if test="email != null">email,</if>
  55. <if test="status != null">status,</if>
  56. <if test="isDel != null">is_del,</if>
  57. <if test="createBy != null">create_by,</if>
  58. <if test="createTime != null">create_time,</if>
  59. <if test="updateBy != null">update_by,</if>
  60. <if test="updateTime != null">update_time,</if>
  61. <if test="hospitalId != null">hospital_id,</if>
  62. </trim>
  63. <trim prefix="values (" suffix=")" suffixOverrides=",">
  64. <if test="parentId != null">#{parentId},</if>
  65. <if test="ancestors != null">#{ancestors},</if>
  66. <if test="deptName != null">#{deptName},</if>
  67. <if test="orderNum != null">#{orderNum},</if>
  68. <if test="leader != null">#{leader},</if>
  69. <if test="phone != null">#{phone},</if>
  70. <if test="email != null">#{email},</if>
  71. <if test="status != null">#{status},</if>
  72. <if test="isDel != null">#{isDel},</if>
  73. <if test="createBy != null">#{createBy},</if>
  74. <if test="createTime != null">#{createTime},</if>
  75. <if test="updateBy != null">#{updateBy},</if>
  76. <if test="updateTime != null">#{updateTime},</if>
  77. <if test="hospitalId != null">#{hospitalId},</if>
  78. </trim>
  79. </insert>
  80. <update id="updateHospitalDept" parameterType="HospitalDept">
  81. update hospital_dept
  82. <trim prefix="SET" suffixOverrides=",">
  83. <if test="parentId != null">parent_id = #{parentId},</if>
  84. <if test="ancestors != null">ancestors = #{ancestors},</if>
  85. <if test="deptName != null">dept_name = #{deptName},</if>
  86. <if test="orderNum != null">order_num = #{orderNum},</if>
  87. <if test="leader != null">leader = #{leader},</if>
  88. <if test="phone != null">phone = #{phone},</if>
  89. <if test="email != null">email = #{email},</if>
  90. <if test="status != null">status = #{status},</if>
  91. <if test="isDel != null">is_del = #{isDel},</if>
  92. <if test="createBy != null">create_by = #{createBy},</if>
  93. <if test="createTime != null">create_time = #{createTime},</if>
  94. <if test="updateBy != null">update_by = #{updateBy},</if>
  95. <if test="updateTime != null">update_time = #{updateTime},</if>
  96. <if test="hospitalId != null">hospital_id = #{hospitalId},</if>
  97. </trim>
  98. where dept_id = #{deptId}
  99. </update>
  100. <delete id="deleteHospitalDeptByDeptId" parameterType="Long">
  101. delete from hospital_dept where dept_id = #{deptId}
  102. </delete>
  103. <delete id="deleteHospitalDeptByDeptIds" parameterType="String">
  104. delete from hospital_dept where dept_id in
  105. <foreach item="deptId" collection="array" open="(" separator="," close=")">
  106. #{deptId}
  107. </foreach>
  108. </delete>
  109. </mapper>