Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yaru
fgqyxxlr
Commits
d3943079
Commit
d3943079
authored
Aug 07, 2018
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持无限级查询
parent
3d370411
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
24 deletions
+39
-24
sql/ry_20180808.sql
+11
-10
src/main/java/com/ruoyi/framework/config/ShiroConfig.java
+1
-6
src/main/java/com/ruoyi/project/system/dept/domain/Dept.java
+15
-3
src/main/java/com/ruoyi/project/system/dept/service/DeptServiceImpl.java
+4
-0
src/main/resources/mybatis/system/DeptMapper.xml
+6
-2
src/main/resources/mybatis/system/UserMapper.xml
+2
-2
src/main/resources/templates/system/user/user.html
+0
-1
No files found.
sql/ry_2018080
1
.sql
→
sql/ry_2018080
8
.sql
View file @
d3943079
...
...
@@ -5,6 +5,7 @@ drop table if exists sys_dept;
create
table
sys_dept
(
dept_id
int
(
11
)
not
null
auto_increment
comment
'部门id'
,
parent_id
int
(
11
)
default
0
comment
'父部门id'
,
ancestors
varchar
(
50
)
default
''
comment
'祖级列表'
,
dept_name
varchar
(
30
)
default
''
comment
'部门名称'
,
order_num
int
(
4
)
default
0
comment
'显示顺序'
,
leader
varchar
(
20
)
default
''
comment
'负责人'
,
...
...
@@ -21,16 +22,16 @@ create table sys_dept (
-- ----------------------------
-- 初始化-部门表数据
-- ----------------------------
insert
into
sys_dept
values
(
100
,
0
,
'若依集团'
,
0
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
101
,
100
,
'研发部门'
,
1
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
102
,
100
,
'市场部门'
,
2
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
103
,
100
,
'测试部门'
,
3
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
104
,
100
,
'财务部门'
,
4
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
105
,
100
,
'运维部门'
,
5
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
106
,
101
,
'研发一部'
,
1
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
107
,
101
,
'研发二部'
,
2
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
108
,
102
,
'市场一部'
,
1
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
109
,
102
,
'市场二部'
,
2
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'1'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
100
,
0
,
'
0'
,
'
若依集团'
,
0
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
101
,
100
,
'
0,100'
,
'
研发部门'
,
1
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
102
,
100
,
'
0,100'
,
'
市场部门'
,
2
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
103
,
100
,
'
0,100'
,
'
测试部门'
,
3
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
104
,
100
,
'
0,100'
,
'
财务部门'
,
4
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
105
,
100
,
'
0,100'
,
'
运维部门'
,
5
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
106
,
101
,
'
0,100,101'
,
'
研发一部'
,
1
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
107
,
101
,
'
0,100,101'
,
'
研发二部'
,
2
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
108
,
102
,
'
0,100,102'
,
'
市场一部'
,
1
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'0'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
insert
into
sys_dept
values
(
109
,
102
,
'
0,100,102'
,
'
市场二部'
,
2
,
'若依'
,
'15888888888'
,
'ry@qq.com'
,
'1'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
);
-- ----------------------------
...
...
src/main/java/com/ruoyi/framework/config/ShiroConfig.java
View file @
d3943079
...
...
@@ -263,12 +263,7 @@ public class ShiroConfig
shiroFilterFactoryBean
.
setFilters
(
filters
);
// 所有请求需要认证
filterChainDefinitionMap
.
put
(
"/**"
,
"user"
);
// 系统请求记录当前会话
filterChainDefinitionMap
.
put
(
"/main"
,
"onlineSession,syncOnlineSession"
);
filterChainDefinitionMap
.
put
(
"/system/**"
,
"onlineSession,syncOnlineSession"
);
filterChainDefinitionMap
.
put
(
"/monitor/**"
,
"onlineSession,syncOnlineSession"
);
filterChainDefinitionMap
.
put
(
"/tool/**"
,
"onlineSession,syncOnlineSession"
);
filterChainDefinitionMap
.
put
(
"/**"
,
"user,onlineSession,syncOnlineSession"
);
shiroFilterFactoryBean
.
setFilterChainDefinitionMap
(
filterChainDefinitionMap
);
return
shiroFilterFactoryBean
;
...
...
src/main/java/com/ruoyi/project/system/dept/domain/Dept.java
View file @
d3943079
...
...
@@ -14,6 +14,8 @@ public class Dept extends BaseEntity
private
Long
deptId
;
/** 父部门ID */
private
Long
parentId
;
/** 祖级列表 */
private
String
ancestors
;
/** 部门名称 */
private
String
deptName
;
/** 显示顺序 */
...
...
@@ -49,6 +51,16 @@ public class Dept extends BaseEntity
this
.
parentId
=
parentId
;
}
public
String
getAncestors
()
{
return
ancestors
;
}
public
void
setAncestors
(
String
ancestors
)
{
this
.
ancestors
=
ancestors
;
}
public
String
getDeptName
()
{
return
deptName
;
...
...
@@ -122,9 +134,9 @@ public class Dept extends BaseEntity
@Override
public
String
toString
()
{
return
"Dept [deptId="
+
deptId
+
", parentId="
+
parentId
+
",
deptName="
+
deptName
+
", orderNum="
+
orderNum
+
", leader="
+
leader
+
", phone="
+
phone
+
", email="
+
email
+
", status="
+
status
+
", parentName="
+
parentName
+
"]"
;
return
"Dept [deptId="
+
deptId
+
", parentId="
+
parentId
+
",
ancestors="
+
ancestors
+
", deptName="
+
deptName
+
", orderNum="
+
orderNum
+
", leader="
+
leader
+
", phone="
+
phone
+
", email="
+
email
+
",
status="
+
status
+
",
parentName="
+
parentName
+
"]"
;
}
}
src/main/java/com/ruoyi/project/system/dept/service/DeptServiceImpl.java
View file @
d3943079
...
...
@@ -119,7 +119,9 @@ public class DeptServiceImpl implements IDeptService
@Override
public
int
insertDept
(
Dept
dept
)
{
Dept
info
=
deptMapper
.
selectDeptById
(
dept
.
getParentId
());
dept
.
setCreateBy
(
ShiroUtils
.
getLoginName
());
dept
.
setAncestors
(
info
.
getAncestors
()
+
","
+
dept
.
getParentId
());
return
deptMapper
.
insertDept
(
dept
);
}
...
...
@@ -132,7 +134,9 @@ public class DeptServiceImpl implements IDeptService
@Override
public
int
updateDept
(
Dept
dept
)
{
Dept
info
=
deptMapper
.
selectDeptById
(
dept
.
getParentId
());
dept
.
setUpdateBy
(
ShiroUtils
.
getLoginName
());
dept
.
setAncestors
(
info
.
getAncestors
()
+
","
+
dept
.
getParentId
());
return
deptMapper
.
updateDept
(
dept
);
}
...
...
src/main/resources/mybatis/system/DeptMapper.xml
View file @
d3943079
...
...
@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap
type=
"Dept"
id=
"DeptResult"
>
<id
property=
"deptId"
column=
"dept_id"
/>
<result
property=
"parentId"
column=
"parent_id"
/>
<result
property=
"ancestors"
column=
"ancestors"
/>
<result
property=
"deptName"
column=
"dept_name"
/>
<result
property=
"orderNum"
column=
"order_num"
/>
<result
property=
"leader"
column=
"leader"
/>
...
...
@@ -21,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql
id=
"selectDeptVo"
>
select t.dept_id, t.parent_id, t.dept_name, t.order_num, t.leader, t.phone, t.email, t.status, t.create_by, t.create_time from sys_dept t
select t.dept_id, t.parent_id, t.
ancestors, t.
dept_name, t.order_num, t.leader, t.phone, t.email, t.status, t.create_by, t.create_time from sys_dept t
</sql>
<select
id=
"selectDeptAll"
resultMap=
"DeptResult"
>
...
...
@@ -58,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select
id=
"selectDeptById"
parameterType=
"Long"
resultMap=
"DeptResult"
>
select t.dept_id, t.parent_id, t.dept_name, t.order_num, t.leader, t.phone, t.email, t.status,
select t.dept_id, t.parent_id, t.
ancestors, t.
dept_name, t.order_num, t.leader, t.phone, t.email, t.status,
(select dept_name from sys_dept where dept_id = t.parent_id) parent_name
from sys_dept t
where dept_id = #{deptId}
...
...
@@ -69,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"deptId != null and deptId != 0"
>
dept_id,
</if>
<if
test=
"parentId != null and parentId != 0"
>
parent_id,
</if>
<if
test=
"deptName != null and deptName != ''"
>
dept_name,
</if>
<if
test=
"ancestors != null and ancestors != ''"
>
ancestors,
</if>
<if
test=
"orderNum != null and orderNum != ''"
>
order_num,
</if>
<if
test=
"leader != null and leader != ''"
>
leader,
</if>
<if
test=
"phone != null and phone != ''"
>
phone,
</if>
...
...
@@ -80,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"deptId != null and deptId != 0"
>
#{deptId},
</if>
<if
test=
"parentId != null and parentId != 0"
>
#{parentId},
</if>
<if
test=
"deptName != null and deptName != ''"
>
#{deptName},
</if>
<if
test=
"ancestors != null and ancestors != ''"
>
#{ancestors},
</if>
<if
test=
"orderNum != null and orderNum != ''"
>
#{orderNum},
</if>
<if
test=
"leader != null and leader != ''"
>
#{leader},
</if>
<if
test=
"phone != null and phone != ''"
>
#{phone},
</if>
...
...
@@ -95,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<set>
<if
test=
"parentId != null and parentId != 0"
>
parent_id = #{parentId},
</if>
<if
test=
"deptName != null and deptName != ''"
>
dept_name = #{deptName},
</if>
<if
test=
"ancestors != null and ancestors != ''"
>
ancestors = #{ancestors},
</if>
<if
test=
"orderNum != null and orderNum != ''"
>
order_num = #{orderNum},
</if>
<if
test=
"leader != null and leader != ''"
>
leader = #{leader},
</if>
<if
test=
"phone != null and phone != ''"
>
phone = #{phone},
</if>
...
...
src/main/resources/mybatis/system/UserMapper.xml
View file @
d3943079
...
...
@@ -62,8 +62,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"params != null and params.endTime != ''"
>
<!-- 结束时间检索 -->
AND date_format(u.create_time,'%y%m%d')
<
= date_format(#{params.endTime},'%y%m%d')
</if>
<if
test=
"deptId != null and
parentId != null and paren
tId != 0"
>
AND
u.dept_id IN (SELECT t.dept_id FROM sys_dept t WHERE t.dept_id = #{deptId} OR t.parent_id = #{deptId}
)
<if
test=
"deptId != null and
dep
tId != 0"
>
AND
(u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE FIND_IN_SET (#{deptId},ancestors) )
)
</if>
</select>
...
...
src/main/resources/templates/system/user/user.html
View file @
d3943079
...
...
@@ -167,7 +167,6 @@
// 树结构初始化加载
var
setting
=
{
view
:{
selectedMulti
:
false
},
data
:{
key
:{
title
:
"title"
},
simpleData
:{
enable
:
true
}},
callback
:{
onClick
:
function
(
event
,
treeId
,
treeNode
){
tree
.
expandNode
(
treeNode
);
$
(
"#deptId"
).
val
(
treeNode
.
id
);
$
(
"#parentId"
).
val
(
treeNode
.
pId
);
$
.
table
.
search
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment