ept_menuMapper.xml
4.3 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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?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.eport.rest.dao.EptMenuDao">
<sql id="EptMenuEntityColumns">
a1.MENU_ID AS "menuId"
,a1.MENU_NAME AS "menuName"
,a1.PARENT_ID AS "parentId"
,a1.MENU_URL AS "menuUrl"
,a1.SORT_ID AS "sortId"
,a1.IS_TOP AS "isTop"
,a1.IS_ADMIN AS "isAdmin"
</sql>
<sql id="EptMenuEntityListColumns">
a1.MENU_ID AS "menuId"
</sql>
<!--查询表中所有资料(所有字段) -->
<select id="listAll"
parameterType="HashMap"
resultType="com.eport.rest.entity.EptMenuEntity"
>
select
<include refid="EptMenuEntityColumns"/>
,(select MENU_NAME from ept_menu c1 where c1.MENU_ID = a1.PARENT_ID) as parentMenuName
FROM ept_menu a1
WHERE 1=1
and a1.IS_DELETE = 0
order by
SORT_ID asc
</select>
<!--分页查询资料(所有字段) -->
<select id="pageAll"
parameterType="HashMap"
resultType="com.eport.rest.entity.EptMenuEntity"
>
select
<include refid="EptMenuEntityColumns"/>
,(select MENU_NAME from ept_menu c1 where c1.MENU_ID = a1.PARENT_ID) as parentMenuName
FROM ept_menu a1
WHERE 1=1
and a1.IS_DELETE = 0
order by
SORT_ID asc
</select>
<!--查询表中所有资料(仅列表显示字段) -->
<select id="list"
parameterType="HashMap"
resultType="com.eport.rest.entity.EptMenuEntity"
>
select
<include refid="EptMenuEntityListColumns"/>
FROM ept_menu a1
WHERE 1=1
and a1.IS_DELETE = 0
order by
SORT_ID asc
</select>
<!--分页查询资料(仅列表显示字段) -->
<select id="page"
parameterType="HashMap"
resultType="com.eport.rest.entity.EptMenuEntity"
>
select
<include refid="EptMenuEntityListColumns"/>
FROM ept_menu a1
WHERE 1=1
and a1.IS_DELETE = 0
order by
SORT_ID asc
</select>
<!--根据主键查询数据 -->
<select id="findByPK"
parameterType="Integer"
resultType="com.eport.rest.entity.EptMenuEntity"
>
select
<include refid="EptMenuEntityColumns"/>
,(select MENU_NAME from ept_menu c1 where c1.MENU_ID = a1.PARENT_ID) as parentMenuName
FROM ept_menu a1
and a1.IS_DELETE = 0
WHERE a1.MENU_ID=#{par}
</select>
<!--新增数据 -->
<insert id="insert"
parameterType="com.eport.rest.entity.EptMenuEntity"
>
<selectKey resultType="Integer" order="AFTER" keyProperty="menuId">
<if test="menuId != null ">
select #{menuId} from dual
</if>
<if test="menuId == null ">
SELECT LAST_INSERT_ID() AS menuId
</if>
</selectKey>
insert
INTO ept_menu (
MENU_NAME
,PARENT_ID
,MENU_URL
,SORT_ID
,IS_TOP
,IS_ADMIN
,IS_DELETE
<if test="menuId != null ">
,MENU_ID
</if>
) VALUES (
#{menuName,jdbcType=VARCHAR}
,#{parentId,jdbcType=INTEGER}
,#{menuUrl,jdbcType=VARCHAR}
,#{sortId,jdbcType=INTEGER}
,#{isTop,jdbcType=INTEGER}
,#{isAdmin,jdbcType=INTEGER}
,#{isDelete,jdbcType=INTEGER}
<if test="menuId != null ">
,#{menuId,jdbcType=INTEGER}
</if>
)
</insert>
<!--更新数据 -->
<update id="update"
parameterType="com.eport.rest.entity.EptMenuEntity"
>
update
ept_menu
<set>
<if test="menuName != null ">
MENU_NAME = #{menuName},
</if>
<if test="parentId != null ">
PARENT_ID = #{parentId},
</if>
<if test="menuUrl != null ">
MENU_URL = #{menuUrl},
</if>
<if test="sortId != null ">
SORT_ID = #{sortId},
</if>
<if test="isTop != null ">
IS_TOP = #{isTop},
</if>
<if test="isAdmin != null ">
IS_ADMIN = #{isAdmin},
</if>
<if test="isDelete != null ">
IS_DELETE = #{isDelete},
</if>
</set>
WHERE MENU_ID = #{menuId}
</update>
<!--根据主键删除数据 -->
<delete id="delete"
parameterType="HashMap"
>
delete
from ept_menu
WHERE MENU_ID in (${par})
</delete>
<!--获取底部显示菜单 -->
<select id="getTopMenu"
parameterType="HashMap"
resultType="HashMap"
>
select a1.MENU_ID AS "menuId"
,a1.MENU_NAME AS "menuName"
,a1.PARENT_ID AS "parentId"
,a1.MENU_URL AS "menuUrl"
,a1.SORT_ID AS "sortId"
,a1.IS_TOP AS "isTop"
,(select MENU_NAME from ept_menu c1 where c1.MENU_ID = a1.PARENT_ID) as parentMenuName
FROM ept_menu a1
where a1.IS_TOP=1
and a1.IS_DELETE = 0
order by SORT_ID asc
</select>
</mapper>