Blame view

src/main/resources/mapper/VideoMapper.xml 6.71 KB
b9411514   陈杰   first
1
2
3
4
5
6
7
8
9
10
11
<?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.sincere.student.mapper.VideoMapper">

    <resultMap id="VideoMap" type="com.sincere.student.model.Video">
        <id column="id" property="id"/>
        <result column="university_id" property="universityId"/>
        <result column="column_type" property="columnType"/>
        <result column="video_url" property="videoUrl"/>
        <result column="sort" property="sort"/>
        <result column="create_time" property="createTime"/>
b246a387   陈杰   bug 修复
12
13
        <result column="name" property="name"/>
        <result column="code" property="code"/>
123dbb81   徐泉   研学代码提交
14
15
16
17
18
19
20
        <result column="status" property="status"/>
        <result column="logo_url" property="imgUrl"/>
        <result column="duration" property="duration"/>
        <result column="cover_url" property="coverUrl"/>
        <result column="video_name" property="videoName"/>
        <result column="read_number" property="readNumber"/>
        <result column="columnTypeString" property="columnTypeString"/>
455cb086   陈杰   bug 修复
21

b9411514   陈杰   first
22
23
    </resultMap>

cdb1817b   陈杰   bug 修复
24
25
26
27
    <update id="updateRead" parameterType="java.lang.Integer">
        update university_video set read_number = read_number + 1 where id= #{id}
    </update>

b9411514   陈杰   first
28
29
30
31
    <select id="getById" parameterType="java.lang.Integer" resultMap="VideoMap">
        select * from university_video where id = #{id}
    </select>

123dbb81   徐泉   研学代码提交
32
33
34
35
36
37
38
39
40
41
42
43
    <select id="countSort" resultMap="VideoMap">
        select * from university_video where
        <choose>
            <when test="flag ==1">
                sort >= #{sort}
            </when>
            <when test="flag ==2">
                sort >= #{sort} and id != #{id}
            </when>
        </choose>
        order by sort asc
    </select>
b246a387   陈杰   bug 修复
44

123dbb81   徐泉   研学代码提交
45
46
47
48
    <select id="getUniversityListCount" parameterType="com.sincere.student.dto.VideoSearchDto"
            resultType="java.lang.Integer">
        select count( distinct (v.university_id)) from university_video v join university_info info on v.university_id =
        info.id
b246a387   陈杰   bug 修复
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
        <where>
            <if test="columnType != 0">
                and v.column_type = #{columnType}
            </if>
            <if test="columnType == 0">
                and 1 = 1
            </if>
            <if test="universityId != 0">
                and info.id = #{universityId}
            </if>
            <if test="status == 1">
                and status = 1
            </if>
            <if test="status != 1">
                and 1 = 1
            </if>
        </where>
    </select>

    <select id="getUniversityList" parameterType="com.sincere.student.dto.VideoSearchDto" resultMap="VideoMap">
305c7810   刘康   添加阅读量
69
        select distinct v.university_id , info.name,info.code ,info.logo_url from university_video v join
123dbb81   徐泉   研学代码提交
70
        university_info info on v.university_id = info.id
b246a387   陈杰   bug 修复
71
72
73
74
75
76
77
78
79
80
81
82
83
84
        <where>
            <if test="columnType != 0">
                and v.column_type = #{columnType}
            </if>
            <if test="universityId != 0">
                and info.id = #{universityId}
            </if>
            <if test="status == 1">
                and status = 1
            </if>
            <if test="status != 1">
                and 1 = 1
            </if>
        </where>
b7a828a7   陈杰   1
85
        order by v.sort
b246a387   陈杰   bug 修复
86
87
    </select>

b9411514   陈杰   first
88
89
90
    <select id="getListCount" parameterType="com.sincere.student.dto.VideoSearchDto" resultType="java.lang.Integer">
        select count(0) from university_video v join university_info info on v.university_id = info.id
        <where>
b246a387   陈杰   bug 修复
91
92
            <if test="columnType != 0">
                and v.column_type = #{columnType}
b9411514   陈杰   first
93
            </if>
b246a387   陈杰   bug 修复
94
            <if test="columnType == 0">
b9411514   陈杰   first
95
96
                and 1 = 1
            </if>
3c7f8a2c   陈杰   bug 修复
97
            <if test="universityName != null and universityName != ''">
