Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
operation-control-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王锦盛
operation-control-platform
Commits
ac71bdf8
Commit
ac71bdf8
authored
Mar 08, 2022
by
zhaochengming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
赵呈明 --服务分类树
parent
98af6324
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
41 deletions
+98
-41
src/main/java/com/pms/ocp/common/utils/RandomStringUtil.java
src/main/java/com/pms/ocp/common/utils/RandomStringUtil.java
+29
-0
src/main/java/com/pms/ocp/controller/OcpApiTreeController.java
...ain/java/com/pms/ocp/controller/OcpApiTreeController.java
+6
-6
src/main/java/com/pms/ocp/mapper/ModelPropertyMapper.java
src/main/java/com/pms/ocp/mapper/ModelPropertyMapper.java
+1
-0
src/main/java/com/pms/ocp/service/OcpApiTreeService.java
src/main/java/com/pms/ocp/service/OcpApiTreeService.java
+2
-1
src/main/java/com/pms/ocp/service/impl/OcpApiTreeServiceImpl.java
.../java/com/pms/ocp/service/impl/OcpApiTreeServiceImpl.java
+60
-34
No files found.
src/main/java/com/pms/ocp/common/utils/RandomStringUtil.java
0 → 100644
View file @
ac71bdf8
package
com.pms.ocp.common.utils
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
java.util.Random
;
/**
* @author zhaochengming
* 随机生成字符串
*/
public
class
RandomStringUtil
{
/**
* length 字符串长度
* @param length
* @return
*/
public
static
String
getRandomString
(
int
length
){
String
str
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
;
Random
random
=
new
Random
();
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
length
;
i
++){
int
number
=
random
.
nextInt
(
62
);
sb
.
append
(
str
.
charAt
(
number
));
}
return
sb
.
toString
();
}
}
src/main/java/com/pms/ocp/controller/OcpApiTreeController.java
View file @
ac71bdf8
package
com.pms.ocp.controller
;
package
com.pms.ocp.controller
;
import
com.pms.ocp.model.dto.ApiParamDTO
;
import
com.pms.ocp.model.dto.ApiTreeGroupDto
;
import
com.pms.ocp.model.dto.ApiTreeGroupDto
;
import
com.pms.ocp.model.dto.OcpApiGroupDtos
;
import
com.pms.ocp.model.dto.OcpApiGroupDtos
;
import
com.pms.ocp.model.entity.OcpApiBase
;
import
com.pms.ocp.model.entity.OcpApiGroup
;
import
com.pms.ocp.model.entity.OcpApiGroup
;
import
com.pms.ocp.model.vo.ResponseVO
;
import
com.pms.ocp.model.vo.ResponseVO
;
import
com.pms.ocp.service.OcpApiTreeService
;
import
com.pms.ocp.service.OcpApiTreeService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
@Slf4j
@Slf4j
@RequestMapping
(
"/api-group/v1"
)
@RequestMapping
(
"/api-group/v1"
)
...
@@ -52,8 +49,11 @@ public class OcpApiTreeController {
...
@@ -52,8 +49,11 @@ public class OcpApiTreeController {
@PostMapping
(
"/updatatree"
)
@PostMapping
(
"/updatatree"
)
@ApiOperation
(
"服务树分类--修改"
)
@ApiOperation
(
"服务树分类--修改"
)
public
ResponseVO
updataTree
(
@RequestBody
OcpApiGroup
ocpApiGroup
){
public
ResponseVO
updataTree
(
@RequestBody
OcpApiGroup
ocpApiGroup
){
service
.
updataOcpTree
(
ocpApiGroup
);
boolean
flag
=
service
.
updataOcpTree
(
ocpApiGroup
);
return
ResponseVO
.
ok
();
if
(
flag
){
return
ResponseVO
.
ok
();
}
return
ResponseVO
.
error
(
"您输入的服务编码重复,请重新输入"
);
}
}
@PostMapping
(
"/deletetree"
)
@PostMapping
(
"/deletetree"
)
@ApiOperation
(
"服务树分类--删除"
)
@ApiOperation
(
"服务树分类--删除"
)
...
...
src/main/java/com/pms/ocp/mapper/ModelPropertyMapper.java
View file @
ac71bdf8
...
@@ -2,6 +2,7 @@ package com.pms.ocp.mapper;
...
@@ -2,6 +2,7 @@ package com.pms.ocp.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.pms.ocp.model.entity.Model
;
import
com.pms.ocp.model.entity.Model
;
import
com.pms.ocp.model.entity.ModelProperty
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
/**
/**
...
...
src/main/java/com/pms/ocp/service/OcpApiTreeService.java
View file @
ac71bdf8
...
@@ -4,6 +4,7 @@ package com.pms.ocp.service;
...
@@ -4,6 +4,7 @@ package com.pms.ocp.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.pms.ocp.model.dto.ApiTreeGroupDto
;
import
com.pms.ocp.model.dto.ApiTreeGroupDto
;
import
com.pms.ocp.model.dto.OcpApiGroupDtos
;
import
com.pms.ocp.model.dto.OcpApiGroupDtos
;
import
com.pms.ocp.model.entity.OcpApiBase
;
import
com.pms.ocp.model.entity.OcpApiGroup
;
import
com.pms.ocp.model.entity.OcpApiGroup
;
...
@@ -25,7 +26,7 @@ public interface OcpApiTreeService extends IService<OcpApiGroup> {
...
@@ -25,7 +26,7 @@ public interface OcpApiTreeService extends IService<OcpApiGroup> {
*/
*/
void
updataOcpTree
(
OcpApiGroup
ocpApiGroup
);
boolean
updataOcpTree
(
OcpApiGroup
ocpApiGroup
);
/**
/**
* 删除服务分类
* 删除服务分类
...
...
src/main/java/com/pms/ocp/service/impl/OcpApiTreeServiceImpl.java
View file @
ac71bdf8
package
com.pms.ocp.service.impl
;
package
com.pms.ocp.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.pms.ocp.common.utils.RandomStringUtil
;
import
com.pms.ocp.mapper.OcpApiBaseMapper
;
import
com.pms.ocp.mapper.OcpApiBaseMapper
;
import
com.pms.ocp.mapper.OcpApiTreeMapper
;
import
com.pms.ocp.mapper.OcpApiTreeMapper
;
import
com.pms.ocp.model.dto.*
;
import
com.pms.ocp.model.dto.*
;
import
com.pms.ocp.model.entity.OcpApiBase
;
import
com.pms.ocp.model.entity.OcpApiBase
;
import
com.pms.ocp.model.entity.OcpApiGroup
;
import
com.pms.ocp.model.entity.OcpApiGroup
;
import
com.pms.ocp.service.OcpApiTreeService
;
import
com.pms.ocp.service.OcpApiTreeService
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -40,7 +42,7 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
...
@@ -40,7 +42,7 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
//服务树分类对象
//服务树分类对象
ApiTreeGroupDto
apiTreeGroupList
=
new
ApiTreeGroupDto
();
ApiTreeGroupDto
apiTreeGroupList
=
new
ApiTreeGroupDto
();
//
一级服务分类
//
1中台层
List
<
OneTreeUpList
>
oneTreeUpLists
=
new
ArrayList
<>();
List
<
OneTreeUpList
>
oneTreeUpLists
=
new
ArrayList
<>();
for
(
OcpApiGroup
ocpApiGroup
:
ocpApiGroups
)
{
for
(
OcpApiGroup
ocpApiGroup
:
ocpApiGroups
)
{
...
@@ -49,10 +51,9 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
...
@@ -49,10 +51,9 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
//一级服务对象
//一级服务对象
OneTreeUpList
oneTreeUpList
=
new
OneTreeUpList
();
OneTreeUpList
oneTreeUpList
=
new
OneTreeUpList
();
// 判断数据是否有上级服务分类
// 判断数据是否有上级服务分类
if
(
""
.
equals
(
ocpApiGroup
.
getApiGroupPcode
())
)
{
if
(
ocpApiGroup
.
getApiGroupLevel
()
==
1
)
{
BeanUtils
.
copyProperties
(
ocpApiGroup
,
oneTreeUpList
);
BeanUtils
.
copyProperties
(
ocpApiGroup
,
oneTreeUpList
);
oneTreeUpLists
.
add
(
oneTreeUpList
);
oneTreeUpLists
.
add
(
oneTreeUpList
);
}
}
}
}
...
@@ -60,7 +61,7 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
...
@@ -60,7 +61,7 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
}
}
List
<
TwoDownList
>
twoDownLists
=
twoTreeLists
(
oneTreeUpLists
,
ocpApiGroups
);
List
<
TwoDownList
>
twoDownLists
=
twoTreeLists
(
oneTreeUpLists
,
ocpApiGroups
);
List
<
ThreeTreeList
>
threeTreeLists
=
threeTreeLists
(
twoDownLists
,
ocpApiGroups
);
List
<
ThreeTreeList
>
threeTreeLists
=
threeTreeLists
(
twoDownLists
,
ocpApiGroups
);
apiTreeGroupList
.
setOne
up
List
(
oneTreeUpLists
);
apiTreeGroupList
.
setOneList
(
oneTreeUpLists
);
apiTreeGroupList
.
setTwoList
(
twoDownLists
);
apiTreeGroupList
.
setTwoList
(
twoDownLists
);
apiTreeGroupList
.
setThreeList
(
threeTreeLists
);
apiTreeGroupList
.
setThreeList
(
threeTreeLists
);
...
@@ -68,55 +69,68 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
...
@@ -68,55 +69,68 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
}
}
/**
/**
*
二级目录
*
2中心层
* @param oneTreeUpLists
* @param oneTreeUpLists
* @return
* @return
*/
*/
public
List
<
TwoDownList
>
twoTreeLists
(
List
<
OneTreeUpList
>
oneTreeUpLists
,
List
<
OcpApiGroup
>
ocpApiGroups
){
public
List
<
TwoDownList
>
twoTreeLists
(
List
<
OneTreeUpList
>
oneTreeUpLists
,
List
<
OcpApiGroup
>
ocpApiGroups
){
List
<
OcpApiGroup
>
twolists
=
new
ArrayList
<>();
List
<
TwoDownList
>
twoTreeLists
=
new
ArrayList
<>();
List
<
TwoDownList
>
twoTreeLists
=
new
ArrayList
<>();
for
(
OcpApiGroup
ocpApiGroup
:
ocpApiGroups
)
{
//服务树全表数据
if
(!(
ocpApiGroup
.
getIsDelete
()
==
0
)){
if
(
ocpApiGroup
.
getApiGroupLevel
()
==
2
){
for
(
OneTreeUpList
oneTreeUpList
:
oneTreeUpLists
)
{
twolists
.
add
(
ocpApiGroup
);
String
code
=
oneTreeUpList
.
getApiGroupCode
();
}
else
{
for
(
OcpApiGroup
ocpApiGroup
:
ocpApiGroups
)
{
continue
;
if
(
code
.
equals
(
ocpApiGroup
.
getApiGroupPcode
()))
{
}
TwoDownList
twoDownList
=
new
TwoDownList
();
BeanUtils
.
copyProperties
(
ocpApiGroup
,
twoDownList
);
twoTreeLists
.
add
(
twoDownList
);
}
}
}
}
}
BeanUtils
.
copyProperties
(
twolists
,
twoTreeLists
);
return
twoTreeLists
;
return
twoTreeLists
;
}
}
/**
/**
*
三级目录
*
3服务组层
* @param twoDownLists
* @param twoDownLists
* @return
* @return
*/
*/
public
List
<
ThreeTreeList
>
threeTreeLists
(
List
<
TwoDownList
>
twoDownLists
,
List
<
OcpApiGroup
>
ocpApiGroups
){
public
List
<
ThreeTreeList
>
threeTreeLists
(
List
<
TwoDownList
>
twoDownLists
,
List
<
OcpApiGroup
>
ocpApiGroups
){
List
<
ThreeTreeList
>
threeTreeLists
=
new
ArrayList
<>();
List
<
ThreeTreeList
>
threeTreeLists
=
new
ArrayList
<>();
List
<
OcpApiGroup
>
threeLists
=
new
ArrayList
<>();
for
(
TwoDownList
twoDownList
:
twoDownLists
)
{
for
(
OcpApiGroup
ocpApiGroup
:
ocpApiGroups
)
{
for
(
OcpApiGroup
ocpApiGroup
:
ocpApiGroups
)
{
String
code
=
twoDownList
.
getApiGroupCode
();
if
(!(
ocpApiGroup
.
getIsDelete
()
==
0
))
{
if
(
code
.
equals
(
ocpApiGroup
.
getApiGroupPcode
())){
if
(
ocpApiGroup
.
getApiGroupLevel
()
==
3
){
ThreeTreeList
threeTreeList
=
new
ThreeTreeList
();
threeLists
.
add
(
ocpApiGroup
);
BeanUtils
.
copyProperties
(
ocpApiGroup
,
threeTreeList
);
}
threeTreeLists
.
add
(
threeTreeList
);
}
else
{
/* threeTreeList.setThreeList(ocpApiGroup);
continue
;
threeTreeLists.add(threeTreeList);*/
}
}
}
BeanUtils
.
copyProperties
(
threeLists
,
threeTreeLists
);
}
}
return
threeTreeLists
;
return
threeTreeLists
;
}
/**
* 4服务层
* @param threeTreeLists
* @return
*/
public
List
<
FourTreeList
>
fourTreeLists
(
List
<
ThreeTreeList
>
threeTreeLists
,
List
<
OcpApiGroup
>
ocpApiGroups
){
List
<
FourTreeList
>
foureTreeList
=
new
ArrayList
<>();
List
<
OcpApiGroup
>
foureLists
=
new
ArrayList
<>();
for
(
OcpApiGroup
ocpApiGroup
:
ocpApiGroups
)
{
if
(!(
ocpApiGroup
.
getIsDelete
()
==
0
))
{
if
(
ocpApiGroup
.
getApiGroupLevel
()
==
4
){
foureLists
.
add
(
ocpApiGroup
);
}
}
else
{
continue
;
}
BeanUtils
.
copyProperties
(
foureLists
,
foureTreeList
);
}
return
foureTreeList
;
}
}
/**
/**
...
@@ -127,6 +141,8 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
...
@@ -127,6 +141,8 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
@Override
@Override
public
boolean
insertTree
(
OcpApiGroupDtos
ocpApiGroupDtos
)
{
public
boolean
insertTree
(
OcpApiGroupDtos
ocpApiGroupDtos
)
{
String
code
=
RandomStringUtil
.
getRandomString
(
6
);
boolean
flag
=
true
;
boolean
flag
=
true
;
List
<
OcpApiGroup
>
ocpApiGroups
=
mapper
.
selectList
(
null
);
List
<
OcpApiGroup
>
ocpApiGroups
=
mapper
.
selectList
(
null
);
for
(
OcpApiGroup
ocpApiGroup
:
ocpApiGroups
)
{
for
(
OcpApiGroup
ocpApiGroup
:
ocpApiGroups
)
{
...
@@ -139,16 +155,17 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
...
@@ -139,16 +155,17 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
OcpApiBase
ocpApiBase
=
new
OcpApiBase
();
OcpApiBase
ocpApiBase
=
new
OcpApiBase
();
ocpApiBase
.
setApiCode
(
ocpApiGroupDtos
.
getApiGroupCode
());
ocpApiBase
.
setApiCode
(
ocpApiGroupDtos
.
getApiGroupCode
());
BeanUtils
.
copyProperties
(
ocpApiGroupDtos
,
ocpApiBase
);
BeanUtils
.
copyProperties
(
ocpApiGroupDtos
,
ocpApiBase
);
ocpApiBase
.
setApiGroupCode
(
code
);
ocpApiBase
.
setApiName
(
"新增服务分类"
);
ocpApiBase
.
setApiName
(
"新增服务分类"
);
Timestamp
timestamp
=
new
Timestamp
(
System
.
currentTimeMillis
());
Timestamp
timestamp
=
new
Timestamp
(
System
.
currentTimeMillis
());
ocpApiBase
.
setApiMtime
(
timestamp
);
ocpApiBase
.
setApiMtime
(
timestamp
);
ocpApiBase
.
setApiCtime
(
ocpApiGroupDtos
.
getApiGroupCtime
());
ocpApiBase
.
setApiCtime
(
ocpApiGroupDtos
.
getApiGroupCtime
());
ocpApiBase
.
setApiUserId
(
ocpApiGroupDtos
.
getApiGroupUserId
());
ocpApiBase
.
setApiUserId
(
ocpApiGroupDtos
.
getApiGroupUserId
());
ocpApiBase
.
setObjId
(
""
);
ocpApiBase
.
setObjId
(
""
);
OcpApiGroup
ocpApiGroup1
=
new
OcpApiGroup
();
OcpApiGroup
ocpApiGroup1
=
new
OcpApiGroup
();
ocpApiGroup1
.
setObjId
(
""
);
ocpApiGroup1
.
setObjId
(
""
);
BeanUtils
.
copyProperties
(
ocpApiGroupDtos
,
ocpApiGroup1
);
BeanUtils
.
copyProperties
(
ocpApiGroupDtos
,
ocpApiGroup1
);
ocpApiGroup1
.
setApiGroupCode
(
code
);
ocpApiBaseMapper
.
insert
(
ocpApiBase
);
ocpApiBaseMapper
.
insert
(
ocpApiBase
);
mapper
.
insert
(
ocpApiGroup1
);
mapper
.
insert
(
ocpApiGroup1
);
...
@@ -164,8 +181,18 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
...
@@ -164,8 +181,18 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
* @param
* @param
*/
*/
@Override
@Override
public
void
updataOcpTree
(
OcpApiGroup
ocpApiGroup
)
{
public
boolean
updataOcpTree
(
OcpApiGroup
ocpApiGroup
)
{
boolean
falg
=
true
;
List
<
OcpApiGroup
>
ocpApiGroups
=
mapper
.
selectList
(
null
);
for
(
OcpApiGroup
apiGroup
:
ocpApiGroups
)
{
String
code
=
apiGroup
.
getApiGroupCode
();
if
(
code
==
ocpApiGroup
.
getApiGroupCode
()){
falg
=
false
;
break
;
}
}
mapper
.
updateById
(
ocpApiGroup
);
mapper
.
updateById
(
ocpApiGroup
);
return
falg
;
}
}
...
@@ -179,7 +206,6 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
...
@@ -179,7 +206,6 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
public
boolean
deleteOcpTree
(
OcpApiGroup
ocpApiGroup
)
{
public
boolean
deleteOcpTree
(
OcpApiGroup
ocpApiGroup
)
{
String
objId
=
ocpApiGroup
.
getObjId
();
String
objId
=
ocpApiGroup
.
getObjId
();
OcpApiGroup
ocpApiGroup1
=
mapper
.
selectById
(
objId
);
OcpApiGroup
ocpApiGroup1
=
mapper
.
selectById
(
objId
);
if
(
StringUtils
.
isBlank
(
ocpApiGroup1
.
getApiGroupPcode
())){
if
(
StringUtils
.
isBlank
(
ocpApiGroup1
.
getApiGroupPcode
())){
mapper
.
deleteById
(
objId
);
mapper
.
deleteById
(
objId
);
return
true
;
return
true
;
...
...
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