龚焕茏
2024-07-03 3ec909b27b3eba956aa9d00cc7a94c179bd04bbf
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
<?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.mindskip.xzs.repository.OnlineStudyMapper">
 
    <select id="page" resultType="com.mindskip.xzs.domain.vo.OnlineStudyVO">
        SELECT
            tos.id,
            tos.content_type,
            tos.content_url as contentUrlString,
            tos.belong_type,
            tos.subject,
            tos.create_time,
            tos.update_time,
            tos.attachment as attachmentString,
            tst.type_name
        FROM
            t_online_study tos
                INNER JOIN t_study_type tst ON tst.id = tos.belong_type
        <where>
            AND tos.deleted = 0
            <if test="query.subject != null and query.subject != ''">
                AND tos.subject like concat('%', #{query.subject}, '%')
            </if>
            <if test="query.belongType != null">
                AND tst.id = #{query.belongType}
            </if>
        </where>
        ORDER BY
            tos.create_time DESC
    </select>
 
    <select id="byType" resultType="com.mindskip.xzs.domain.vo.OnlineStudyVO">
        SELECT
            tos.id,
            tos.content_type,
            tos.content_url as contentUrlString,
            tos.belong_type,
            tos.subject,
            tos.create_time,
            tos.update_time,
            tos.attachment as attachmentString
        FROM
            t_online_study tos
                INNER JOIN t_study_type tst ON tst.id = tos.belong_type
        <where>
            AND tos.deleted = 0
            <if test="query.subject != null and query.subject != ''">
                AND tos.subject like concat('%', #{query.subject}, '%')
            </if>
            <if test="query.belongType != null">
                AND tst.id = #{query.belongType}
            </if>
        </where>
        ORDER BY
            tos.create_time DESC
    </select>
 
    <insert id="add" keyColumn="id" useGeneratedKeys="true" parameterType="com.mindskip.xzs.domain.OnlineStudy">
        INSERT INTO t_online_study(content_type, content_url, belong_type, subject, create_time, update_time,
                                   attachment)
            value (#{form.contentType}, #{form.contentUrl}, #{form.belongType}, #{form.subject}, #{form.createTime}, #{form.updateTime}, #{form.attachment})
    </insert>
 
    <update id="update" parameterType="com.mindskip.xzs.domain.vo.OnlineStudyVO">
        UPDATE
        t_online_study
        <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.belongType != null">belong_type = #{form.belongType},</if>
            <if test="form.subject != null and form.subject != ''">subject = #{form.subject},</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_online_study SET deleted = 1 WHERE id IN
        <foreach collection="ids" open="(" separator="," close=")" item="id">#{id}</foreach>
    </update>
 
 
</mapper>