DzSchoolMapper.xml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.ruoyi.dz.mapper.DzSchoolMapper">
  6. <resultMap type="DzSchool" id="DzSchoolResult">
  7. <result property="id" column="id" />
  8. <result property="name" column="name" />
  9. <result property="deptId" column="dept_id" />
  10. <result property="location" column="location" />
  11. <result property="remark" column="remark" />
  12. <result property="pro" column="pro" />
  13. <result property="city" column="city" />
  14. <result property="area" column="area" />
  15. <result property="status" column="status" />
  16. <result property="createTime" column="create_time" />
  17. <result property="updateTime" column="update_time" />
  18. <association property="dept" javaType="SysDept" resultMap="deptResult" />
  19. </resultMap>
  20. <resultMap id="deptResult" type="SysDept">
  21. <id property="deptId" column="dept_id" />
  22. <result property="parentId" column="parent_id" />
  23. <result property="deptName" column="dept_name" />
  24. <result property="ancestors" column="ancestors" />
  25. <result property="orderNum" column="order_num" />
  26. <result property="leader" column="leader" />
  27. <result property="status" column="dept_status" />
  28. </resultMap>
  29. <sql id="selectDzSchoolVo">
  30. select t1.id, t1.name, t1.dept_id, t1.location, t1.remark, t1.pro, t1.city, t1.area, t1.status, t1.create_time, t1.update_time,
  31. d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status
  32. from dz_school t1
  33. left join sys_dept d on t1.dept_id = d.dept_id
  34. </sql>
  35. <select id="selectDzSchoolList" parameterType="DzSchool" resultMap="DzSchoolResult">
  36. <include refid="selectDzSchoolVo"/>
  37. <where>
  38. <if test="name != null and name != ''"> and t1.name like concat('%', #{name}, '%')</if>
  39. <!-- <if test="deptId != null "> and t1.dept_id = #{deptId}</if>-->
  40. <if test="deptId != null ">
  41. AND (t1.dept_id = #{deptId} OR t1.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  42. </if>
  43. <if test="location != null and location != ''"> and t1.location = #{location}</if>
  44. <if test="pro != null "> and t1.pro = #{pro}</if>
  45. <if test="city != null "> and t1.city = #{city}</if>
  46. <if test="area != null "> and t1.area = #{area}</if>
  47. <if test="status != null "> and t1.status = #{status}</if>
  48. </where>
  49. </select>
  50. <select id="selectDzSchoolListByIds" resultMap="DzSchoolResult">
  51. <include refid="selectDzSchoolVo"/>
  52. WHERE 1=1
  53. AND t1.id IN
  54. <foreach collection="ids" item="id" open="(" separator="," close=")">
  55. #{id}
  56. </foreach>
  57. ORDER BY t1.id ASC
  58. </select>
  59. <select id="selectDzSchoolById" parameterType="Long" resultMap="DzSchoolResult">
  60. <include refid="selectDzSchoolVo"/>
  61. where t1.id = #{id}
  62. </select>
  63. <insert id="insertDzSchool" parameterType="DzSchool" useGeneratedKeys="true" keyProperty="id">
  64. insert into dz_school
  65. <trim prefix="(" suffix=")" suffixOverrides=",">
  66. <if test="name != null">name,</if>
  67. <if test="deptId != null">dept_id,</if>
  68. <if test="location != null">location,</if>
  69. <if test="remark != null">remark,</if>
  70. <if test="pro != null">pro,</if>
  71. <if test="city != null">city,</if>
  72. <if test="area != null">area,</if>
  73. <if test="status != null">status,</if>
  74. <if test="createTime != null">create_time,</if>
  75. <if test="updateTime != null">update_time,</if>
  76. </trim>
  77. <trim prefix="values (" suffix=")" suffixOverrides=",">
  78. <if test="name != null">#{name},</if>
  79. <if test="deptId != null">#{deptId},</if>
  80. <if test="location != null">#{location},</if>
  81. <if test="remark != null">#{remark},</if>
  82. <if test="pro != null">#{pro},</if>
  83. <if test="city != null">#{city},</if>
  84. <if test="area != null">#{area},</if>
  85. <if test="status != null">#{status},</if>
  86. <if test="createTime != null">#{createTime},</if>
  87. <if test="updateTime != null">#{updateTime},</if>
  88. </trim>
  89. </insert>
  90. <update id="updateDzSchool" parameterType="DzSchool">
  91. update dz_school
  92. <trim prefix="SET" suffixOverrides=",">
  93. <if test="name != null">name = #{name},</if>
  94. <if test="deptId != null">dept_id = #{deptId},</if>
  95. <if test="location != null">location = #{location},</if>
  96. <if test="remark != null">remark = #{remark},</if>
  97. <if test="pro != null">pro = #{pro},</if>
  98. <if test="city != null">city = #{city},</if>
  99. <if test="area != null">area = #{area},</if>
  100. <if test="status != null">status = #{status},</if>
  101. <if test="createTime != null">create_time = #{createTime},</if>
  102. <if test="updateTime != null">update_time = #{updateTime},</if>
  103. </trim>
  104. where id = #{id}
  105. </update>
  106. <delete id="deleteDzSchoolById" parameterType="Long">
  107. delete from dz_school where id = #{id}
  108. </delete>
  109. <delete id="deleteDzSchoolByIds" parameterType="String">
  110. delete from dz_school where id in
  111. <foreach item="id" collection="array" open="(" separator="," close=")">
  112. #{id}
  113. </foreach>
  114. </delete>
  115. </mapper>