123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.jeeplus.modules.exam.mapper.EduUserTestsDetailMapper">
-
- <sql id="eduUserTestsDetailColumns">
- a.id AS "id",
- a.tests_id AS "tests.id",
- a.question_title AS "questionTitle",
- a.question_points AS "questionPoints",
- a.question_option AS "questionOption",
- a.results AS "results",
- a.types AS "types",
- a.question_id AS "questionId"
- </sql>
-
- <sql id="eduUserTestsDetailJoins">
-
- LEFT JOIN edu_user_tests b ON b.id = a.tests_id
- </sql>
-
-
- <select id="get" resultType="EduUserTestsDetail" >
- SELECT
- <include refid="eduUserTestsDetailColumns"/>
- FROM edu_user_tests_detail a
- <include refid="eduUserTestsDetailJoins"/>
- WHERE a.id = #{id}
- </select>
-
- <select id="findList" resultType="EduUserTestsDetail" >
- SELECT
- <include refid="eduUserTestsDetailColumns"/>
- FROM edu_user_tests_detail a
- <include refid="eduUserTestsDetailJoins"/>
- <where>
-
- ${dataScope}
- <if test="tests != null and tests.id != null and tests.id != ''">
- AND a.tests_id = #{tests.id}
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
-
- <select id="findAllList" resultType="EduUserTestsDetail" >
- SELECT
- <include refid="eduUserTestsDetailColumns"/>
- FROM edu_user_tests_detail a
- <include refid="eduUserTestsDetailJoins"/>
- <where>
-
- ${dataScope}
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="findByTextId" resultType="EduUserTestsDetail" >
- SELECT d.*,q.points from edu_user_tests_detail d LEFT JOIN edu_question q on d.question_id = q.id
- LEFT JOIN edu_user_tests u ON u.id = d.tests_id
- <where>
- <if test="testsId != null and testsId != ''">
- AND d.tests_id =#{testsId}
- </if>
- <if test="userId != null and userId != ''">
- AND u.user_id=#{userId}
- </if>
- </where>
- </select>
- <select id="findErrorRanking" resultType="EduUserTestsDetail" >
- SELECT question_id,question_title,sum(case when question_points=0 then 1 else 0 end ) as num from edu_user_tests_detail
- <where>
- 1=1
- ${dataScope}
- <if test="questionTitle !=null and questionTitle!='' ">
- and question_title LIKE concat('%',#{questionTitle},'%')
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- GROUP BY question_id order by num desc
- </otherwise>
- </choose>
- </select>
- <insert id="insert">
- INSERT INTO edu_user_tests_detail(
- id,
- tests_id,
- question_title,
- question_points,
- question_option,
- results,
- types,
- question_id
- ) VALUES (
- #{id},
- #{tests.id},
- #{questionTitle},
- #{questionPoints},
- #{questionOption},
- #{results},
- #{types},
- #{questionId}
- )
- </insert>
-
- <update id="update">
- UPDATE edu_user_tests_detail SET
- tests_id = #{tests.id},
- question_title = #{questionTitle},
- question_points = #{questionPoints},
- question_option = #{questionOption},
- results = #{results},
- types=#{types},
- question_id=#{questionId}
- WHERE id = #{id}
- </update>
-
-
- <!--物理删除-->
- <update id="delete">
- DELETE FROM edu_user_tests_detail
- <choose>
- <when test="id !=null and id != ''">
- WHERE id = #{id}
- </when>
- <otherwise>
- WHERE tests_id = #{tests.id}
- </otherwise>
- </choose>
- </update>
-
- <!--逻辑删除-->
- <update id="deleteByLogic">
- UPDATE edu_user_tests_detail SET
- del_flag = #{DEL_FLAG_DELETE}
- <choose>
- <when test="id !=null and id != ''">
- WHERE id = #{id}
- </when>
- <otherwise>
- WHERE tests_id = #{tests.id}
- </otherwise>
- </choose>
- </update>
-
-
- <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
- <select id="findUniqueByProperty" resultType="EduUserTestsDetail" statementType="STATEMENT">
- select * FROM edu_user_tests_detail where ${propertyName} = '${value}'
- </select>
-
- </mapper>
|