fuliqi
2024-10-17 8546b3d285af4235a0ef615a0c6e89486ae2c806
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?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.ycl.jxkg.mapper.ExamSubmitTempMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.vo.ExamSubmitTempVO">
        <result column="exam_id" property="examId" />
        <result column="user_id" property="userId" />
        <result column="do_time" property="doTime" />
        <result column="exam_submit" property="examSubmit" />
        <result column="create_time" property="createTime" />
        <result column="status" property="status" />
    </resultMap>
 
    <select id="getById" resultMap="BaseResultMap">
        SELECT
            TEST.exam_id,
            TEST.user_id,
            TEST.do_time,
            TEST.exam_submit,
            TEST.create_time,
            TEST.status,
            TEST.id
        FROM
            t_exam_submit_temp TEST
        WHERE
            TEST.id = #{id} AND TEST.deleted = 0
    </select>
 
    <select id="getPage" resultMap="BaseResultMap">
        SELECT
            TEST.exam_id,
            TEST.user_id,
            TEST.do_time,
            TEST.exam_submit,
            TEST.create_time,
            TEST.status,
            TEST.id
        FROM
            t_exam_submit_temp TEST
        WHERE
            TEST.deleted = 0
    </select>
 
<!--    <select id="monitorList" resultType="com.ycl.jxkg.domain.vo.ExamSubmitTempVO">-->
<!--        SELECT-->
<!--            TEST.exam_id,-->
<!--            TEST.user_id,-->
<!--            TEST.do_time,-->
<!--            TEST.exam_submit,-->
<!--            TEST.create_time,-->
<!--            TEST.status,-->
<!--            TEST.id,-->
<!--            TE.exam_name,-->
<!--            TU.real_name as userName-->
<!--        FROM-->
<!--            t_exam_submit_temp TEST-->
<!--        INNER JOIN t_user TU ON TU.id = TEST.user_id AND TU.deleted = 0-->
<!--        INNER JOIN t_exam TE ON TE.id = TEST.exam_id AND TE.deleted = 0-->
<!--        WHERE-->
<!--            TEST.deleted = 0-->
<!--        <if test="query.examId != null">-->
<!--            AND TEST.exam_id = #{query.examId}-->
<!--        </if>-->
<!--        <if test="query.keyword != null and query.keyword != ''">-->
<!--            AND (INSTR(TU.real_name, #{query.keyword}) OR INSTR(TE.exam_name, #{query.keyword}))-->
<!--        </if>-->
<!--    </select>-->
 
    <select id="monitorList" resultType="com.ycl.jxkg.domain.vo.ExamSubmitTempVO">
        SELECT
        te.id as examId,
        TU.id as userId,
        TEST.do_time,
        TEST.exam_submit,
        TEST.create_time,
        TEST.status,
        TEST.id,
        TE.exam_name,
        TU.real_name as userName
        FROM
        t_exam TE
        LEFT JOIN t_classes_user TCU ON TE.classes_id = TCU.classes_id AND TCU.deleted = 0
        INNER JOIN t_user TU ON TU.id = TCU.user_id AND TU.deleted = 0
        LEFT JOIN t_exam_submit_temp TEST ON TE.id = TEST.exam_id AND TCU.user_id = TEST.user_id AND (TEST.deleted = 0 or TEST.deleted is null)
        WHERE
        TE.deleted = 0
        <if test="query.examId != null">
            AND TE.id = #{query.examId}
        </if>
        <if test="query.keyword != null and query.keyword != ''">
            AND (INSTR(TU.real_name, #{query.keyword}) OR INSTR(TE.exam_name, #{query.keyword}))
        </if>
    </select>
</mapper>