fuliqi
2024-06-18 c46f49af9e766aed0ba583fce0efab98ebcdf76c
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?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.ExamPaperMapper">
    <resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.entity.ExamPaper">
        <id column="id"  property="id"/>
        <result column="name"  property="name"/>
        <result column="subject_id"  property="subjectId"/>
        <result column="paper_type"  property="paperType"/>
        <result column="score"  property="score"/>
        <result column="question_count"  property="questionCount"/>
        <result column="suggest_time"  property="suggestTime"/>
        <result column="visibility"  property="visibility"/>
        <result column="deduct_type" property="deductType"/>
        <result column="deduct_type_score"  property="deductTypeScore"/>
        <result column="content"  property="content"/>
        <result column="create_user"  property="createUser"/>
        <result column="create_time"  property="createTime"/>
        <result column="deleted"  property="deleted"/>
    </resultMap>
 
    <sql id="Base_Column_List">
        id, name, subject_id, paper_type, score, question_count, suggest_time,visibility
        ,deduct_type,deduct_type_score,create_user, create_time,deleted
    </sql>
 
    <resultMap id="PaperInfoResultMap" type="com.ycl.jxkg.domain.vo.student.dashboard.PaperInfo">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
 
    </resultMap>
 
 
    <select id="page" resultMap="BaseResultMap">
        SELECT
        tep.*
        FROM t_exam_paper tep
        <where>
            and tep.deleted=0
            <if test="id != null ">
                and tep.id= #{id}
            </if>
            <if test="name != null and name != ''">
                and tep.name like concat('%',#{name},'%')
            </if>
            <if test="subjectId != null ">
                and tep.subject_id= #{subjectId}
            </if>
            <if test="paperType != null ">
                and tep.paper_type= #{paperType}
            </if>
        </where>
    </select>
 
    <select id="taskExamPage" resultMap="BaseResultMap"
            parameterType="com.ycl.jxkg.domain.vo.admin.exam.ExamPaperPageRequestVO">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_exam_paper
        <where>
            and deleted=0
            and paper_type=#{paperType}
        </where>
    </select>
 
    <select id="studentPage" resultMap="BaseResultMap" parameterType="com.ycl.jxkg.domain.vo.student.exam.ExamPaperPageVO">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_exam_paper
        <where>
            and deleted=0
            <if test="subjectId != null ">
                and subject_id=#{subjectId}
            </if>
            <if test="levelId != null ">
                and grade_level=#{levelId}
            </if>
            and paper_type=#{paperType}
        </where>
    </select>
 
    <select id="indexPaper" resultMap="PaperInfoResultMap"
            parameterType="com.ycl.jxkg.domain.vo.student.dashboard.PaperFilter">
        SELECT id,name,limit_start_time,limit_end_time
        FROM t_exam_paper
        <where>
            and deleted=0
            and paper_type= #{examPaperType}
            and grade_level=#{gradeLevel}
            <if test="examPaperType == 3 ">
            </if>
            <if test="examPaperType == 4 ">
                and #{dateTime} between limit_start_time and limit_end_time
            </if>
        </where>
        ORDER BY id desc limit 5
    </select>
 
    <select id="selectAllCount" resultType="java.lang.Integer">
        SELECT count(*)
        from t_exam_paper
        where deleted = 0
    </select>
 
    <select id="selectCountByDate" resultType="com.ycl.jxkg.domain.other.KeyValue">
        SELECT create_time as name, COUNT(create_time) as value
        from
            (
            SELECT DATE_FORMAT(create_time, '%Y-%m-%d') as create_time from t_exam_paper
            WHERE deleted=0 and create_time between #{startTime} and #{endTime}
            ) a
        GROUP BY create_time
    </select>
 
    <update id="updateTaskPaper">
        update t_exam_paper set task_exam_id = #{taskId} where id in
        <foreach item="id" collection="paperIds" open="(" separator=","
                 close=")">
            #{id}
        </foreach>
    </update>
 
    <update id="clearTaskPaper" parameterType="java.util.List">
        update t_exam_paper set task_exam_id = null where id in
        <foreach item="id" collection="paperIds" open="(" separator=","
                 close=")">
            #{id}
        </foreach>
    </update>
 
</mapper>