EduQuestionOptionMapper.xml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.jeeplus.modules.exam.mapper.EduQuestionOptionMapper">
  4. <sql id="eduQuestionOptionColumns">
  5. a.id AS "id",
  6. a.question_id AS "questionId.id",
  7. a.title AS "title",
  8. a.is_answer AS "isAnswer"
  9. </sql>
  10. <sql id="eduQuestionOptionJoins">
  11. LEFT JOIN edu_question b ON b.id = a.question_id
  12. </sql>
  13. <select id="get" resultType="EduQuestionOption">
  14. SELECT
  15. <include refid="eduQuestionOptionColumns"/>
  16. FROM edu_question_option a
  17. <include refid="eduQuestionOptionJoins"/>
  18. WHERE a.id = #{id}
  19. </select>
  20. <select id="findList" resultType="EduQuestionOption" >
  21. SELECT
  22. <include refid="eduQuestionOptionColumns"/>
  23. FROM edu_question_option a
  24. <include refid="eduQuestionOptionJoins"/>
  25. <where>
  26. ${dataScope}
  27. <if test="questionId != null and questionId != ''">
  28. AND a.question_id = #{questionId.id}
  29. </if>
  30. </where>
  31. <choose>
  32. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  33. ORDER BY ${page.orderBy}
  34. </when>
  35. <otherwise>
  36. </otherwise>
  37. </choose>
  38. </select>
  39. <select id="findAllList" resultType="EduQuestionOption" >
  40. SELECT
  41. <include refid="eduQuestionOptionColumns"/>
  42. FROM edu_question_option a
  43. <include refid="eduQuestionOptionJoins"/>
  44. <where>
  45. ${dataScope}
  46. </where>
  47. <choose>
  48. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  49. ORDER BY ${page.orderBy}
  50. </when>
  51. <otherwise>
  52. </otherwise>
  53. </choose>
  54. </select>
  55. <select id="findByTextId" resultType="EduQuestionOption" >
  56. SELECT o.*,o.question_id AS qId from edu_user_tests_detail d
  57. LEFT JOIN edu_question_option o on d.question_id = o.question_id
  58. LEFT JOIN edu_user_tests u ON u.id = d.tests_id
  59. <where>
  60. <if test="testsId != null and testsId != ''">
  61. AND d.tests_id =#{testsId}
  62. </if>
  63. <if test="userId != null and userId != ''">
  64. AND u.user_id=#{userId}
  65. </if>
  66. </where>
  67. </select>
  68. <select id="findByQuestionId" resultType="EduQuestionOption">
  69. SELECT
  70. a.id AS "id",
  71. a.title AS "title",
  72. a.is_answer AS "isAnswer"
  73. FROM edu_question_option a
  74. WHERE question_id = #{questionId}
  75. </select>
  76. <insert id="insert" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
  77. INSERT INTO edu_question_option(
  78. question_id,
  79. title,
  80. is_answer
  81. ) VALUES (
  82. #{questionId.id},
  83. #{title},
  84. #{isAnswer}
  85. )
  86. </insert>
  87. <update id="update">
  88. UPDATE edu_question_option SET
  89. question_id = #{questionId.id},
  90. title = #{title},
  91. is_answer = #{isAnswer}
  92. WHERE id = #{id}
  93. </update>
  94. <!--物理删除-->
  95. <update id="delete">
  96. DELETE FROM edu_question_option
  97. <choose>
  98. <when test="id !=null and id != ''">
  99. WHERE id = #{id}
  100. </when>
  101. <otherwise>
  102. WHERE question_id = #{questionId.id}
  103. </otherwise>
  104. </choose>
  105. </update>
  106. <!--逻辑删除-->
  107. <update id="deleteByLogic">
  108. UPDATE edu_question_option SET
  109. del_flag = #{DEL_FLAG_DELETE}
  110. <choose>
  111. <when test="id !=null and id != ''">
  112. WHERE id = #{id}
  113. </when>
  114. <otherwise>
  115. WHERE question_id = #{questionId.id}
  116. </otherwise>
  117. </choose>
  118. </update>
  119. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  120. <select id="findUniqueByProperty" resultType="EduQuestionOption" statementType="STATEMENT">
  121. select * FROM edu_question_option where ${propertyName} = '${value}'
  122. </select>
  123. </mapper>