Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jz-dmp-service
Project
Project
Details
Activity
Releases
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
姚本章
jz-dmp-service
Commits
ca60e482
Commit
ca60e482
authored
Jan 26, 2021
by
sml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
树树形结构
parent
27618cd1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
120 deletions
+75
-120
DmpNavigationTreeDto.java
.../jz/dmp/modules/controller/bean/DmpNavigationTreeDto.java
+19
-0
DmpPermissionController.java
...z/dmp/modules/controller/sys/DmpPermissionController.java
+0
-115
DmpNavigationTreeServiceImpl.java
...mp/modules/service/impl/DmpNavigationTreeServiceImpl.java
+55
-4
DmpNavigationTreeMapper.xml
src/main/resources/mapper/dmp/DmpNavigationTreeMapper.xml
+1
-1
No files found.
src/main/java/com/jz/dmp/modules/controller/bean/DmpNavigationTreeDto.java
View file @
ca60e482
package
com
.
jz
.
dmp
.
modules
.
controller
.
bean
;
import
java.util.List
;
import
com.jz.dmp.modules.model.DmpNavigationTree
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
/**DMP资源导航树Dto
* @author ybz
...
...
@@ -10,4 +13,20 @@ import io.swagger.annotations.ApiModel;
@ApiModel
(
value
=
"DMP资源导航树Dto"
,
description
=
"DMP资源导航树Dto"
)
public
class
DmpNavigationTreeDto
extends
DmpNavigationTree
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"孩子节点"
)
private
List
<
DmpNavigationTreeDto
>
children
;
public
List
<
DmpNavigationTreeDto
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
DmpNavigationTreeDto
>
children
)
{
this
.
children
=
children
;
}
}
src/main/java/com/jz/dmp/modules/controller/sys/DmpPermissionController.java
View file @
ca60e482
...
...
@@ -42,121 +42,6 @@ public class DmpPermissionController {
@Autowired
private
DmpPermissionService
dmpPermissionService
;
/**列表查询资源表
* @param dmpPermissionRequest
* @return
*/
//@RequestMapping(method = RequestMethod.POST, value = "/findList")
//@ApiOperation(value = "列表查询资源表", notes = "列表查询资源表")
public
PageInfoResponse
<
DmpPermissionDto
>
findList
(
@RequestBody
DmpPermissionRequest
dmpPermissionRequest
,
HttpServletRequest
httpRequest
){
PageInfoResponse
<
DmpPermissionDto
>
pageInfo
=
new
PageInfoResponse
<
DmpPermissionDto
>();
try
{
pageInfo
=
dmpPermissionService
.
findList
(
dmpPermissionRequest
,
httpRequest
);
}
catch
(
Exception
e
)
{
pageInfo
.
setMessage
(
"查询失败"
);
pageInfo
.
setCode
(
StatuConstant
.
FAILURE_CODE
);
e
.
printStackTrace
();
}
return
pageInfo
;
}
/**主键查询资源表
* @param dmpPermissionRequest
* @return
*/
//@RequestMapping(method = RequestMethod.POST, value = "/view")
//@ApiOperation(value = "主键查询资源表", notes = "主键查询资源表")
public
BaseBeanResponse
<
DmpPermissionDto
>
view
(
@RequestBody
DmpPermissionRequest
dmpPermissionRequest
,
HttpServletRequest
httpRequest
){
BaseBeanResponse
<
DmpPermissionDto
>
baseBeanResponse
=
new
BaseBeanResponse
<
DmpPermissionDto
>();
try
{
baseBeanResponse
=
dmpPermissionService
.
findById
(
dmpPermissionRequest
,
httpRequest
);
}
catch
(
Exception
e
)
{
baseBeanResponse
.
setMessage
(
"请求失败"
);
baseBeanResponse
.
setCode
(
StatuConstant
.
FAILURE_CODE
);
e
.
printStackTrace
();
}
return
baseBeanResponse
;
}
/**删除资源表
* @param dmpPermissionRequest
* @return
*/
//@RequestMapping(method = RequestMethod.POST, value = "/delete")
//@ApiOperation(value = "删除资源表", notes = "删除资源表")
public
BaseResponse
delete
(
@RequestBody
DmpPermissionRequest
dmpPermissionRequest
,
HttpServletRequest
httpRequest
){
BaseResponse
baseResponse
=
new
BaseResponse
();
try
{
baseResponse
=
dmpPermissionService
.
deleteById
(
dmpPermissionRequest
,
httpRequest
);
}
catch
(
Exception
e
)
{
baseResponse
.
setMessage
(
"删除失败"
);
baseResponse
.
setCode
(
StatuConstant
.
FAILURE_CODE
);
e
.
printStackTrace
();
}
return
baseResponse
;
}
/**新增资源表
* @param dmpPermissionRequest
* @return
*/
//@RequestMapping(method = RequestMethod.POST, value = "/add")
//@ApiOperation(value = "新增资源表", notes = "新增资源表")
public
BaseBeanResponse
<
DmpPermission
>
add
(
@RequestBody
DmpPermission
dmpPermission
,
HttpServletRequest
httpRequest
){
BaseBeanResponse
<
DmpPermission
>
baseBeanResponse
=
new
BaseBeanResponse
<
DmpPermission
>();
try
{
baseBeanResponse
=
dmpPermissionService
.
add
(
dmpPermission
,
httpRequest
);
}
catch
(
Exception
e
)
{
baseBeanResponse
.
setMessage
(
"新增失败"
);
baseBeanResponse
.
setCode
(
StatuConstant
.
FAILURE_CODE
);
e
.
printStackTrace
();
}
return
baseBeanResponse
;
}
/**批量新增资源表
* @param dmpPermissionRequest
* @return
*/
//@RequestMapping(method = RequestMethod.POST, value = "/addBatch")
//@ApiOperation(value = "批量新增资源表", notes = "批量新增资源表")
public
BaseBeanResponse
<
DmpPermissionBatch
>
addBatch
(
@RequestBody
DmpPermissionBatch
dmpPermissionBatch
,
HttpServletRequest
httpRequest
){
BaseBeanResponse
<
DmpPermissionBatch
>
baseBeanResponse
=
new
BaseBeanResponse
<
DmpPermissionBatch
>();
try
{
baseBeanResponse
=
dmpPermissionService
.
addBatch
(
dmpPermissionBatch
,
httpRequest
);
}
catch
(
Exception
e
)
{
baseBeanResponse
.
setMessage
(
"批量新增失败"
);
baseBeanResponse
.
setCode
(
StatuConstant
.
FAILURE_CODE
);
e
.
printStackTrace
();
}
return
baseBeanResponse
;
}
/**修改资源表
* @param dmpPermissionRequest
* @return
*/
//@RequestMapping(method = RequestMethod.POST, value = "/edit")
//@ApiOperation(value = "修改资源表", notes = "修改资源表")
public
BaseBeanResponse
<
DmpPermission
>
edit
(
@RequestBody
DmpPermission
dmpPermission
,
HttpServletRequest
httpRequest
){
BaseBeanResponse
<
DmpPermission
>
baseBeanResponse
=
new
BaseBeanResponse
<
DmpPermission
>();
try
{
baseBeanResponse
=
dmpPermissionService
.
edit
(
dmpPermission
,
httpRequest
);
}
catch
(
Exception
e
)
{
baseBeanResponse
.
setMessage
(
"修改失败"
);
baseBeanResponse
.
setCode
(
StatuConstant
.
FAILURE_CODE
);
e
.
printStackTrace
();
}
return
baseBeanResponse
;
}
/**根据父级资源编码,获取当前登录用户所有资源
* @param dmpPermissionRequest
* @return
...
...
src/main/java/com/jz/dmp/modules/service/impl/DmpNavigationTreeServiceImpl.java
View file @
ca60e482
package
com
.
jz
.
dmp
.
modules
.
service
.
impl
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
com.jz.common.bean.BaseBeanResponse
;
...
...
@@ -18,6 +22,7 @@ import com.jz.dmp.modules.controller.bean.DmpNavigationTreeRequest;
import
com.jz.dmp.modules.controller.bean.MyDmpNavigationTreeConverter
;
import
com.jz.dmp.modules.dao.DmpNavigationTreeDao
;
import
com.jz.dmp.modules.model.DmpNavigationTree
;
import
com.jz.dmp.modules.model.DmpPermission
;
import
com.jz.dmp.modules.service.DmpNavigationTreeService
;
/**
...
...
@@ -145,10 +150,6 @@ public class DmpNavigationTreeServiceImpl extends BaseService implements DmpNavi
if
(!
StringUtils
.
isEmpty
(
dmpNavigationTreeRequest
.
getIsEnable
()))
{
dmpNavigationTree
.
setIsEnable
(
dmpNavigationTreeRequest
.
getIsEnable
());
}
//父节点ID
if
(
dmpNavigationTreeRequest
.
getParentId
()
!=
null
)
{
dmpNavigationTree
.
setParentId
(
dmpNavigationTreeRequest
.
getParentId
());
}
//数据状态
if
(!
StringUtils
.
isEmpty
(
dmpNavigationTreeRequest
.
getDataStatus
()))
{
dmpNavigationTree
.
setDataStatus
(
dmpNavigationTreeRequest
.
getDataStatus
());
...
...
@@ -166,12 +167,62 @@ public class DmpNavigationTreeServiceImpl extends BaseService implements DmpNavi
List
<
DmpNavigationTreeDto
>
dtos
=
MyDmpNavigationTreeConverter
.
INSTANCE
().
domain2dto
(
list
);
dtos
=
dmpArrangeTree
(
dmpNavigationTreeRequest
.
getParentId
(),
dtos
);
baseBeanResponse
.
setCode
(
StatuConstant
.
SUCCESS_CODE
);
baseBeanResponse
.
setMessage
(
"查询成功"
);
baseBeanResponse
.
setDatas
(
dtos
);
return
baseBeanResponse
;
}
/**
* @Title: treeArrangeTree
* @Description: TODO(将所有的树资源整理成树形结构)
* @param @param dmpNavigationTreeDtoes
* @param @return
* @param @throws Exception 参数
* @return List<DmpNavigationTreeDto> 返回类型
* @throws
*/
private
List
<
DmpNavigationTreeDto
>
dmpArrangeTree
(
Integer
parentId
,
List
<
DmpNavigationTreeDto
>
dmpNavigationTreeDtoes
)
throws
Exception
{
Map
<
Integer
,
List
<
DmpNavigationTreeDto
>>
dictMap
=
dmpNavigationTreeDtoes
.
stream
().
collect
(
Collectors
.
groupingBy
(
DmpNavigationTreeDto:
:
getParentId
));
List
<
DmpNavigationTreeDto
>
trees
=
dictMap
.
get
(
parentId
);
//获取顶层资源
if
(!
CollectionUtils
.
isEmpty
(
trees
))
{
for
(
DmpNavigationTreeDto
tree
:
trees
)
{
tree
=
arrangeChildren
(
tree
,
dictMap
);
}
}
return
trees
;
}
/**
* @Title: arrangeChildren
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param treeDto
* @param @param dictMap
* @param @return
* @param @throws Exception 参数
* @return DmpNavigationTreeDto 返回类型
* @throws
*/
private
DmpNavigationTreeDto
arrangeChildren
(
DmpNavigationTreeDto
treeDto
,
Map
<
Integer
,
List
<
DmpNavigationTreeDto
>>
dictMap
)
throws
Exception
{
Integer
treeId
=
treeDto
.
getId
();
List
<
DmpNavigationTreeDto
>
children
=
dictMap
.
get
(
treeId
);
if
(!
CollectionUtils
.
isEmpty
(
children
))
{
for
(
DmpNavigationTreeDto
child
:
children
)
{
child
=
arrangeChildren
(
child
,
dictMap
);
}
treeDto
.
setChildren
(
children
);
}
return
treeDto
;
}
@Override
public
DmpNavigationTree
getByProjectIdAndName
(
Long
projectId
,
String
name
)
throws
Exception
{
return
dmpNavigationTreeDao
.
getByProjectIdAndName
(
projectId
,
name
);
...
...
src/main/resources/mapper/dmp/DmpNavigationTreeMapper.xml
View file @
ca60e482
...
...
@@ -79,7 +79,7 @@
and UPDATE_TIME = #{updateTime}
</if>
<if
test=
"projectId != null"
>
and
PROJECT_ID = #{projectId}
and
(PROJECT_ID = #{projectId} or PROJECT_ID = 0)
</if>
<if
test=
"parentId != null"
>
and PARENT_ID = #{parentId}
...
...
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