-
Notifications
You must be signed in to change notification settings - Fork 74
/
BlogRepository.xml
178 lines (164 loc) · 6.9 KB
/
BlogRepository.xml
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?xml version="1.0" encoding="UTF-8"?>
<!-- 这是用来测试 XML 模版或标签生成的 SQL语句或参数的 Fenix XML 文件. -->
<fenixs namespace="BlogRepository">
<!-- 查询我的博客信息2. -->
<fenix id="queryBlogs2">
SELECT b FROM Blog AS b
WHERE
<in field="b.id" value="ids"/>
<andLike field="b.author" value="blog.author" match="blog.author != empty"/>
<andLike field="b.title" value="blog.title" match="blog.title != empty"/>
<andBetween field="b.createTime" start="blog.createTime" end="blog.updateTime" match="(?blog.createTime != empty) || (?blog.updateTime != empty)"/>
</fenix>
<!-- 查询我的博客信息的总数. -->
<fenix id="queryBlogs2Count">
SELECT count(*) FROM Blog AS b
WHERE
<in field="b.id" value="ids"/>
<andLike field="b.author" value="blog.author" match="blog.author != empty"/>
<andLike field="b.title" value="blog.title" match="blog.title != empty"/>
<andBetween field="b.createTime" start="blog.createTime" end="blog.updateTime" match="(?blog.createTime != empty) || (?blog.updateTime != empty)"/>
</fenix>
<!-- 根据用户ID、博客信息查询该用户发表的用户博客信息(自定义实体信息). -->
<fenix id="queryUserBlogsByTitleWithFenix">
SELECT
new com.blinkfox.fenix.vo.UserBlogInfo(u.id, u.name, b.id, b.title, b.author, b.content)
FROM
Blog as b,
com.blinkfox.fenix.entity.User as u
WHERE
u.id = b.userId
<andEqual field="b.userId" value="userId"/>
<andLike field="b.title" value="blog.title" match="blog.title != empty"/>
<andLike field="b.content" value="blog.content" match="blog.content != empty"/>
</fenix>
<!-- 根据用户ID、博客信息查询该用户发表的用户博客信息(自定义实体信息). -->
<fenix id="queryUserBlogsByProjection">
SELECT
u.id AS userId, u.name, b.id AS blogId, b.title, b.author, b.content
FROM
Blog as b,
com.blinkfox.fenix.entity.User as u
WHERE
u.id = b.userId
<andEqual field="b.userId" value="userId"/>
<andLike field="b.title" value="blog.title" match="blog.title != empty"/>
<andLike field="b.content" value="blog.content" match="blog.content != empty"/>
</fenix>
<!-- 根据用户ID、博客信息查询该用户发表的用户博客信息(自定义投影信息). -->
<fenix id="queryFenixNativeByProjection">
SELECT
u.c_id as userId,
u.c_name as name,
b.c_id as blogId,
b.c_title as title,
b.c_author as author,
b.c_content as content
FROM
t_blog as b, t_user as u
WHERE
u.c_id = b.c_user_id
<andEqual field="b.c_user_id" value="userId"/>
<andLike field="b.c_title" value="blog.title" match="blog.title != empty"/>
<andLike field="b.c_content" value="blog.content" match="blog.content != empty"/>
</fenix>
<!-- 根据用户ID、博客信息查询该用户发表的用户博客信息(用于测试返回自定义的实体信息). -->
<fenix id="queryUserBlogsWithFenixNative" resultType="com.blinkfox.fenix.vo.UserBlogInfo">
SELECT
u.c_id as userId,
u.c_name as name,
b.c_id as blogId,
b.c_title as title,
b.c_author as author,
b.c_content as content
FROM
t_blog as b, t_user as u
WHERE
u.c_id = b.c_user_id
AND b.c_user_id = #{userId}
AND b.c_title LIKE #{title}
</fenix>
<!-- 根据用户ID、博客信息查询该用户发表的用户博客信息(用于测试返回自定义的实体信息). -->
<fenix id="queryUserBlogsWithFenixResultType" resultType="com.blinkfox.fenix.vo.UserBlogInfo">
SELECT
u.id as userId,
u.name as name,
b.id as blogId,
b.title as title,
b.author as author,
b.content as content
FROM
Blog as b,
User as u
WHERE
u.id = b.userId
<andEqual field="b.userId" value="userId"/>
<andLike field="b.title" value="blog.title" match="blog.title != empty"/>
<andLike field="b.content" value="blog.content" match="blog.content != empty"/>
</fenix>
<!-- 根据用户ID、博客信息查询该用户发表的用户博客信息(用于测试返回自定义的实体信息). -->
<fenix id="queryUserBlogsWithFenixResultType2" resultType="com.blinkfox.fenix.vo.UserBlogDto">
SELECT
u.id as userId,
u.name as name,
b.id as blogId,
b.title as title,
b.author as author
FROM
Blog as b,
User as u
WHERE
u.id = b.userId
<andEqual field="b.userId" value="userId"/>
<andLike field="b.title" value="blog.title" match="blog.title != empty"/>
<andLike field="b.content" value="blog.content" match="blog.content != empty"/>
</fenix>
<!-- 根据用户ID、博客信息查询该用户发表的用户博客信息(用于测试返回自 map 的情况). -->
<fenix id="queryUserBlogMapWithFenix">
SELECT new map (
u.id as userId,
u.name as name,
b.id as blogId,
b.title as title,
b.author as author,
b.content as content)
FROM
Blog as b,
User as u
WHERE
u.id = b.userId
<andEqual field="b.userId" value="userId"/>
<andLike field="b.title" value="blog.title" match="blog.title != empty"/>
<andLike field="b.content" value="blog.content" match="blog.content != empty"/>
</fenix>
<!-- 查询根据我的博客信息,根据用户ID去重 -->
<fenix id="queryBlogsWithDistinct" resultType="com.blinkfox.fenix.entity.Blog">
SELECT
DISTINCT userId as userId
FROM Blog AS b
</fenix>
<!-- 查询根据我的博客信息,根据用户ID去重 -->
<fenix id="queryBlogsWithoutDistinct" resultType="com.blinkfox.fenix.entity.Blog">
SELECT
b as b
FROM Blog AS b
</fenix>
<!-- 查询根据我的博客信息,根据用户ID去重 -->
<fenix id="queryBlogsWithoutDistinctNative" resultType="com.blinkfox.fenix.entity.Blog">
SELECT
b.c_user_id as userId,
b.c_id as id,
b.c_author as author,
b.c_title as title,
b.c_content as content,
b.dt_create_time as createTime,
b.dt_update_time as updateTime
FROM t_blog AS b
</fenix>
<!-- 查询根据我的博客信息,根据用户ID去重 -->
<fenix id="queryBlogsWithDistinctNative">
SELECT
distinct b.c_user_id as userId
FROM t_blog AS b
</fenix>
</fenixs>