ArticleMapper.xml
4.72 KB
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
<?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.ArticleMapper">
<resultMap id="ArticleMap" type="com.sincere.student.model.Article">
<id column="id" property="id"/>
<result column="title" property="title"/>
<result column="column_type" property="columnType"/>
<result column="university_id" property="universityId"/>
<result column="sort" property="sort"/>
<result column="context" property="context"/>
<result column="author" property="author"/>
<result column="image_url" property="imageUrl"/>
<result column="video_url" property="videoUrl"/>
<result column="article_link" property="articleLink"/>
<result column="good_number" property="goodNumber"/>
<result column="look_number" property="lookNumber"/>
<result column="create_time" property="createTime"/>
<result column="type" property="type"/>
<result column="status" property="status" />
</resultMap>
<select id="getListCount" parameterType="com.sincere.student.dto.ArticleSearchDto" resultType="java.lang.Integer">
select count(0) from university_article
<where>
<if test="title != null and title != ''">
and title like #{title}
</if>
<if test="columnType != 0">
and column_type = #{columnType}
</if>
<if test="articleType != 0">
and type = #{articleType}
</if>
<if test="status == 1">
and status = 1
</if>
<if test="status != 1">
and 1 = 1
</if>
</where>
</select>
<select id="getList" parameterType="com.sincere.student.dto.ArticleSearchDto" resultMap="ArticleMap">
select * from university_article
<where>
<if test="title != null and title != ''">
and title like #{title}
</if>
<if test="columnType != 0">
and column_type = #{columnType}
</if>
<if test="articleType != 0">
and type = #{articleType}
</if>
<if test="status == 1">
and status = 1
</if>
<if test="status != 1">
and 1 = 1
</if>
</where>
order by sort
</select>
<select id="getRelationList" parameterType="java.lang.Integer" resultMap="ArticleMap">
select top 3 * from university_article where university_id = #{universityId}
</select>
<select id="selectById" parameterType="java.lang.Integer" resultMap="ArticleMap">
select * from university_article where id = #{id}
</select>
<insert id="create" parameterType="com.sincere.student.model.Article" >
insert into university_article (title,column_type,university_id,sort,context,author,image_url,video_url,article_link,good_number,look_number,create_time,type,status)
values (#{title},#{columnType},#{universityId},#{sort},#{context},#{author},#{imageUrl},#{videoUrl},#{articleLink},#{goodNumber},#{lookNumber},GETDATE(),#{type},#{status})
</insert>
<delete id="delete" parameterType="java.lang.Integer">
delete university_article where id = #{id}
</delete>
<update id="update" parameterType="com.sincere.student.model.Article">
update university_article
<trim prefix="set" suffixOverrides=",">
<if test="title!=null">
title=#{title},
</if>
<if test="columnType!=0">
column_type=#{columnType},
</if>
<if test="universityId!=0">
university_id=#{universityId},
</if>
<if test="sort!=0">
sort=#{sort},
</if>
<if test="context!=null">
context=#{context},
</if>
<if test="author!=null">
author=#{author},
</if>
<if test="imageUrl!=null">
image_url=#{imageUrl},
</if>
<if test="videoUrl!=null">
video_url=#{videoUrl},
</if>
<if test="articleLink!=null">
article_link=#{articleLink},
</if>
<if test="goodNumber!=0">
good_number=#{goodNumber},
</if>
<if test="lookNumber!=0">
look_number=#{lookNumber},
</if>
<if test="status!=-1">
status=#{status},
</if>
</trim>
where id = #{id}
</update>
</mapper>