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
fd75ee49
Commit
fd75ee49
authored
Aug 14, 2018
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
部门修改同步ancestor
parent
f67d7179
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
1 deletions
+49
-1
src/main/java/com/ruoyi/project/system/dept/mapper/DeptMapper.java
+9
-0
src/main/java/com/ruoyi/project/system/dept/service/DeptServiceImpl.java
+24
-1
src/main/resources/mybatis/system/DeptMapper.xml
+16
-0
No files found.
src/main/java/com/ruoyi/project/system/dept/mapper/DeptMapper.java
View file @
fd75ee49
package
com
.
ruoyi
.
project
.
system
.
dept
.
mapper
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Param
;
import
com.ruoyi.project.system.dept.domain.Dept
;
/**
...
...
@@ -66,6 +67,14 @@ public interface DeptMapper
public
int
updateDept
(
Dept
dept
);
/**
* 修改子元素关系
*
* @param depts 子元素
* @return 结果
*/
public
int
updateDeptChildren
(
@Param
(
"depts"
)
List
<
Dept
>
depts
);
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
...
...
src/main/java/com/ruoyi/project/system/dept/service/DeptServiceImpl.java
View file @
fd75ee49
...
...
@@ -135,12 +135,35 @@ public class DeptServiceImpl implements IDeptService
public
int
updateDept
(
Dept
dept
)
{
Dept
info
=
deptMapper
.
selectDeptById
(
dept
.
getParentId
());
String
ancestors
=
info
.
getAncestors
()
+
","
+
dept
.
getParentId
();
dept
.
setUpdateBy
(
ShiroUtils
.
getLoginName
());
dept
.
setAncestors
(
info
.
getAncestors
()
+
","
+
dept
.
getParentId
());
dept
.
setAncestors
(
ancestors
);
updateDeptChildren
(
dept
.
getDeptId
(),
ancestors
);
return
deptMapper
.
updateDept
(
dept
);
}
/**
* 修改子元素关系
*
* @param deptId 部门ID
* @param ancestors 元素列表
*/
public
void
updateDeptChildren
(
Long
deptId
,
String
ancestors
)
{
Dept
dept
=
new
Dept
();
dept
.
setParentId
(
deptId
);
List
<
Dept
>
childrens
=
deptMapper
.
selectDeptList
(
dept
);
for
(
Dept
children
:
childrens
)
{
children
.
setAncestors
(
ancestors
+
","
+
dept
.
getParentId
());
}
if
(
childrens
.
size
()
>
0
)
{
deptMapper
.
updateDeptChildren
(
childrens
);
}
}
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
...
...
src/main/resources/mybatis/system/DeptMapper.xml
View file @
fd75ee49
...
...
@@ -32,6 +32,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select
id=
"selectDeptList"
parameterType=
"Dept"
resultMap=
"DeptResult"
>
<include
refid=
"selectDeptVo"
/>
<where>
<if
test=
"parentId != null and parentId != 0"
>
AND parent_id = #{parentId}
</if>
<if
test=
"deptName != null and deptName != ''"
>
AND dept_name like concat('%', #{deptName}, '%')
</if>
...
...
@@ -109,6 +112,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</set>
where dept_id = #{deptId}
</update>
<update
id=
"updateDeptChildren"
parameterType=
"java.util.List"
>
update sys_dept set ancestors =
<foreach
collection=
"depts"
item=
"item"
index=
"index"
separator=
" "
open=
"case dept_id"
close=
"end"
>
when #{item.deptId} then #{item.ancestors}
</foreach>
where dept_id in
<foreach
collection=
"depts"
item=
"item"
index=
"index"
separator=
","
open=
"("
close=
")"
>
#{item.deptId}
</foreach>
</update>
<delete
id=
"deleteDeptById"
parameterType=
"Long"
>
delete from sys_dept where dept_id = #{deptId}
...
...
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