SubjectMapper.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.ie.mapper.SubjectMapper">
  6. <resultMap type="Subject" id="SubjectResult">
  7. <result property="subjectId" column="subjectId" />
  8. <result property="subjectName" column="subjectName" />
  9. <result property="pinyin" column="pinyin" />
  10. <result property="sort" column="sort" />
  11. <result property="location" column="location" />
  12. <result property="examType" column="examType" />
  13. <result property="updateTime" column="update_time" />
  14. </resultMap>
  15. <sql id="selectSubjectVo">
  16. select subjectId, subjectName, pinyin, sort, location, examType from subject
  17. </sql>
  18. <select id="selectSubjectList" parameterType="Subject" resultMap="SubjectResult">
  19. <include refid="selectSubjectVo"/>
  20. <where>
  21. <if test="subjectName != null and subjectName != ''"> and subjectName like concat('%', #{subjectName}, '%')</if>
  22. <if test="location != null and location != ''"> and (`location` IS NULL OR FIND_IN_SET(#{location}, `location`) &gt; 0)</if>
  23. <if test="examType != null and examType != ''"> and (`examType` IS NULL OR FIND_IN_SET(#{examType}, `examType`) &gt; 0)</if>
  24. <if test="subjectId != null "> and (subjectId &lt;= 3 or subjectId = #{subjectId})</if>
  25. </where>
  26. order by sort asc
  27. </select>
  28. <select id="selectSubjectListBack" parameterType="Subject" resultMap="SubjectResult">
  29. <include refid="selectSubjectVo"/>
  30. <where>
  31. <if test="subjectName != null and subjectName != ''"> and subjectName like concat('%', #{subjectName}, '%')</if>
  32. <if test="subjectId != null"> subjectId = #{subjectId}</if>
  33. </where>
  34. order by sort asc
  35. </select>
  36. <select id="selectSubjectById" parameterType="Long" resultMap="SubjectResult">
  37. <include refid="selectSubjectVo"/>
  38. where subjectId = #{subjectId}
  39. </select>
  40. <insert id="insertSubject" parameterType="Subject">
  41. insert into subject
  42. <trim prefix="(" suffix=")" suffixOverrides=",">
  43. <if test="subjectId != null">subjectId,</if>
  44. <if test="subjectName != null">subjectName,</if>
  45. <if test="pinyin != null">pinyin,</if>
  46. <if test="location != null">location,</if>
  47. <if test="examType != null">examType,</if>
  48. <if test="updateTime != null">update_time,</if>
  49. </trim>
  50. <trim prefix="values (" suffix=")" suffixOverrides=",">
  51. <if test="subjectId != null">#{subjectId},</if>
  52. <if test="subjectName != null">#{subjectName},</if>
  53. <if test="pinyin != null">#{pinyin},</if>
  54. <if test="location != null">#{location},</if>
  55. <if test="examType != null">#{examType},</if>
  56. <if test="updateTime != null">#{updateTime},</if>
  57. </trim>
  58. </insert>
  59. <update id="updateSubject" parameterType="Subject">
  60. update subject
  61. <trim prefix="SET" suffixOverrides=",">
  62. <if test="subjectName != null">subjectName = #{subjectName},</if>
  63. <if test="pinyin != null">pinyin = #{pinyin},</if>
  64. <if test="location != null">location = #{location},</if>
  65. <if test="examType != null">examType = #{examType},</if>
  66. <if test="updateTime != null">update_time=#{updateTime},</if>
  67. </trim>
  68. where subjectId = #{subjectId}
  69. </update>
  70. <delete id="deleteSubjectById" parameterType="Long">
  71. delete from subject where subjectId = #{subjectId}
  72. </delete>
  73. <delete id="deleteSubjectByIds" parameterType="String">
  74. delete from subject where subjectId in
  75. <foreach item="subjectId" collection="array" open="(" separator="," close=")">
  76. #{subjectId}
  77. </foreach>
  78. </delete>
  79. <select id="getQuestionsSubject" parameterType="Integer" resultMap="SubjectResult">
  80. select t1.subjectId,ANY_VALUE(t1.subjectName) subjectName from `subject` t1
  81. left join chapter t2 on t2.subjectId=t1.subjectId
  82. where t2.pharseId=#{phaseId}
  83. GROUP BY t1.subjectId
  84. </select>
  85. </mapper>