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
96
97
98
99
100
101
102
103
104
105
106
107
<?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.EducationResourceMapper">
 
    <select id="page" resultType="com.ycl.jxkg.domain.vo.admin.education.EducationResourceVO">
        SELECT
            ter.id,
            ter.content_type,
            ter.content_url as contentUrlString,
            ter.subject_id,
            ter.introduction,
            ter.create_time,
            ter.update_time,
            ter.attachment as attachmentString,
            ts.name as typeName,
            ter.class_id,
            tc.class_name
        FROM
        t_education_resource ter
                INNER JOIN t_subject ts ON ts.id = ter.subject_id
                INNER JOIN t_classes tc ON tc.id = ter.class_id
        <where>
            AND ter.deleted = 0
            <if test="query.introduction != null and query.introduction != ''">
                AND ter.introduction like concat('%', #{query.introduction}, '%')
            </if>
            <if test="query.subjectId != null">
                AND ter.subject_id = #{query.subjectId}
            </if>
            <if test="query.classId != null">
                AND ter.class_id = #{query.classId}
            </if>
            <if test="query.contentType != null and query.contentType != '' ">
                AND ter.content_type = #{query.contentType}
            </if>
        </where>
        ORDER BY
        ter.create_time DESC
    </select>
 
    <select id="studentPage" resultType="com.ycl.jxkg.domain.vo.admin.education.EducationResourceVO">
        SELECT
        ter.id,
        ter.content_type,
        ter.content_url as contentUrlString,
        ter.subject_id,
        ter.introduction,
        ter.create_time,
        ter.update_time,
        ter.attachment as attachmentString,
        ts.name as typeName,
        ter.class_id,
        tc.class_name
        FROM
        t_education_resource ter
        INNER JOIN t_subject ts ON ts.id = ter.subject_id
        INNER JOIN t_classes tc ON tc.id = ter.class_id
        <where>
            AND ter.deleted = 0 and ter.class_id in
            <foreach collection="query.classIds" item="classId" separator="," open="(" close=")">
                #{classId}
            </foreach>
            <if test="query.introduction != null and query.introduction != ''">
                AND ter.introduction like concat('%', #{query.introduction}, '%')
            </if>
            <if test="query.subjectId != null">
                AND ter.subject_id = #{query.subjectId}
            </if>
            <if test="query.contentType != null and query.contentType != '' ">
                AND ter.content_type = #{query.contentType}
            </if>
        </where>
        ORDER BY
        ter.create_time DESC
    </select>
 
    <insert id="add" keyColumn="id" useGeneratedKeys="true">
        INSERT INTO t_education_resource(content_type, content_url, subject_id, introduction, create_time, update_time,
                                   attachment,create_user,class_id)
            values (#{form.contentType}, #{form.contentUrl}, #{form.subjectId}, #{form.introduction}, #{form.createTime}, #{form.updateTime}, #{form.attachment},#{form.createUser},#{form.classId})
    </insert>
 
    <update id="update">
        UPDATE
        t_education_resource
        <set>
            <if test="form.contentType != null and form.contentType != ''">content_type = #{form.contentType},</if>
            <if test="form.contentUrl != null and form.contentUrl != ''">content_url = #{form.contentUrl},</if>
            <if test="form.subjectId != null">subject_id = #{form.subjectId},</if>
            <if test="form.classId != null">class_id = #{form.classId},</if>
            <if test="form.introduction != null and form.introduction != ''">introduction = #{form.introduction},</if>
            <if test="form.updateTime != null">update_time = #{form.updateTime},</if>
            attachment = #{form.attachment}
        </set>
        WHERE
        id = #{form.id}
    </update>
 
    <update id="remove">
        UPDATE t_education_resource SET deleted = 1 WHERE id IN
        <foreach collection="ids" open="(" separator="," close=")" item="id">#{id}</foreach>
    </update>
 
 
</mapper>