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