b9411514   陈杰   first
98
99
                and info.name like #{universityName}
            </if>
b246a387   陈杰   bug 修复
100
101
102
            <if test="universityId != 0">
                and info.id = #{universityId}
            </if>
455cb086   陈杰   bug 修复
103
104
105
106
107
            <if test="status == 1">
                and status = 1
            </if>
            <if test="status != 1">
                and 1 = 1
be5d580a   陈杰   加发布 预览功能
108
            </if>
b9411514   陈杰   first
109
110
111
        </where>
    </select>

b246a387   陈杰   bug 修复
112
    <select id="getList" parameterType="com.sincere.student.dto.VideoSearchDto" resultMap="VideoMap">
123dbb81   徐泉   研学代码提交
113
114
        select v.*,info.name,info.code ,info.logo_url , university_column_type.name as columnTypeString from
        university_video v join university_info info on v.university_id = info.id
455cb086   陈杰   bug 修复
115
        left join university_column_type on v.column_type = university_column_type.id
b9411514   陈杰   first
116
        <where>
b246a387   陈杰   bug 修复
117
118
119
120
121
            <if test="columnType != 0">
                and v.column_type = #{columnType}
            </if>
            <if test="universityId != 0">
                and info.id = #{universityId}
be5d580a   陈杰   加发布 预览功能
122
            </if>
3c7f8a2c   陈杰   bug 修复
123
            <if test="universityName != null and universityName != ''">
b9411514   陈杰   first
124
125
                and info.name like #{universityName}
            </if>
455cb086   陈杰   bug 修复
126
127
128
129
130
            <if test="status == 1">
                and status = 1
            </if>
            <if test="status != 1">
                and 1 = 1
be5d580a   陈杰   加发布 预览功能
131
            </if>
b9411514   陈杰   first
132
        </where>
123dbb81   徐泉   研学代码提交
133
        order by v.sort
b9411514   陈杰   first
134
135
    </select>

123dbb81   徐泉   研学代码提交
136
137
138
139
140
    <insert id="create" parameterType="com.sincere.student.model.Video" useGeneratedKeys="true" keyProperty="id">
        insert into university_video
        (column_type,university_id,sort,video_url,create_time,status,duration,cover_url,video_name,read_number)
        values
        (#{columnType},#{universityId},#{sort},#{videoUrl},GETDATE(),#{status},#{duration},#{coverUrl},#{videoName},#{readNumber})
b9411514   陈杰   first
141
142
143
144
145
146
147
148
149
    </insert>

    <delete id="delete" parameterType="java.lang.Integer">
        delete university_video where id = #{id}
    </delete>

    <update id="update" parameterType="com.sincere.student.model.Video">
        update university_video
        <trim prefix="set" suffixOverrides=",">
05508d96   陈杰   bug 修复
150
            <if test="videoUrl!=null and videoUrl != ''">
b9411514   陈杰   first
151
152
                video_url=#{videoUrl},
            </if>
4a51395c   陈杰   bug 修复
153
154
155
            <if test="videoName!=null and videoName != ''">
                video_name=#{videoName},
            </if>
05508d96   陈杰   bug 修复
156
157
158
            <if test="duration!=null and duration != ''">
                duration=#{duration},
            </if>
2f3069be   陈杰   bug 修复
159
160
161
            <if test="coverUrl!=null and coverUrl != ''">
                cover_url=#{coverUrl},
            </if>
be5d580a   陈杰   加发布 预览功能
162
            <if test="columnType!=0">
b9411514   陈杰   first
163
164
                column_type=#{columnType},
            </if>
be5d580a   陈杰   加发布 预览功能
165
            <if test="universityId!=0">
b9411514   陈杰   first
166
167
                university_id=#{universityId},
            </if>
be5d580a   陈杰   加发布 预览功能
168
            <if test="sort!=0">
b9411514   陈杰   first
169
170
                sort=#{sort},
            </if>
be5d580a   陈杰   加发布 预览功能
171
172
173
            <if test="status!=-1">
                status=#{status},
            </if>
455cb086   陈杰   bug 修复
174
175
176
            <if test="readNumber!=-1">
                read_number=#{readNumber},
            </if>
b9411514   陈杰   first
177
        </trim>
123dbb81   徐泉   研学代码提交
178
        where id = #{id}
b9411514   陈杰   first
179
180
    </update>
</mapper>