StuDepartmentMapper.xml 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.system.mapper.StuDepartmentMapper">
  6. <resultMap type="StuDepartment" id="StuDepartmentResult">
  7. <result property="id" column="id" />
  8. <result property="collegeId" column="college_id" />
  9. <result property="collegeName" column="college_name" />
  10. <result property="departmentName" column="department_name" />
  11. <result property="remark" column="remark" />
  12. <result property="createBy" column="create_by" />
  13. <result property="createTime" column="create_time" />
  14. <result property="updateBy" column="update_by" />
  15. <result property="updateTime" column="update_time" />
  16. </resultMap>
  17. <sql id="selectStuDepartmentVo">
  18. select d.id, d.college_id,co.college_name, d.department_name, d.remark, d.create_by, d.create_time, d.update_by, d.update_time from stu_department d
  19. </sql>
  20. <select id="selectStuDepartmentList" parameterType="StuDepartment" resultMap="StuDepartmentResult">
  21. <include refid="selectStuDepartmentVo"/>
  22. LEFT JOIN stu_college co ON d.college_id = co.id
  23. <where>
  24. <if test="collegeId != null "> and college_id = #{collegeId}</if>
  25. <if test="departmentName != null and departmentName != ''"> and department_name like concat('%', #{departmentName}, '%')</if>
  26. <if test="delStatus != null "> and d.del_status = #{delStatus}</if>
  27. </where>
  28. order by update_time desc
  29. </select>
  30. <select id="selectStuDepartmentById" parameterType="Long" resultMap="StuDepartmentResult">
  31. <include refid="selectStuDepartmentVo"/>
  32. LEFT JOIN stu_college co ON d.college_id = co.id
  33. where d.id = #{id}
  34. </select>
  35. <insert id="insertStuDepartment" parameterType="StuDepartment" useGeneratedKeys="true" keyProperty="id">
  36. insert into stu_department
  37. <trim prefix="(" suffix=")" suffixOverrides=",">
  38. <if test="collegeId != null">college_id,</if>
  39. <if test="departmentName != null">department_name,</if>
  40. <if test="delStatus != null">del_status,</if>
  41. <if test="remark != null">remark,</if>
  42. <if test="createBy != null">create_by,</if>
  43. <if test="createTime != null">create_time,</if>
  44. <if test="updateBy != null">update_by,</if>
  45. <if test="updateTime != null">update_time,</if>
  46. </trim>
  47. <trim prefix="values (" suffix=")" suffixOverrides=",">
  48. <if test="collegeId != null">#{collegeId},</if>
  49. <if test="departmentName != null">#{departmentName},</if>
  50. <if test="delStatus != null">#{delStatus},</if>
  51. <if test="remark != null">#{remark},</if>
  52. <if test="createBy != null">#{createBy},</if>
  53. <if test="createTime != null">#{createTime},</if>
  54. <if test="updateBy != null">#{updateBy},</if>
  55. <if test="updateTime != null">#{updateTime},</if>
  56. </trim>
  57. </insert>
  58. <update id="updateStuDepartment" parameterType="StuDepartment">
  59. update stu_department
  60. <trim prefix="SET" suffixOverrides=",">
  61. <if test="collegeId != null">college_id = #{collegeId},</if>
  62. <if test="departmentName != null">department_name = #{departmentName},</if>
  63. <if test="delStatus != null">del_status = #{delStatus},</if>
  64. <if test="remark != null">remark = #{remark},</if>
  65. <if test="createBy != null">create_by = #{createBy},</if>
  66. <if test="createTime != null">create_time = #{createTime},</if>
  67. <if test="updateBy != null">update_by = #{updateBy},</if>
  68. <if test="updateTime != null">update_time = #{updateTime},</if>
  69. </trim>
  70. where id = #{id}
  71. </update>
  72. <delete id="deleteStuDepartmentById" parameterType="Long">
  73. delete from stu_department where id = #{id}
  74. </delete>
  75. <delete id="deleteStuDepartmentByIds" parameterType="String">
  76. delete from stu_department where id in
  77. <foreach item="id" collection="array" open="(" separator="," close=")">
  78. #{id}
  79. </foreach>
  80. </delete>
  81. <!-- 查询科系列表 -->
  82. <select id="queryList" parameterType="Long" resultType="Map">
  83. SELECT id,department_name AS departmentName FROM stu_department where del_status=0 AND college_id=#{collegeId}
  84. </select>
  85. </mapper>