Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
e0c5d68f
Commit
e0c5d68f
authored
Dec 12, 2018
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善部门管理查询
parent
2dcaa929
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
176 additions
and
52 deletions
+176
-52
src/main/java/cn/stylefeng/guns/core/common/node/TreeviewNode.java
+66
-0
src/main/java/cn/stylefeng/guns/modular/system/controller/DeptController.java
+24
-2
src/main/java/cn/stylefeng/guns/modular/system/mapper/DeptMapper.java
+6
-1
src/main/java/cn/stylefeng/guns/modular/system/mapper/mapping/DeptMapper.xml
+9
-2
src/main/java/cn/stylefeng/guns/modular/system/service/DeptService.java
+10
-2
src/main/java/cn/stylefeng/guns/modular/system/warpper/DeptTreeWarpper.java
+49
-0
src/main/webapp/assets/modular/system/dept/dept.js
+11
-44
src/test/java/cn/stylefeng/guns/system/DeptTest.java
+1
-1
No files found.
src/main/java/cn/stylefeng/guns/core/common/node/TreeviewNode.java
0 → 100644
View file @
e0c5d68f
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
cn
.
stylefeng
.
guns
.
core
.
common
.
node
;
import
cn.stylefeng.roses.kernel.model.tree.Tree
;
import
lombok.Data
;
import
java.util.List
;
/**
* jquery ztree 插件的节点
*
* @author fengshuonan
* @date 2017年2月17日 下午8:25:14
*/
@Data
public
class
TreeviewNode
implements
Tree
{
/**
* 附加信息,一般用于存业务id
*/
private
String
tags
;
/**
* 父级id
*/
private
String
parentId
;
/**
* 节点名称
*/
private
String
text
;
/**
* 子节点
*/
private
List
<
TreeviewNode
>
nodes
;
@Override
public
String
getNodeId
()
{
return
tags
;
}
@Override
public
String
getNodeParentId
()
{
return
parentId
;
}
@Override
public
void
setChildrenNodes
(
List
childrenNodes
)
{
this
.
nodes
=
childrenNodes
;
}
}
src/main/java/cn/stylefeng/guns/modular/system/controller/DeptController.java
View file @
e0c5d68f
...
@@ -21,13 +21,16 @@ import cn.stylefeng.guns.core.common.annotion.Permission;
...
@@ -21,13 +21,16 @@ import cn.stylefeng.guns.core.common.annotion.Permission;
import
cn.stylefeng.guns.core.common.constant.dictmap.DeptDict
;
import
cn.stylefeng.guns.core.common.constant.dictmap.DeptDict
;
import
cn.stylefeng.guns.core.common.constant.factory.ConstantFactory
;
import
cn.stylefeng.guns.core.common.constant.factory.ConstantFactory
;
import
cn.stylefeng.guns.core.common.exception.BizExceptionEnum
;
import
cn.stylefeng.guns.core.common.exception.BizExceptionEnum
;
import
cn.stylefeng.guns.core.common.node.TreeviewNode
;
import
cn.stylefeng.guns.core.common.node.ZTreeNode
;
import
cn.stylefeng.guns.core.common.node.ZTreeNode
;
import
cn.stylefeng.guns.core.log.LogObjectHolder
;
import
cn.stylefeng.guns.core.log.LogObjectHolder
;
import
cn.stylefeng.guns.modular.system.entity.Dept
;
import
cn.stylefeng.guns.modular.system.entity.Dept
;
import
cn.stylefeng.guns.modular.system.model.DeptDto
;
import
cn.stylefeng.guns.modular.system.model.DeptDto
;
import
cn.stylefeng.guns.modular.system.service.DeptService
;
import
cn.stylefeng.guns.modular.system.service.DeptService
;
import
cn.stylefeng.guns.modular.system.warpper.DeptTreeWarpper
;
import
cn.stylefeng.guns.modular.system.warpper.DeptWarpper
;
import
cn.stylefeng.guns.modular.system.warpper.DeptWarpper
;
import
cn.stylefeng.roses.core.base.controller.BaseController
;
import
cn.stylefeng.roses.core.base.controller.BaseController
;
import
cn.stylefeng.roses.core.treebuild.DefaultTreeBuildFactory
;
import
cn.stylefeng.roses.core.util.ToolUtil
;
import
cn.stylefeng.roses.core.util.ToolUtil
;
import
cn.stylefeng.roses.kernel.model.exception.ServiceException
;
import
cn.stylefeng.roses.kernel.model.exception.ServiceException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -97,6 +100,24 @@ public class DeptController extends BaseController {
...
@@ -97,6 +100,24 @@ public class DeptController extends BaseController {
}
}
/**
/**
* 获取部门的tree列表
*/
@RequestMapping
(
value
=
"/treeview"
)
@ResponseBody
public
List
<
TreeviewNode
>
treeview
()
{
List
<
TreeviewNode
>
treeviewNodes
=
this
.
deptService
.
treeviewNodes
();
//构建树
DefaultTreeBuildFactory
<
TreeviewNode
>
factory
=
new
DefaultTreeBuildFactory
<>();
factory
.
setRootParentId
(
"0"
);
List
<
TreeviewNode
>
results
=
factory
.
doTreeBuild
(
treeviewNodes
);
//把子节点为空的设为null
DeptTreeWarpper
.
clearNull
(
results
);
return
results
;
}
/**
* 新增部门
* 新增部门
*/
*/
@BussinessLog
(
value
=
"添加部门"
,
key
=
"simplename"
,
dict
=
DeptDict
.
class
)
@BussinessLog
(
value
=
"添加部门"
,
key
=
"simplename"
,
dict
=
DeptDict
.
class
)
...
@@ -119,8 +140,9 @@ public class DeptController extends BaseController {
...
@@ -119,8 +140,9 @@ public class DeptController extends BaseController {
@RequestMapping
(
value
=
"/list"
)
@RequestMapping
(
value
=
"/list"
)
@Permission
@Permission
@ResponseBody
@ResponseBody
public
Object
list
(
String
condition
)
{
public
Object
list
(
@RequestParam
(
value
=
"condition"
,
required
=
false
)
String
condition
,
List
<
Map
<
String
,
Object
>>
list
=
this
.
deptService
.
list
(
condition
);
@RequestParam
(
value
=
"deptId"
,
required
=
false
)
String
deptId
)
{
List
<
Map
<
String
,
Object
>>
list
=
this
.
deptService
.
list
(
condition
,
deptId
);
return
super
.
warpObject
(
new
DeptWarpper
(
list
));
return
super
.
warpObject
(
new
DeptWarpper
(
list
));
}
}
...
...
src/main/java/cn/stylefeng/guns/modular/system/mapper/DeptMapper.java
View file @
e0c5d68f
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
mapper
;
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
mapper
;
import
cn.stylefeng.guns.core.common.node.TreeviewNode
;
import
cn.stylefeng.guns.core.common.node.ZTreeNode
;
import
cn.stylefeng.guns.core.common.node.ZTreeNode
;
import
cn.stylefeng.guns.modular.system.entity.Dept
;
import
cn.stylefeng.guns.modular.system.entity.Dept
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
...
@@ -26,6 +27,10 @@ public interface DeptMapper extends BaseMapper<Dept> {
...
@@ -26,6 +27,10 @@ public interface DeptMapper extends BaseMapper<Dept> {
/**
/**
* 获取所有部门列表
* 获取所有部门列表
*/
*/
List
<
Map
<
String
,
Object
>>
list
(
@Param
(
"condition"
)
String
condition
);
List
<
Map
<
String
,
Object
>>
list
(
@Param
(
"condition"
)
String
condition
,
@Param
(
"deptId"
)
String
deptId
);
/**
* 获取所有部门树列表
*/
List
<
TreeviewNode
>
treeviewNodes
();
}
}
src/main/java/cn/stylefeng/guns/modular/system/mapper/mapping/DeptMapper.xml
View file @
e0c5d68f
...
@@ -38,11 +38,18 @@
...
@@ -38,11 +38,18 @@
<select
id=
"list"
resultType=
"map"
>
<select
id=
"list"
resultType=
"map"
>
select
select
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from sys_dept
from sys_dept
where 1 = 1
<if
test=
"condition != null and condition != ''"
>
<if
test=
"condition != null and condition != ''"
>
where SIMPLE_NAME like CONCAT('%',#{condition},'%') or FULL_NAME like CONCAT('%',#{condition},'%')
and SIMPLE_NAME like CONCAT('%',#{condition},'%') or FULL_NAME like CONCAT('%',#{condition},'%')
</if>
<if
test=
"deptId != null and deptId != ''"
>
and (DEPT_ID = #{deptId} or DEPT_ID in ( select DEPT_ID from sys_dept where PIDS like CONCAT('%[', #{deptId}, ']%') ))
</if>
</if>
order by SORT ASC
order by SORT ASC
</select>
</select>
<select
id=
"treeviewNodes"
resultType=
"cn.stylefeng.guns.core.common.node.TreeviewNode"
>
select DEPT_ID AS tags, PID as parentId, SIMPLE_NAME as text from sys_dept
</select>
</mapper>
</mapper>
src/main/java/cn/stylefeng/guns/modular/system/service/DeptService.java
View file @
e0c5d68f
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
service
;
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
service
;
import
cn.stylefeng.guns.core.common.node.TreeviewNode
;
import
cn.stylefeng.guns.core.common.node.ZTreeNode
;
import
cn.stylefeng.guns.core.common.node.ZTreeNode
;
import
cn.stylefeng.guns.modular.system.entity.Dept
;
import
cn.stylefeng.guns.modular.system.entity.Dept
;
import
cn.stylefeng.guns.modular.system.mapper.DeptMapper
;
import
cn.stylefeng.guns.modular.system.mapper.DeptMapper
;
...
@@ -52,10 +53,17 @@ public class DeptService extends ServiceImpl<DeptMapper, Dept> {
...
@@ -52,10 +53,17 @@ public class DeptService extends ServiceImpl<DeptMapper, Dept> {
}
}
/**
/**
* 获取ztree的节点列表
*/
public
List
<
TreeviewNode
>
treeviewNodes
()
{
return
this
.
baseMapper
.
treeviewNodes
();
}
/**
* 获取所有部门列表
* 获取所有部门列表
*/
*/
public
List
<
Map
<
String
,
Object
>>
list
(
String
condition
)
{
public
List
<
Map
<
String
,
Object
>>
list
(
String
condition
,
String
deptId
)
{
return
this
.
baseMapper
.
list
(
condition
);
return
this
.
baseMapper
.
list
(
condition
,
deptId
);
}
}
}
}
src/main/java/cn/stylefeng/guns/modular/system/warpper/DeptTreeWarpper.java
0 → 100644
View file @
e0c5d68f
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
warpper
;
import
cn.stylefeng.guns.core.common.node.TreeviewNode
;
import
java.util.List
;
/**
* 部门列表树的包装
*
* @author fengshuonan
* @date 2017年4月25日 18:10:31
*/
public
class
DeptTreeWarpper
{
public
static
void
clearNull
(
List
<
TreeviewNode
>
list
)
{
if
(
list
==
null
)
{
return
;
}
else
{
if
(
list
.
size
()
==
0
)
{
return
;
}
else
{
for
(
TreeviewNode
node
:
list
)
{
if
(
node
.
getNodes
()
!=
null
)
{
if
(
node
.
getNodes
().
size
()
==
0
)
{
node
.
setNodes
(
null
);
}
else
{
clearNull
(
node
.
getNodes
());
}
}
}
}
}
}
}
src/main/webapp/assets/modular/system/dept/dept.js
View file @
e0c5d68f
...
@@ -7,7 +7,8 @@ var Dept = {
...
@@ -7,7 +7,8 @@ var Dept = {
table
:
null
,
table
:
null
,
layerIndex
:
-
1
,
layerIndex
:
-
1
,
condition
:
{
condition
:
{
name
:
''
name
:
''
,
deptId
:
''
}
}
};
};
...
@@ -95,59 +96,25 @@ Dept.delete = function () {
...
@@ -95,59 +96,25 @@ Dept.delete = function () {
Dept
.
search
=
function
()
{
Dept
.
search
=
function
()
{
var
queryData
=
{};
var
queryData
=
{};
queryData
[
'condition'
]
=
Dept
.
condition
.
name
;
queryData
[
'condition'
]
=
Dept
.
condition
.
name
;
queryData
[
'deptId'
]
=
Dept
.
condition
.
deptId
;
Dept
.
table
.
refresh
({
query
:
queryData
});
Dept
.
table
.
refresh
({
query
:
queryData
});
};
};
$
(
function
()
{
$
(
function
()
{
var
defaultData
=
[
//获取部门树
{
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/dept/treeview"
);
text
:
'Parent 1'
,
var
result
=
ajax
.
start
();
href
:
'#parent1'
,
tags
:
[
'4'
],
nodes
:
[
{
text
:
'Child 1'
,
href
:
'#child1'
,
tags
:
[
'2'
],
nodes
:
[
{
text
:
'Grandchild 1'
,
href
:
'#grandchild1'
,
tags
:
[
'0'
]
},
{
text
:
'Grandchild 2'
,
href
:
'#grandchild2'
,
tags
:
[
'0'
]
}
]
},
{
text
:
'Child 2'
,
href
:
'#child2'
,
tags
:
[
'0'
]
}
]
},
{
text
:
'Parent 2'
},
{
text
:
'Parent 3'
},
{
text
:
'Parent 4'
}
];
$
(
'#deptTree'
).
treeview
({
$
(
'#deptTree'
).
treeview
({
selectedBackColor
:
"#03a9f3"
,
selectedBackColor
:
"#03a9f3"
,
onhoverColor
:
"rgba(0, 0, 0, 0.05)"
,
expandIcon
:
'ti-plus'
,
expandIcon
:
'ti-plus'
,
collapseIcon
:
'ti-minus'
,
collapseIcon
:
'ti-minus'
,
nodeIcon
:
'fa fa-home'
,
data
:
result
,
data
:
defaultData
onNodeSelected
:
function
(
event
,
data
)
{
Dept
.
condition
.
deptId
=
data
.
tags
;
Dept
.
search
();
}
});
});
Dept
.
app
=
new
Vue
({
Dept
.
app
=
new
Vue
({
...
...
src/test/java/cn/stylefeng/guns/system/DeptTest.java
View file @
e0c5d68f
...
@@ -52,7 +52,7 @@ public class DeptTest extends BaseJunit {
...
@@ -52,7 +52,7 @@ public class DeptTest extends BaseJunit {
@Test
@Test
public
void
listTest
()
{
public
void
listTest
()
{
List
<
Map
<
String
,
Object
>>
list
=
this
.
deptMapper
.
list
(
"总公司"
);
List
<
Map
<
String
,
Object
>>
list
=
this
.
deptMapper
.
list
(
"总公司"
,
null
);
assertTrue
(
list
.
size
()
>
0
);
assertTrue
(
list
.
size
()
>
0
);
}
}
}
}
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