FsCourseQuestionBankMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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="questionSubType != null "> and question_sub_type = #{questionSubType}</if>
  30. <if test="status != null "> and status = #{status}</if>
  31. <if test="question != null and question != ''"> and question = #{question}</if>
  32. <if test="answer != null and answer != ''"> and answer = #{answer}</if>
  33. </where>
  34. order by sort,id
  35. </select>
  36. <select id="selectFsCourseQuestionBankById" parameterType="Long" resultMap="FsCourseQuestionBankResult">
  37. <include refid="selectFsCourseQuestionBankVo"/>
  38. where id = #{id}
  39. </select>
  40. <insert id="insertFsCourseQuestionBank" parameterType="FsCourseQuestionBank" useGeneratedKeys="true" keyProperty="id">
  41. insert into fs_course_question_bank
  42. <trim prefix="(" suffix=")" suffixOverrides=",">
  43. <if test="title != null">title,</if>
  44. <if test="sort != null">sort,</if>
  45. <if test="type != null">type,</if>
  46. <if test="status != null">status,</if>
  47. <if test="question != null">question,</if>
  48. <if test="createTime != null">create_time,</if>
  49. <if test="answer != null">answer,</if>
  50. <if test="createBy != null">create_by,</if>
  51. <if test="questionType != null">question_type,</if>
  52. <if test="questionSubType != null">question_sub_type,</if>
  53. </trim>
  54. <trim prefix="values (" suffix=")" suffixOverrides=",">
  55. <if test="title != null">#{title},</if>
  56. <if test="sort != null">#{sort},</if>
  57. <if test="type != null">#{type},</if>
  58. <if test="status != null">#{status},</if>
  59. <if test="question != null">#{question},</if>
  60. <if test="createTime != null">#{createTime},</if>
  61. <if test="answer != null">#{answer},</if>
  62. <if test="createBy != null">#{createBy},</if>
  63. <if test="questionType != null">#{questionType},</if>
  64. <if test="questionSubType != null">#{questionSubType},</if>
  65. </trim>
  66. </insert>
  67. <insert id="insertFsCourseQuestionBankBatch">
  68. INSERT INTO fs_course_question_bank (
  69. title,
  70. sort,
  71. type,
  72. status,
  73. question,
  74. create_time,
  75. answer,
  76. create_by,
  77. question_type,
  78. question_sub_type
  79. )
  80. VALUES
  81. <foreach collection="list" item="item" separator=",">
  82. (
  83. #{item.title, jdbcType=VARCHAR},
  84. #{item.sort, jdbcType=INTEGER},
  85. #{item.type, jdbcType=VARCHAR},
  86. #{item.status, jdbcType=INTEGER},
  87. #{item.question, jdbcType=CLOB},
  88. #{item.createTime, jdbcType=TIMESTAMP},
  89. #{item.answer, jdbcType=CLOB},
  90. #{item.createBy, jdbcType=VARCHAR},
  91. #{item.questionType, jdbcType=VARCHAR},
  92. #{item.questionSubType, jdbcType=VARCHAR}
  93. )
  94. </foreach>
  95. </insert>
  96. <update id="updateFsCourseQuestionBank" parameterType="FsCourseQuestionBank">
  97. update fs_course_question_bank
  98. <trim prefix="SET" suffixOverrides=",">
  99. <if test="title != null">title = #{title},</if>
  100. <if test="sort != null">sort = #{sort},</if>
  101. <if test="type != null">type = #{type},</if>
  102. <if test="status != null">status = #{status},</if>
  103. <if test="question != null">question = #{question},</if>
  104. <if test="createTime != null">create_time = #{createTime},</if>
  105. <if test="answer != null">answer = #{answer},</if>
  106. <if test="createBy != null">create_by = #{createBy},</if>
  107. <if test="questionType != null">question_type = #{questionType},</if>
  108. <if test="questionSubType != null">question_sub_type = #{questionSubType},</if>
  109. </trim>
  110. where id = #{id}
  111. </update>
  112. <delete id="deleteFsCourseQuestionBankById" parameterType="Long">
  113. delete from fs_course_question_bank where id = #{id}
  114. </delete>
  115. <delete id="deleteFsCourseQuestionBankByIds" parameterType="String">
  116. delete from fs_course_question_bank where id in
  117. <foreach item="id" collection="array" open="(" separator="," close=")">
  118. #{id}
  119. </foreach>
  120. </delete>
  121. <select id="selectFsCourseQuestionBankByIds" resultType="FsCourseQuestionBank">
  122. SELECT *
  123. FROM fs_course_question_bank
  124. WHERE id IN
  125. <foreach collection="list" item="item" open="(" separator="," close=")">
  126. #{item}
  127. </foreach>
  128. </select>
  129. </mapper>