Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
kt-keystone
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
kt-keystone
Commits
974d9ee4
提交
974d9ee4
authored
8月 09, 2022
作者:
mry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(web): 递归删除分组以及分组下的接口,用例,或者数据模型
上级
cf7b1990
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
61 行增加
和
189 行删除
+61
-189
InterfaceDoc.java
...atabase/src/main/java/org/matrix/entity/InterfaceDoc.java
+0
-7
InterfaceGroupingServiceImpl.java
...org/matrix/service/impl/InterfaceGroupingServiceImpl.java
+38
-29
MouldGroupingServiceImpl.java
...ava/org/matrix/service/impl/MouldGroupingServiceImpl.java
+18
-31
InterfaceSortVo.java
kt-database/src/main/java/org/matrix/vo/InterfaceSortVo.java
+0
-105
CaseController.java
...n/java/org/matrix/autotest/controller/CaseController.java
+4
-16
InterfaceGroupingController.java
...trix/autotest/controller/InterfaceGroupingController.java
+1
-1
没有找到文件。
kt-database/src/main/java/org/matrix/entity/InterfaceDoc.java
浏览文件 @
974d9ee4
...
...
@@ -11,7 +11,6 @@ import lombok.EqualsAndHashCode;
import
lombok.NoArgsConstructor
;
import
org.matrix.enums.SyncStatus
;
import
org.matrix.vo.InterfaceDocVo
;
import
org.matrix.vo.InterfaceSortVo
;
import
org.springframework.beans.BeanUtils
;
/**
...
...
@@ -120,10 +119,4 @@ public class InterfaceDoc extends BaseEntity {
return
interfaceDocVo
;
}
public
InterfaceSortVo
toInterfaceSortVo
()
{
InterfaceSortVo
interfaceSortVo
=
new
InterfaceSortVo
();
BeanUtils
.
copyProperties
(
this
,
interfaceSortVo
);
interfaceSortVo
.
setUrl
(
this
.
getHttpMethod
()
+
this
.
getPathUrl
());
return
interfaceSortVo
;
}
}
kt-database/src/main/java/org/matrix/service/impl/InterfaceGroupingServiceImpl.java
浏览文件 @
974d9ee4
...
...
@@ -2,13 +2,16 @@ package org.matrix.service.impl;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.matrix.entity.Case
;
import
org.matrix.entity.InterfaceDoc
;
import
org.matrix.entity.InterfaceGrouping
;
import
org.matrix.mapper.CaseMapper
;
import
org.matrix.mapper.InterfaceDocMapper
;
import
org.matrix.mapper.InterfaceGroupingMapper
;
import
org.matrix.service.IInterfaceGroupingService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -27,48 +30,54 @@ public class InterfaceGroupingServiceImpl extends ServiceImpl<InterfaceGroupingM
@Autowired
private
InterfaceDocMapper
interfaceDocMapper
;
@Autowired
private
CaseMapper
caseMapper
;
@Override
public
void
removeInterfaceGrouping
(
Long
id
)
{
//删除当前分组下的接口文档
List
<
InterfaceDoc
>
interfaceDocs
=
Optional
.
ofNullable
(
interfaceDocMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
InterfaceDoc
.
class
)
.
eq
(
InterfaceDoc:
:
getInterfaceGroupId
,
id
))).
orElse
(
new
ArrayList
<>());
if
(
interfaceDocs
.
size
()
!=
0
)
{
interfaceDocMapper
.
deleteBatchIds
(
interfaceDocs
);
List
<
Long
>
list
=
getGroupIds
(
id
);
//所有的分组id
for
(
Long
groupId
:
list
)
{
//分组下的接口
List
<
InterfaceDoc
>
interfaceDocs
=
Optional
.
ofNullable
(
interfaceDocMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
InterfaceDoc
.
class
)
.
eq
(
InterfaceDoc:
:
getInterfaceGroupId
,
groupId
))).
orElse
(
new
ArrayList
<>());
if
(!
CollectionUtils
.
isEmpty
(
interfaceDocs
))
{
//删除接口下的测试用例
for
(
InterfaceDoc
interfaceDoc
:
interfaceDocs
)
{
List
<
Case
>
cases
=
Optional
.
ofNullable
(
caseMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
Case
.
class
)
.
eq
(
Case:
:
getDocId
,
interfaceDoc
.
getId
()))).
orElse
(
new
ArrayList
<>());
if
(!
CollectionUtils
.
isEmpty
(
cases
))
{
caseMapper
.
deleteBatchIds
(
cases
);
}
}
//测试用例删除完成,删除接口
interfaceDocMapper
.
deleteBatchIds
(
interfaceDocs
);
}
//最后删除分组
interfaceGroupingMapper
.
deleteBatchIds
(
list
);
interfaceGroupingMapper
.
deleteById
(
id
);
}
recursionInterface
(
id
);
//最后删除当前分组
interfaceGroupingMapper
.
deleteById
(
id
);
}
/**
*
递归处理当前分组下的分组
*
获取所有分组的主键id
*
* @param id 当前分组id
* @param id 当前要删除的分组id
* @return 该分组下所有分组的主键id, 也包括当前分组本身
*/
public
void
recursionInterface
(
Long
id
)
{
//找到当前分组下的子分组
private
List
<
Long
>
getGroupIds
(
Long
id
)
{
List
<
Long
>
list
=
new
ArrayList
<>();
//根据分组id找到分组下的分组
List
<
InterfaceGrouping
>
interfaceGroupings
=
Optional
.
ofNullable
(
interfaceGroupingMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
InterfaceGrouping
.
class
)
.
eq
(
InterfaceGrouping:
:
getInterfaceGroupingId
,
id
))).
orElse
(
new
ArrayList
<>());
//是否存在子分组,如果不存在就不做任何操作,如果存在进入下一层
if
(
interfaceGroupings
.
size
()
!=
0
)
{
//找到当前分组下的每个子类分组
//存在分组
if
(!
CollectionUtils
.
isEmpty
(
interfaceGroupings
))
{
for
(
InterfaceGrouping
interfaceGrouping
:
interfaceGroupings
)
{
//删除子类分组中的数据模型
Long
groupingId
=
interfaceGrouping
.
getId
();
List
<
InterfaceGrouping
>
recursionsInterfaces
=
Optional
.
ofNullable
(
interfaceGroupingMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
InterfaceGrouping
.
class
)
.
eq
(
InterfaceGrouping:
:
getInterfaceGroupingId
,
groupingId
))).
orElse
(
new
ArrayList
<>());
if
(
recursionsInterfaces
.
size
()
!=
0
)
{
interfaceDocMapper
.
deleteBatchIds
(
recursionsInterfaces
);
}
recursionInterface
(
groupingId
);
//删除当前分组下的接口
List
<
InterfaceDoc
>
interfaceDocs
=
Optional
.
ofNullable
(
interfaceDocMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
InterfaceDoc
.
class
)
.
eq
(
InterfaceDoc:
:
getInterfaceGroupId
,
groupingId
))).
orElse
(
new
ArrayList
<>());
if
(
interfaceDocs
.
size
()
!=
0
)
{
interfaceDocMapper
.
deleteBatchIds
(
interfaceDocs
);
}
list
.
add
(
interfaceGrouping
.
getId
());
getGroupIds
(
interfaceGrouping
.
getId
());
}
}
return
list
;
}
}
kt-database/src/main/java/org/matrix/service/impl/MouldGroupingServiceImpl.java
浏览文件 @
974d9ee4
...
...
@@ -9,6 +9,7 @@ import org.matrix.mapper.MouldGroupingMapper;
import
org.matrix.service.IMouldGroupingService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -29,46 +30,32 @@ public class MouldGroupingServiceImpl extends ServiceImpl<MouldGroupingMapper, M
@Override
public
void
removeMould
(
Long
id
)
{
//删除当前分组下的数据模型
List
<
MouldDoc
>
mouldDocs
=
Optional
.
ofNullable
(
mouldDocMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
MouldDoc
.
class
)
.
eq
(
MouldDoc:
:
getMouldGroupingId
,
id
))).
orElse
(
new
ArrayList
<>());
if
(
mouldDocs
.
size
()
!=
0
)
{
mouldDocMapper
.
deleteBatchIds
(
mouldDocs
);
List
<
Long
>
list
=
getGroupIds
(
id
);
for
(
Long
groupId
:
list
)
{
//分组下的数据模型
List
<
MouldDoc
>
mouldDocs
=
Optional
.
ofNullable
(
mouldDocMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
MouldDoc
.
class
)
.
eq
(
MouldDoc:
:
getMouldGroupingId
,
groupId
))).
orElse
(
new
ArrayList
<>());
if
(!
CollectionUtils
.
isEmpty
(
mouldDocs
))
{
mouldDocMapper
.
deleteBatchIds
(
mouldDocs
);
}
}
recursionMould
(
id
);
//最后删除当前分组
mouldGroupingMapper
.
deleteBatchIds
(
list
);
mouldGroupingMapper
.
deleteById
(
id
);
}
/**
* 递归处理当前分组下的分组
*
* @param id 当前分组id
*/
public
void
recursionMould
(
Long
id
)
{
//找到当前分组下的子分组
private
List
<
Long
>
getGroupIds
(
Long
id
)
{
List
<
Long
>
list
=
new
ArrayList
<>();
//根据分组id找到分组下的分组
List
<
MouldGrouping
>
mouldGroupings
=
Optional
.
ofNullable
(
mouldGroupingMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
MouldGrouping
.
class
)
.
eq
(
MouldGrouping:
:
getMouldId
,
id
))).
orElse
(
new
ArrayList
<>());
//是否存在子分组,如果不存在就不做任何操作,如果存在进入下一层
if
(
mouldGroupings
.
size
()
!=
0
)
{
//找到当前分组下的每个子类分组
//存在分组
if
(!
CollectionUtils
.
isEmpty
(
mouldGroupings
))
{
for
(
MouldGrouping
mouldGrouping
:
mouldGroupings
)
{
//删除子类分组中的数据模型
Long
groupingId
=
mouldGrouping
.
getId
();
List
<
MouldGrouping
>
recursionsMoulds
=
Optional
.
ofNullable
(
mouldGroupingMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
MouldGrouping
.
class
)
.
eq
(
MouldGrouping:
:
getMouldId
,
groupingId
))).
orElse
(
new
ArrayList
<>());
if
(
recursionsMoulds
.
size
()
!=
0
)
{
mouldDocMapper
.
deleteBatchIds
(
recursionsMoulds
);
}
recursionMould
(
groupingId
);
//删除当前分组下的接口
List
<
MouldDoc
>
mouldDocs
=
Optional
.
ofNullable
(
mouldDocMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
MouldDoc
.
class
)
.
eq
(
MouldDoc:
:
getMouldGroupingId
,
groupingId
))).
orElse
(
new
ArrayList
<>());
if
(
mouldDocs
.
size
()
!=
0
)
{
mouldDocMapper
.
deleteBatchIds
(
mouldDocs
);
}
list
.
add
(
mouldGrouping
.
getId
());
getGroupIds
(
mouldGrouping
.
getId
());
}
}
return
list
;
}
}
kt-database/src/main/java/org/matrix/vo/InterfaceSortVo.java
deleted
100644 → 0
浏览文件 @
cf7b1990
package
org
.
matrix
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.matrix.entity.InterfaceDoc
;
import
org.matrix.enums.SyncStatus
;
import
org.springframework.beans.BeanUtils
;
/**
* @author mruny
* @create 2022/8/5 16:03:14
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
InterfaceSortVo
{
/**
* id
*/
private
Long
id
;
/**
* 名称
*/
@ApiModelProperty
(
"名称"
)
private
String
summary
;
/**
* 说明
*/
@ApiModelProperty
(
"说明"
)
private
String
des
;
/**
* 请求方式
*/
@ApiModelProperty
(
"请求方式"
)
private
String
httpMethod
;
/**
* 接口相对路径
*/
@ApiModelProperty
(
"接口相对路径"
)
private
String
pathUrl
;
/**
* 参数详情(整段json)
*/
@ApiModelProperty
(
"参数详情(整段json)"
)
private
String
parameters
;
/**
* 返回值信息(整段json)
*/
@ApiModelProperty
(
"返回值信息(整段json)"
)
private
String
responses
;
/**
* 项目id
*/
@ApiModelProperty
(
"项目id"
)
private
Long
projectId
;
/**
* 环境id
*/
@ApiModelProperty
(
"环境id"
)
private
Long
envId
;
/**
* 分组id
*/
@ApiModelProperty
(
"分组id"
)
private
Long
interfaceGroupId
;
/**
* 同步状态
*/
@ApiModelProperty
(
"同步状态"
)
private
SyncStatus
status
;
/**
* 开发状态
*/
@ApiModelProperty
(
"开发状态"
)
private
String
devStatus
;
/**
* 负责人
*/
@ApiModelProperty
(
"负责人"
)
private
String
dutyPeople
;
@ApiModelProperty
(
"请求以及url相对路径"
)
private
String
url
;
public
InterfaceDoc
toInterfaceDoc
()
{
InterfaceDoc
interfaceDoc
=
new
InterfaceDoc
();
BeanUtils
.
copyProperties
(
this
,
interfaceDoc
);
return
interfaceDoc
;
}
}
kt-web/src/main/java/org/matrix/autotest/controller/CaseController.java
浏览文件 @
974d9ee4
package
org
.
matrix
.
autotest
.
controller
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.matrix.entity.Case
;
...
...
@@ -12,8 +11,6 @@ import org.springframework.http.HttpStatus;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
/**
...
...
@@ -45,10 +42,10 @@ public class CaseController {
@ApiOperation
(
"添加测试用例"
)
@PostMapping
public
ResponseEntity
<
Case
>
insertCase
(
@RequestBody
Case
a
Case
)
{
return
Optional
.
of
(
caseService
.
save
(
a
Case
)).
orElseThrow
(()
->
new
GlobalException
(
"添加失败"
))
?
ResponseEntity
.
ok
(
a
Case
)
:
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
a
Case
);
public
ResponseEntity
<
Case
>
insertCase
(
@RequestBody
Case
test
Case
)
{
return
Optional
.
of
(
caseService
.
save
(
test
Case
)).
orElseThrow
(()
->
new
GlobalException
(
"添加失败"
))
?
ResponseEntity
.
ok
(
test
Case
)
:
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
test
Case
);
}
@ApiOperation
(
"修改测试用例"
)
...
...
@@ -59,15 +56,6 @@ public class CaseController {
:
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
aCase
);
}
@ApiOperation
(
"查询快捷请求"
)
@GetMapping
public
ResponseEntity
<
List
<
Case
>>
findCase
(
@RequestParam
Long
projectId
)
{
List
<
Case
>
cases
=
Optional
.
ofNullable
(
caseService
.
list
(
Wrappers
.
lambdaQuery
(
Case
.
class
)
.
eq
(
Case:
:
getProjectId
,
projectId
)
.
eq
(
Case:
:
getDocId
,
-
1L
))).
orElse
(
new
ArrayList
<>());
return
ResponseEntity
.
ok
(
cases
);
}
@ApiOperation
(
"查询当前项目下所有分组,以及分组下的接口,测试用例等"
)
@GetMapping
(
"/all"
)
public
ResponseEntity
<
InterfaceGroupVo
>
findAll
(
@RequestParam
Long
projectId
)
{
...
...
kt-web/src/main/java/org/matrix/autotest/controller/InterfaceGroupingController.java
浏览文件 @
974d9ee4
...
...
@@ -52,7 +52,7 @@ public class InterfaceGroupingController {
return
ResponseEntity
.
ok
(
interfaceGrouping
);
}
@ApiOperation
(
"根据接口分组主键id删除分组以及分组下所有分组
和接口文档
"
)
@ApiOperation
(
"根据接口分组主键id删除分组以及分组下所有分组
,接口文档,测试用例
"
)
@DeleteMapping
(
"/{id}"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResponseEntity
<
String
>
removeInterfaceGrouping
(
@PathVariable
Long
id
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论