DzSchoolMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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="location != null and location != ''"> and t1.location = #{location}</if>
  41. <if test="pro != null "> and t1.pro = #{pro}</if>
  42. <if test="city != null "> and t1.city = #{city}</if>
  43. <if test="area != null "> and t1.area = #{area}</if>
  44. <if test="status != null "> and t1.status = #{status}</if>
  45. </where>
  46. </select>
  47. <select id="selectDzSchoolById" parameterType="Long" resultMap="DzSchoolResult">
  48. <include refid="selectDzSchoolVo"/>
  49. where t1.id = #{id}
  50. </select>
  51. <insert id="insertDzSchool" parameterType="DzSchool" useGeneratedKeys="true" keyProperty="id">
  52. insert into dz_school
  53. <trim prefix="(" suffix=")" suffixOverrides=",">
  54. <if test="name != null">name,</if>
  55. <if test="deptId != null">dept_id,</if>
  56. <if test="location != null">location,</if>
  57. <if test="remark != null">remark,</if>
  58. <if test="pro != null">pro,</if>
  59. <if test="city != null">city,</if>
  60. <if test="area != null">area,</if>
  61. <if test="status != null">status,</if>
  62. <if test="createTime != null">create_time,</if>
  63. <if test="updateTime != null">update_time,</if>
  64. </trim>
  65. <trim prefix="values (" suffix=")" suffixOverrides=",">
  66. <if test="name != null">#{name},</if>
  67. <if test="deptId != null">#{deptId},</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">#{createTime},</if>
  75. <if test="updateTime != null">#{updateTime},</if>
  76. </trim>
  77. </insert>
  78. <update id="updateDzSchool" parameterType="DzSchool">
  79. update dz_school
  80. <trim prefix="SET" suffixOverrides=",">
  81. <if test="name != null">name = #{name},</if>
  82. <if test="deptId != null">dept_id = #{deptId},</if>
  83. <if test="location != null">location = #{location},</if>
  84. <if test="remark != null">remark = #{remark},</if>
  85. <if test="pro != null">pro = #{pro},</if>
  86. <if test="city != null">city = #{city},</if>
  87. <if test="area != null">area = #{area},</if>
  88. <if test="status != null">status = #{status},</if>
  89. <if test="createTime != null">create_time = #{createTime},</if>
  90. <if test="updateTime != null">update_time = #{updateTime},</if>
  91. </trim>
  92. where id = #{id}
  93. </update>
  94. <delete id="deleteDzSchoolById" parameterType="Long">
  95. delete from dz_school where id = #{id}
  96. </delete>
  97. <delete id="deleteDzSchoolByIds" parameterType="String">
  98. delete from dz_school where id in
  99. <foreach item="id" collection="array" open="(" separator="," close=")">
  100. #{id}
  101. </foreach>
  102. </delete>
  103. </mapper>