NewsDictMapper.xml
3.79 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
<?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.laowu.mapper.NewsDictMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.laowu.model.NewsDictDO">
<id column="id" property="id" />
<result column="create_date" property="createDate" />
<result column="update_date" property="updateDate" />
<result column="delete_date" property="deleteDate" />
<result column="title" property="title" />
<result column="guiding" property="guiding" />
<result column="status" property="status" />
<result column="publish_date" property="publishDate" />
<result column="publish_id" property="publishId" />
<result column="content" property="content" />
<result column="cover_page" property="coverPage" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
create_date,
update_date,
delete_date,
id, title, guiding, status, publish_date, publish_id, content, cover_page
</sql>
<select id="news" resultType="com.laowu.vo.lables.NewsVO">
SELECT DISTINCT
t2.id,
t2.title,
t2.guiding,
t2.`status`,
t2.publish_date,
t3.user_name,
t2.top_flag,
t2.cover_page
FROM
news_labels t
LEFT JOIN news_dict t2 ON t.news_id = t2.id
LEFT JOIN administer t3 ON t2.publish_id = t3.id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
<if test="labelId != null and labelId != ''">
AND t.label_id = #{labelId}
</if>
<if test="title != null and title != ''">
AND t2.title like concat('%', #{title}, '%')
</if>
order by t2.top_flag desc,t2.publish_date desc
</select>
<select id="newsLabels" parameterType="long" resultType="com.laowu.model.NewsLabelDictDO">
SELECT
t2.*
FROM
news_labels t
LEFT JOIN news_label_dict t2 ON t.label_id = t2.id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t.news_id = #{newsId}
</select>
<update id="updateTopStatus">
update news_dict set top_flag = 0
</update>
<select id="oneNews" resultType="com.laowu.vo.lables.NewsVO">
SELECT DISTINCT
t2.id,
t2.title,
t2.guiding,
t2.`status`,
t2.publish_date,
t3.user_name,
t2.top_flag,
t2.cover_page,
t2.content
FROM
news_labels t
LEFT JOIN news_dict t2 ON t.news_id = t2.id
LEFT JOIN administer t3 ON t2.publish_id = t3.id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
and t2.id = #{id}
</select>
<select id="noTopNews" resultType="com.laowu.vo.lables.NewsVO">
SELECT DISTINCT
t2.id,
t2.title,
t2.guiding,
t2.`status`,
t2.publish_date,
t3.user_name,
t2.top_flag,
t2.cover_page
FROM
news_labels t
LEFT JOIN news_dict t2 ON t.news_id = t2.id
LEFT JOIN administer t3 ON t2.publish_id = t3.id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
and t2.top_flag != 1
and t2.status = '已发布'
<if test="labelId != null and labelId != ''">
AND t.label_id = #{labelId}
</if>
<if test="title != null and title != ''">
AND t2.title like concat('%', #{title}, '%')
</if>
order by t2.top_flag desc,t2.publish_date desc
</select>
</mapper>