FsCourseQuestionBankMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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.fs.course.mapper.FsCourseQuestionBankMapper">
  6. <resultMap type="FsCourseQuestionBank" id="FsCourseQuestionBankResult">
  7. <result property="id" column="id" />
  8. <result property="title" column="title" />
  9. <result property="sort" column="sort" />
  10. <result property="type" column="type" />
  11. <result property="status" column="status" />
  12. <result property="question" column="question" />
  13. <result property="createTime" column="create_time" />
  14. <result property="answer" column="answer" />
  15. <result property="createBy" column="create_by" />
  16. <result property="questionType" column="question_type" />
  17. <result property="questionSubType" column="question_sub_type" />
  18. </resultMap>
  19. <sql id="selectFsCourseQuestionBankVo">
  20. select id, title, sort, type, status,question_type, question_sub_type, question, create_time, answer, create_by from fs_course_question_bank
  21. </sql>
  22. <select id="selectFsCourseQuestionBankList" parameterType="FsCourseQuestionBank" resultMap="FsCourseQuestionBankResult">
  23. <include refid="selectFsCourseQuestionBankVo"/>
  24. <where>
  25. <if test="title != null and title != ''"> and title like concat('%', #{title}, '%') </if>
  26. <if test="sort != null "> and sort = #{sort}</if>
  27. <if test="type != null "> and type = #{type}</if>
  28. <if test="questionType != null "> and question_type = #{questionType}</if>
  29. <if test="userId != null "> and user_id = #{userId}</if>
  30. <if test="questionSubType != null "> and question_sub_type = #{questionSubType}</if>
  31. <if test="status != null "> and status = #{status}</if>
  32. <if test="question != null and question != ''"> and question = #{question}</if>
  33. <if test="answer != null and answer != ''"> and answer = #{answer}</if>
  34. </where>
  35. order by sort,id
  36. </select>
  37. <select id="selectFsCourseQuestionBankById" parameterType="Long" resultMap="FsCourseQuestionBankResult">
  38. <include refid="selectFsCourseQuestionBankVo"/>
  39. where id = #{id}
  40. </select>
  41. <insert id="insertFsCourseQuestionBank" parameterType="FsCourseQuestionBank" useGeneratedKeys="true" keyProperty="id">
  42. insert into fs_course_question_bank
  43. <trim prefix="(" suffix=")" suffixOverrides=",">
  44. <if test="title != null">title,</if>
  45. <if test="sort != null">sort,</if>
  46. <if test="type != null">type,</if>
  47. <if test="status != null">status,</if>
  48. <if test="question != null">question,</if>
  49. <if test="createTime != null">create_time,</if>
  50. <if test="answer != null">answer,</if>
  51. <if test="createBy != null">create_by,</if>
  52. <if test="questionType != null">question_type,</if>
  53. <if test="questionSubType != null">question_sub_type,</if>
  54. <if test="userId != null">user_id,</if>
  55. </trim>
  56. <trim prefix="values (" suffix=")" suffixOverrides=",">
  57. <if test="title != null">#{title},</if>
  58. <if test="sort != null">#{sort},</if>
  59. <if test="type != null">#{type},</if>
  60. <if test="status != null">#{status},</if>
  61. <if test="question != null">#{question},</if>
  62. <if test="createTime != null">#{createTime},</if>
  63. <if test="answer != null">#{answer},</if>
  64. <if test="createBy != null">#{createBy},</if>
  65. <if test="questionType != null">#{questionType},</if>
  66. <if test="questionSubType != null">#{questionSubType},</if>
  67. <if test="userId != null">#{userId},</if>
  68. </trim>
  69. </insert>
  70. <insert id="insertFsCourseQuestionBankBatch">
  71. INSERT INTO fs_course_question_bank (
  72. title,
  73. sort,
  74. type,
  75. status,
  76. question,
  77. create_time,
  78. answer,
  79. create_by,
  80. question_type,
  81. question_sub_type,
  82. user_id
  83. )
  84. VALUES
  85. <foreach collection="list" item="item" separator=",">
  86. (
  87. #{item.title, jdbcType=VARCHAR},
  88. #{item.sort, jdbcType=INTEGER},
  89. #{item.type, jdbcType=VARCHAR},
  90. #{item.status, jdbcType=INTEGER},
  91. #{item.question, jdbcType=CLOB},
  92. #{item.createTime, jdbcType=TIMESTAMP},
  93. #{item.answer, jdbcType=CLOB},
  94. #{item.createBy, jdbcType=VARCHAR},
  95. #{item.questionType, jdbcType=VARCHAR},
  96. #{item.questionSubType, jdbcType=VARCHAR},
  97. #{item.userId, jdbcType=BIGINT}
  98. )
  99. </foreach>
  100. </insert>
  101. <update id="updateFsCourseQuestionBank" parameterType="FsCourseQuestionBank">
  102. update fs_course_question_bank
  103. <trim prefix="SET" suffixOverrides=",">
  104. <if test="title != null">title = #{title},</if>
  105. <if test="sort != null">sort = #{sort},</if>
  106. <if test="type != null">type = #{type},</if>
  107. <if test="status != null">status = #{status},</if>
  108. <if test="question != null">question = #{question},</if>
  109. <if test="createTime != null">create_time = #{createTime},</if>
  110. <if test="answer != null">answer = #{answer},</if>
  111. <if test="createBy != null">create_by = #{createBy},</if>
  112. <if test="questionType != null">question_type = #{questionType},</if>
  113. <if test="questionSubType != null">question_sub_type = #{questionSubType},</if>
  114. </trim>
  115. where id = #{id}
  116. </update>
  117. <delete id="deleteFsCourseQuestionBankById" parameterType="Long">
  118. delete from fs_course_question_bank where id = #{id}
  119. </delete>
  120. <delete id="deleteFsCourseQuestionBankByIds" parameterType="String">
  121. delete from fs_course_question_bank where id in
  122. <foreach item="id" collection="array" open="(" separator="," close=")">
  123. #{id}
  124. </foreach>
  125. </delete>
  126. <select id="selectFsCourseQuestionBankByIds" resultType="FsCourseQuestionBank">
  127. SELECT *
  128. FROM fs_course_question_bank
  129. WHERE id IN
  130. <foreach collection="list" item="item" open="(" separator="," close=")">
  131. #{item}
  132. </foreach>
  133. </select>
  134. <select id="selectFsCourseQuestionBankByTitle" resultMap="FsCourseQuestionBankResult">
  135. <include refid="selectFsCourseQuestionBankVo"/>
  136. where title = #{title}
  137. limit 1
  138. </select>
  139. <update id="updateFsCourseQuestionBankBatch">
  140. <foreach collection="list" item="item" separator=";">
  141. update fs_course_question_bank
  142. <set>
  143. <if test="item.sort != null">sort = #{item.sort},</if>
  144. <if test="item.type != null">type = #{item.type},</if>
  145. <if test="item.status != null">status = #{item.status},</if>
  146. <if test="item.question != null">question = #{item.question},</if>
  147. <if test="item.answer != null">answer = #{item.answer},</if>
  148. <if test="item.createBy != null">create_by = #{item.createBy},</if>
  149. <if test="item.questionType != null">question_type = #{item.questionType},</if>
  150. <if test="item.questionSubType != null">question_sub_type = #{item.questionSubType},</if>
  151. <if test="item.userId != null">user_id = #{item.userId},</if>
  152. </set>
  153. where title = #{item.title}
  154. </foreach>
  155. </update>
  156. </mapper>