DzSubjectMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.DzSubjectMapper">
  6. <resultMap type="DzSubject" id="DzSubjectResult">
  7. <result property="subjectId" column="subject_id" />
  8. <result property="subjectName" column="subject_name" />
  9. <result property="pinyin" column="pinyin" />
  10. <result property="sort" column="sort" />
  11. <result property="locations" column="locations" />
  12. <result property="examTypes" column="exam_types" />
  13. <result property="groupName" column="group_name" />
  14. </resultMap>
  15. <sql id="selectDzSubjectVo">
  16. select subject_id, subject_name, pinyin, sort, locations, exam_types, group_name from dz_subject
  17. </sql>
  18. <select id="selectDzSubjectBySubjectIds" resultMap="DzSubjectResult">
  19. <include refid="selectDzSubjectVo"/>
  20. where subject_id in <foreach item="subjectId" collection="array" open="(" separator="," close=")">#{subjectId}</foreach>
  21. </select>
  22. <select id="selectWrongSubjectList" parameterType="Long" resultMap="DzSubjectResult">
  23. SELECT s.subject_id, s.subject_name FROM `learn_wrong_book` wb JOIN dz_subject s ON wb.`subject_id` = s.`subject_id`
  24. WHERE wb.`student_id` = #{studentId}
  25. </select>
  26. <select id="selectDzSubjectList" parameterType="DzSubject" resultMap="DzSubjectResult">
  27. <include refid="selectDzSubjectVo"/>
  28. <where>
  29. <if test="subjectName != null and subjectName != ''"> and subject_name like concat('%', #{subjectName}, '%')</if>
  30. <if test="pinyin != null and pinyin != ''"> and pinyin = #{pinyin}</if>
  31. <if test="sort != null "> and sort = #{sort}</if>
  32. <if test="locations != null and locations != ''"> and locations = #{locations}</if>
  33. <if test="examTypes != null and examTypes != ''"> and exam_types like concat('%', #{examTypes}, '%') </if>
  34. </where>
  35. order by `sort`, subject_id
  36. </select>
  37. <select id="selectDzSubjectBySubjectId" parameterType="Long" resultMap="DzSubjectResult">
  38. <include refid="selectDzSubjectVo"/>
  39. where subject_id = #{subjectId}
  40. </select>
  41. <insert id="insertDzSubject" parameterType="DzSubject">
  42. insert into dz_subject
  43. <trim prefix="(" suffix=")" suffixOverrides=",">
  44. <if test="subjectId != null">subject_id,</if>
  45. <if test="subjectName != null">subject_name,</if>
  46. <if test="pinyin != null">pinyin,</if>
  47. <if test="sort != null">sort,</if>
  48. <if test="locations != null">locations,</if>
  49. <if test="examTypes != null">exam_types,</if>
  50. </trim>
  51. <trim prefix="values (" suffix=")" suffixOverrides=",">
  52. <if test="subjectId != null">#{subjectId},</if>
  53. <if test="subjectName != null">#{subjectName},</if>
  54. <if test="pinyin != null">#{pinyin},</if>
  55. <if test="sort != null">#{sort},</if>
  56. <if test="locations != null">#{locations},</if>
  57. <if test="examTypes != null">#{examTypes},</if>
  58. </trim>
  59. </insert>
  60. <update id="updateDzSubject" parameterType="DzSubject">
  61. update dz_subject
  62. <trim prefix="SET" suffixOverrides=",">
  63. <if test="subjectName != null">subject_name = #{subjectName},</if>
  64. <if test="pinyin != null">pinyin = #{pinyin},</if>
  65. <if test="sort != null">sort = #{sort},</if>
  66. <if test="locations != null">locations = #{locations},</if>
  67. <if test="examTypes != null">exam_types = #{examTypes},</if>
  68. </trim>
  69. where subject_id = #{subjectId}
  70. </update>
  71. <delete id="deleteDzSubjectBySubjectId" parameterType="Long">
  72. delete from dz_subject where subject_id = #{subjectId}
  73. </delete>
  74. <delete id="deleteDzSubjectBySubjectIds" parameterType="String">
  75. delete from dz_subject where subject_id in
  76. <foreach item="subjectId" collection="array" open="(" separator="," close=")">
  77. #{subjectId}
  78. </foreach>
  79. </delete>
  80. </mapper>