Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
普蓝开源社区
盘古开发框架
提交
0566adad
盘古开发框架
项目概览
普蓝开源社区
/
盘古开发框架
通知
25
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
盘古开发框架
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0566adad
编写于
5月 23, 2019
作者:
X
xiongchun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
重构资源模块和诸多改进
上级
f2f41520
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
198 addition
and
79 deletion
+198
-79
myclouds-base/src/main/java/com/gitee/myclouds/base/helper/treebuiler/TreeBuilder.java
...om/gitee/myclouds/base/helper/treebuiler/TreeBuilder.java
+87
-0
myclouds-base/src/main/java/com/gitee/myclouds/base/helper/treebuiler/TreeNodeVO.java
...com/gitee/myclouds/base/helper/treebuiler/TreeNodeVO.java
+33
-0
myclouds-base/src/main/java/com/gitee/myclouds/base/vo/DictVO.java
...base/src/main/java/com/gitee/myclouds/base/vo/DictVO.java
+4
-0
myclouds-base/src/main/java/com/gitee/myclouds/base/vo/OutVO.java
...-base/src/main/java/com/gitee/myclouds/base/vo/OutVO.java
+4
-33
myclouds-base/src/main/java/com/gitee/myclouds/base/vo/UserVO.java
...base/src/main/java/com/gitee/myclouds/base/vo/UserVO.java
+4
-0
myclouds-builder/src/main/resources/template/entity.java.vm
myclouds-builder/src/main/resources/template/entity.java.vm
+4
-0
myclouds-system-service/src/main/java/com/gitee/myclouds/system/common/vo/MenuVO.java
...main/java/com/gitee/myclouds/system/common/vo/MenuVO.java
+4
-0
myclouds-system-service/src/main/java/com/gitee/myclouds/system/module/module/ModuleController.java
...gitee/myclouds/system/module/module/ModuleController.java
+15
-17
myclouds-system-service/src/main/java/com/gitee/myclouds/system/module/module/ModuleMapper.xml
.../com/gitee/myclouds/system/module/module/ModuleMapper.xml
+4
-10
myclouds-system-service/src/main/java/com/gitee/myclouds/system/module/module/ModuleService.java
...om/gitee/myclouds/system/module/module/ModuleService.java
+39
-19
未找到文件。
myclouds-base/src/main/java/com/gitee/myclouds/base/helper/treebuiler/TreeBuilder.java
0 → 100644
浏览文件 @
0566adad
package
com.gitee.myclouds.base.helper.treebuiler
;
import
java.util.List
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.collect.Lists
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* 树结构数据模型构造器
*
* @author xiongchun
*
*/
public
class
TreeBuilder
{
@Getter
@Setter
List
<
TreeNodeVO
>
nodes
=
Lists
.
newArrayList
();
public
TreeBuilder
()
{
}
public
TreeBuilder
(
List
<
TreeNodeVO
>
nodes
)
{
super
();
this
.
nodes
=
nodes
;
}
public
String
buildJSONTree
()
{
List
<
TreeNodeVO
>
nodeTree
=
buildTree
();
return
JSON
.
toJSONString
(
nodeTree
);
}
public
List
<
TreeNodeVO
>
buildTree
()
{
List
<
TreeNodeVO
>
treeTreeNodeVOs
=
Lists
.
newArrayList
();
List
<
TreeNodeVO
>
rootTreeNodeVOs
=
getParentTreeNodes
();
for
(
TreeNodeVO
rootTreeNodeVO
:
rootTreeNodeVOs
)
{
buildChildTreeNodes
(
rootTreeNodeVO
);
treeTreeNodeVOs
.
add
(
rootTreeNodeVO
);
}
return
treeTreeNodeVOs
;
}
private
void
buildChildTreeNodes
(
TreeNodeVO
node
)
{
List
<
TreeNodeVO
>
children
=
getChildTreeNodes
(
node
);
if
(!
children
.
isEmpty
())
{
for
(
TreeNodeVO
child
:
children
)
{
buildChildTreeNodes
(
child
);
}
node
.
setChildren
(
children
);
}
}
public
List
<
TreeNodeVO
>
getChildTreeNodes
(
TreeNodeVO
pnode
)
{
List
<
TreeNodeVO
>
childTreeNodeVOs
=
Lists
.
newArrayList
();
for
(
TreeNodeVO
n
:
nodes
)
{
if
(
pnode
.
getId
().
equals
(
n
.
getPId
()))
{
childTreeNodeVOs
.
add
(
n
);
}
}
return
childTreeNodeVOs
;
}
private
boolean
isParentNode
(
TreeNodeVO
node
)
{
boolean
isParentNode
=
true
;
for
(
TreeNodeVO
n
:
nodes
)
{
if
(
node
.
getPId
().
equals
(
n
.
getId
()))
{
isParentNode
=
false
;
break
;
}
}
return
isParentNode
;
}
public
List
<
TreeNodeVO
>
getParentTreeNodes
()
{
List
<
TreeNodeVO
>
rootTreeNodeVOs
=
Lists
.
newArrayList
();
for
(
TreeNodeVO
n
:
nodes
)
{
if
(
isParentNode
(
n
))
{
rootTreeNodeVOs
.
add
(
n
);
}
}
return
rootTreeNodeVOs
;
}
}
myclouds-base/src/main/java/com/gitee/myclouds/base/helper/treebuiler/TreeNodeVO.java
0 → 100644
浏览文件 @
0566adad
package
com.gitee.myclouds.base.helper.treebuiler
;
import
java.io.Serializable
;
import
java.util.List
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
/**
* 树节点VO
*
* @author xiongchun
*
*/
@Data
@Accessors
(
chain
=
true
)
public
class
TreeNodeVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
// 节点ID
private
String
id
;
// 父节点ID
private
String
pId
;
// 节点名称
private
String
label
;
// 子孙节点集合
private
List
<
TreeNodeVO
>
children
;
}
myclouds-base/src/main/java/com/gitee/myclouds/base/vo/DictVO.java
浏览文件 @
0566adad
...
...
@@ -3,6 +3,8 @@ package com.gitee.myclouds.base.vo;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.ToString
;
import
lombok.experimental.Accessors
;
/**
* 数据字典通用值对象
...
...
@@ -11,6 +13,8 @@ import lombok.Data;
*
*/
@Data
@ToString
@Accessors
(
chain
=
true
)
public
class
DictVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
myclouds-base/src/main/java/com/gitee/myclouds/base/vo/OutVO.java
浏览文件 @
0566adad
...
...
@@ -2,8 +2,9 @@ package com.gitee.myclouds.base.vo;
import
java.io.Serializable
;
import
lombok.
Getter
;
import
lombok.
Data
;
import
lombok.ToString
;
import
lombok.experimental.Accessors
;
/**
* 接口返回通用值对象
...
...
@@ -11,8 +12,9 @@ import lombok.ToString;
* @author xiongchun
*
*/
@
Getter
@
Data
@ToString
@Accessors
(
chain
=
true
)
public
class
OutVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -41,35 +43,4 @@ public class OutVO implements Serializable{
public
OutVO
(
int
code
)
{
setCode
(
code
);
}
public
OutVO
setCode
(
int
code
)
{
this
.
code
=
code
;
return
this
;
}
public
OutVO
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
return
this
;
}
public
OutVO
setCount
(
int
count
)
{
this
.
count
=
count
;
return
this
;
}
public
OutVO
setData
(
Object
data
)
{
this
.
data
=
data
;
return
this
;
}
public
OutVO
setTrace
(
String
trace
)
{
this
.
trace
=
trace
;
return
this
;
}
public
OutVO
setAdvice
(
String
advice
)
{
this
.
advice
=
advice
;
return
this
;
}
}
myclouds-base/src/main/java/com/gitee/myclouds/base/vo/UserVO.java
浏览文件 @
0566adad
...
...
@@ -4,6 +4,8 @@ import java.io.Serializable;
import
java.util.List
;
import
lombok.Data
;
import
lombok.ToString
;
import
lombok.experimental.Accessors
;
/**
* 当前会话用户数据对象
...
...
@@ -12,6 +14,8 @@ import lombok.Data;
*
*/
@Data
@ToString
@Accessors
(
chain
=
true
)
public
class
UserVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
myclouds-builder/src/main/resources/template/entity.java.vm
浏览文件 @
0566adad
...
...
@@ -21,6 +21,8 @@ import java.sql.Timestamp;
import java.io.Serializable;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
##java.lang.*下的类型不需要导入
/**
...
...
@@ -33,6 +35,8 @@ import lombok.Data;
* @date
$
!sysdate
*/
@Data
@ToString
@Accessors(chain = true)
public class
${
tableDto
.
upname
}
Entity implements Serializable
{
private static final long serialVersionUID = 1L;
...
...
myclouds-system-service/src/main/java/com/gitee/myclouds/system/common/vo/MenuVO.java
浏览文件 @
0566adad
...
...
@@ -4,6 +4,8 @@ import java.io.Serializable;
import
java.util.List
;
import
lombok.Data
;
import
lombok.ToString
;
import
lombok.experimental.Accessors
;
/**
* 功能菜单简单值对象(配合前端使用的数据结构)
...
...
@@ -12,6 +14,8 @@ import lombok.Data;
*
*/
@Data
@ToString
@Accessors
(
chain
=
true
)
public
class
MenuVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
myclouds-system-service/src/main/java/com/gitee/myclouds/system/module/module/ModuleController.java
浏览文件 @
0566adad
...
...
@@ -3,14 +3,12 @@ package com.gitee.myclouds.system.module.module;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.gitee.myclouds.base.vo.OutVO
;
import
com.gitee.myclouds.common.wrapper.Dto
;
import
com.gitee.myclouds.common.wrapper.Dtos
;
/**
...
...
@@ -34,7 +32,7 @@ public class ModuleController {
*/
@RequestMapping
(
value
=
"list"
,
produces
=
"application/json"
)
public
OutVO
list
(
@RequestBody
Map
<
String
,
Object
>
inMap
){
return
moduleService
.
list
(
Dtos
.
new
Page
Dto
(
inMap
));
return
moduleService
.
list
(
Dtos
.
newDto
(
inMap
));
}
/**
...
...
@@ -43,9 +41,9 @@ public class ModuleController {
* @param inMap
* @return
*/
@RequestMapping
(
value
=
"get"
,
method
=
{
RequestMethod
.
POST
},
produces
=
"application/json"
)
public
String
get
(
@RequestParam
Integer
id
){
return
moduleService
.
get
(
id
);
@RequestMapping
(
value
=
"get"
,
produces
=
"application/json"
)
public
OutVO
get
(
@RequestBody
Map
<
String
,
Object
>
inMap
){
return
moduleService
.
get
(
Dtos
.
newDto
(
inMap
).
getInteger
(
"id"
)
);
}
/**
...
...
@@ -54,9 +52,9 @@ public class ModuleController {
* @param inMap
* @return
*/
@
RequestMapping
(
value
=
"save"
,
method
=
{
RequestMethod
.
POST
}
,
produces
=
"application/json"
)
public
Dto
save
(
@RequestParam
Map
<
String
,
Object
>
inMap
){
return
moduleService
.
save
(
Dtos
.
newDto
(
inMap
));
@
PostMapping
(
value
=
"add"
,
produces
=
"application/json"
)
public
OutVO
add
(
@RequestBody
Map
<
String
,
Object
>
inMap
){
return
moduleService
.
add
(
Dtos
.
newDto
(
inMap
));
}
/**
...
...
@@ -65,8 +63,8 @@ public class ModuleController {
* @param inMap
* @return
*/
@
RequestMapping
(
value
=
"update"
,
method
=
{
RequestMethod
.
POST
}
,
produces
=
"application/json"
)
public
Dto
update
(
@RequestParam
Map
<
String
,
Object
>
inMap
){
@
PostMapping
(
value
=
"update"
,
produces
=
"application/json"
)
public
OutVO
update
(
@RequestBody
Map
<
String
,
Object
>
inMap
){
return
moduleService
.
update
(
Dtos
.
newDto
(
inMap
));
}
...
...
@@ -76,19 +74,19 @@ public class ModuleController {
* @param inMap
* @return
*/
@
RequestMapping
(
value
=
"delete"
,
method
=
{
RequestMethod
.
POST
}
,
produces
=
"application/json"
)
public
Dto
delete
(
@RequestParam
Map
<
String
,
Object
>
inMap
){
@
PostMapping
(
value
=
"delete"
,
produces
=
"application/json"
)
public
OutVO
delete
(
@RequestBody
Map
<
String
,
Object
>
inMap
){
return
moduleService
.
delete
(
Dtos
.
newDto
(
inMap
));
}
/**
*查询资源树
*查询资源树
(返回树桩数据模型)
*
* @param inMap
* @return
*/
@RequestMapping
(
value
=
"list
ModuleTree"
,
method
=
{
RequestMethod
.
POST
}
,
produces
=
"application/json"
)
public
String
listOrgTree
(
@RequestParam
Map
<
String
,
Object
>
inMap
){
@RequestMapping
(
value
=
"list
Tree"
,
produces
=
"application/json"
)
public
OutVO
listTree
(
@RequestBody
Map
<
String
,
Object
>
inMap
){
return
moduleService
.
listModuleTree
(
Dtos
.
newDto
(
inMap
));
}
...
...
myclouds-system-service/src/main/java/com/gitee/myclouds/system/module/module/ModuleMapper.xml
浏览文件 @
0566adad
...
...
@@ -33,21 +33,15 @@
FROM my_role_module WHERE module_id = #{module_id}
</select>
<!-- 查询资源树 -->
<select
id=
"listModuleTree"
resultType=
"
Dto
"
parameterType=
"Dto"
>
<!-- 查询资源树
集合
-->
<select
id=
"listModuleTree"
resultType=
"
TreeNodeVO
"
parameterType=
"Dto"
>
SELECT
id,
parent_id AS pId,
name
name
AS label
FROM
my_module
<where>
type IN
<foreach
item=
"type"
index=
"index"
collection=
"types"
open=
"("
separator=
","
close=
")"
>
#{type}
</foreach>
</where>
ORDER BY parent_id, sort_no
ORDER BY sort_no
</select>
<!-- 统计直系子节点个数 -->
...
...
myclouds-system-service/src/main/java/com/gitee/myclouds/system/module/module/ModuleService.java
浏览文件 @
0566adad
...
...
@@ -5,8 +5,11 @@ import java.util.List;
import
org.apache.ibatis.session.SqlSession
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.alibaba.fastjson.JSON
;
import
com.gitee.myclouds.base.exception.BizException
;
import
com.gitee.myclouds.base.helper.treebuiler.TreeBuilder
;
import
com.gitee.myclouds.base.helper.treebuiler.TreeNodeVO
;
import
com.gitee.myclouds.base.vo.OutVO
;
import
com.gitee.myclouds.common.util.MyUtil
;
import
com.gitee.myclouds.common.wrapper.Dto
;
...
...
@@ -47,9 +50,19 @@ public class ModuleService {
* @param id
* @return
*/
public
String
get
(
Integer
id
)
{
public
OutVO
get
(
Integer
id
)
{
OutVO
outVO
=
new
OutVO
(
0
);
MyModuleEntity
myModuleEntity
=
myModuleMapper
.
selectByKey
(
id
);
return
JSON
.
toJSONString
(
myModuleEntity
);
MyModuleEntity
parentEntity
=
myModuleMapper
.
selectByKey
(
myModuleEntity
.
getParent_id
());
Dto
dto
=
Dtos
.
newDto
();
MyUtil
.
copyProperties
(
myModuleEntity
,
dto
);
if
(
MyUtil
.
isNotEmpty
(
parentEntity
))
{
dto
.
put
(
"parent_name"
,
parentEntity
.
getName
());
}
else
{
dto
.
put
(
"parent_name"
,
"无"
);
}
outVO
.
setData
(
dto
);
return
outVO
;
}
/**
...
...
@@ -58,14 +71,16 @@ public class ModuleService {
* @param inDto
* @return
*/
public
Dto
save
(
Dto
inDto
)
{
Dto
outDto
=
null
;
//拷贝参数对象中的属性到实体对象中
public
OutVO
add
(
Dto
inDto
)
{
OutVO
outVO
=
new
OutVO
(
0
);
MyModuleEntity
myModuleEntity
=
new
MyModuleEntity
();
MyUtil
.
copyProperties
(
inDto
,
myModuleEntity
);
if
(
MyUtil
.
isEmpty
(
myModuleEntity
.
getParent_id
()))
{
myModuleEntity
.
setParent_id
(
0
);
}
myModuleMapper
.
insert
(
myModuleEntity
);
out
Dto
=
Dtos
.
newDto
().
put2
(
"code"
,
"1"
).
put2
(
"msg"
,
"资源模块信息保存
成功"
);
return
out
Dto
;
out
VO
.
setMsg
(
"资源模块新增
成功"
);
return
out
VO
;
}
/**
...
...
@@ -74,13 +89,13 @@ public class ModuleService {
* @param inDto
* @return
*/
public
Dto
update
(
Dto
inDto
)
{
Dto
outDto
=
null
;
public
OutVO
update
(
Dto
inDto
)
{
OutVO
outVO
=
new
OutVO
(
0
)
;
MyModuleEntity
myModuleEntity
=
new
MyModuleEntity
();
MyUtil
.
copyProperties
(
inDto
,
myModuleEntity
);
myModuleMapper
.
updateByKey
(
myModuleEntity
);
out
Dto
=
Dtos
.
newDto
().
put2
(
"code"
,
"1"
).
put2
(
"msg"
,
"资源模块信息
修改成功"
);
return
out
Dto
;
out
VO
.
setMsg
(
"资源模块
修改成功"
);
return
out
VO
;
}
/**
...
...
@@ -89,26 +104,31 @@ public class ModuleService {
* @param inDto
* @return
*/
public
Dto
delete
(
Dto
inDto
)
{
@Transactional
public
OutVO
delete
(
Dto
inDto
)
{
OutVO
outVO
=
new
OutVO
(
0
);
Integer
moduleId
=
inDto
.
getInteger
(
"id"
);
Integer
cnt
=
sqlSession
.
selectOne
(
"sql.module.countSubModules"
,
moduleId
);
if
(
cnt
>
0
)
{
return
Dtos
.
newDto
().
put2
(
"code"
,
"-1"
).
put2
(
"msg"
,
"该节点包含子节点,不能删除
。请先删除子节点。"
);
throw
new
BizException
(
1
,
"操作取消
。请先删除子节点。"
);
}
myModuleMapper
.
deleteByKey
(
moduleId
);
sqlSession
.
delete
(
"sql.module.deleteMyRoleModule"
,
moduleId
);
Dto
outDto
=
Dtos
.
newDto
().
put2
(
"code"
,
"1"
).
put2
(
"msg"
,
"资源模块删除
成功"
);
return
out
Dto
;
outVO
.
setMsg
(
"资源模块修改
成功"
);
return
out
VO
;
}
/**
* 查询资源树
* 查询资源树
(返回树状数据模型)
*
* @param inDto
* @return
*/
public
String
listModuleTree
(
Dto
inDto
)
{
return
null
;
public
OutVO
listModuleTree
(
Dto
inDto
)
{
OutVO
outVO
=
new
OutVO
(
0
);
List
<
TreeNodeVO
>
treeNodeVOs
=
sqlSession
.
selectList
(
"sql.module.listModuleTree"
,
inDto
);
outVO
.
setData
(
new
TreeBuilder
(
treeNodeVOs
).
buildTree
());
return
outVO
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录