OptionMapper.xml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
  3. <mapper namespace="cn.xyz.mapper.OptionMapper">
  4. <resultMap id="BaseResultMap" type="cn.xyz.mianshi.vo.QuestionOptionVO">
  5. <result column="id" property="optionId" jdbcType="INTEGER" />
  6. <result column="question_id" property="questionId" jdbcType="INTEGER" />
  7. <result column="body" property="body" jdbcType="VARCHAR" />
  8. <result column="correct" property="correct" jdbcType="INTEGER" />
  9. <result column="score" property="score" jdbcType="INTEGER" />
  10. </resultMap>
  11. <insert id="insert" parameterType="cn.xyz.mianshi.vo.QuestionOptionVO">
  12. <selectKey keyProperty="optionId" resultType="java.lang.Integer"
  13. order="AFTER">
  14. <![CDATA[
  15. SELECT LAST_INSERT_ID() as optionId
  16. ]]>
  17. </selectKey>
  18. <![CDATA[
  19. INSERT INTO tb_exam_question_option (
  20. question_id,
  21. body,
  22. correct,
  23. score
  24. )
  25. VALUES
  26. (
  27. #{questionId,jdbcType=INTEGER},
  28. #{body,jdbcType=VARCHAR},
  29. #{correct,jdbcType=INTEGER},
  30. #{score,jdbcType=INTEGER}
  31. )
  32. ]]>
  33. </insert>
  34. <delete id="delete" parameterType="java.lang.Integer">
  35. DELETE FROM tb_exam_question_option WHERE id = ${value}
  36. </delete>
  37. <update id="update" parameterType="cn.xyz.mianshi.vo.QuestionOptionVO">
  38. UPDATE tb_exam_question_option
  39. <set>
  40. <if test="questionId != null">
  41. question_id = #{questionId,jdbcType=INTEGER},
  42. </if>
  43. <if test="body != null">
  44. body = #{body,jdbcType=VARCHAR},
  45. </if>
  46. <if test="correct != null">
  47. correct = #{correct,jdbcType=INTEGER},
  48. </if>
  49. <if test="score != null">
  50. score = #{score,jdbcType=INTEGER},
  51. </if>
  52. </set>
  53. WHERE id = #{optionId,jdbcType=INTEGER}
  54. </update>
  55. <select id="selectByQuestionId" parameterType="java.lang.Integer"
  56. resultMap="BaseResultMap">
  57. SELECT * FROM tb_exam_question_option WHERE question_id = ${value}
  58. </select>
  59. <select id="selectById" parameterType="java.lang.Integer"
  60. resultMap="BaseResultMap">
  61. SELECT * FROM tb_exam_question_option WHERE id = ${value}
  62. </select>
  63. </mapper>