Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
kt-keystone
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
kt-keystone
Commits
24c50546
提交
24c50546
authored
1月 25, 2022
作者:
mry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(base): 调用http与用例的方式变为注入方式
上级
76b60095
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
84 行增加
和
150 行删除
+84
-150
IProjectService.java
...ain/java/org/matrix/database/service/IProjectService.java
+0
-33
ProjectServiceImpl.java
.../org/matrix/database/service/impl/ProjectServiceImpl.java
+0
-28
CommonResult.java
...se/src/main/java/org/matrix/database/vo/CommonResult.java
+20
-0
TestPigeon.java
kt-base/src/main/java/org/matrix/testNg/TestPigeon.java
+10
-2
ConnectController.java
...ava/org/matrix/autotest/controller/ConnectController.java
+28
-52
MoveController.java
...n/java/org/matrix/autotest/controller/MoveController.java
+9
-5
ProjectController.java
...ava/org/matrix/autotest/controller/ProjectController.java
+16
-29
application.yml
kt-web/src/main/resources/application.yml
+1
-1
没有找到文件。
kt-base/src/main/java/org/matrix/database/service/IProjectService.java
浏览文件 @
24c50546
...
...
@@ -3,8 +3,6 @@ package org.matrix.database.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
org.matrix.database.entity.Project
;
import
java.util.List
;
/**
* <p>
* 服务类
...
...
@@ -15,35 +13,4 @@ import java.util.List;
*/
public
interface
IProjectService
extends
IService
<
Project
>
{
/**
* 查询所有项目
*
* @return 查询到的所有项目
*/
List
<
Project
>
findAllProject
();
/**
* 添加项目
*
* @param project 项目
* @return 影响行数
*/
int
insertProject
(
Project
project
);
/**
* 修改项目
*
* @param project 项目
* @return 影响行数
*/
int
updateProject
(
Project
project
);
/**
* 删除项目
*
* @param id 项目id
* @return 影响行数
*/
int
deleteProject
(
Integer
id
);
}
kt-base/src/main/java/org/matrix/database/service/impl/ProjectServiceImpl.java
浏览文件 @
24c50546
...
...
@@ -6,8 +6,6 @@ import org.matrix.database.mapper.ProjectMapper;
import
org.matrix.database.service.IProjectService
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* <p>
* 服务实现类
...
...
@@ -19,30 +17,4 @@ import java.util.List;
@Service
public
class
ProjectServiceImpl
extends
ServiceImpl
<
ProjectMapper
,
Project
>
implements
IProjectService
{
private
final
ProjectMapper
projectMapper
;
public
ProjectServiceImpl
(
ProjectMapper
projectMapper
)
{
this
.
projectMapper
=
projectMapper
;
}
@Override
public
List
<
Project
>
findAllProject
()
{
return
projectMapper
.
selectList
(
null
);
}
@Override
public
int
insertProject
(
Project
project
)
{
return
projectMapper
.
insert
(
project
);
}
@Override
public
int
updateProject
(
Project
project
)
{
return
projectMapper
.
updateById
(
project
);
}
@Override
public
int
deleteProject
(
Integer
id
)
{
return
projectMapper
.
deleteById
(
id
);
}
}
kt-base/src/main/java/org/matrix/database/vo/CommonResult.java
浏览文件 @
24c50546
...
...
@@ -4,6 +4,9 @@ import org.springframework.http.HttpHeaders;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
java.util.Optional
;
import
java.util.function.Predicate
;
/**
* @author mry
*/
...
...
@@ -19,6 +22,23 @@ public class CommonResult {
return
new
ResponseEntity
(
new
CommonResultObj
(
data
),
headers
,
HttpStatus
.
OK
);
}
/**
* 运行predicate这段函数,如果返回值为true,返回值Response.ok(data),successMsg,否则返回failedMsg
*
* @param predicate 接受一段参数为T类型,返回值为boolean类型的函数
* @param data predicate的参数
* @param failedMsg 失败信息
* @param <T> data类型
* @return 如果成功,返回data自己,如果失败返回failedMsg给的错误信息
*/
public
static
<
T
>
ResponseEntity
<
CommonResultObj
<
T
>>
pred
(
Predicate
<
T
>
predicate
,
T
data
,
String
successMsg
,
String
failedMsg
)
{
if
(
predicate
.
test
(
data
)){
return
success
(
data
,
successMsg
);
}
else
{
return
failed
(
data
,
failedMsg
);
}
}
/**
* 成功返回结果
*
...
...
kt-base/src/main/java/org/matrix/testNg/TestPigeon.java
浏览文件 @
24c50546
package
org
.
matrix
.
testNg
;
import
org.matrix.actuators.checkpoint.CheckPointActuator
;
import
org.matrix.actuators.checkpoint.CheckPointResult
;
import
org.matrix.actuators.httpclient.HttpClientActuator
;
import
org.matrix.actuators.usecase.CaseActuator
;
import
org.matrix.actuators.usecase.TestCaseExecuteResult
;
import
org.matrix.database.entity.TestCase
;
...
...
@@ -29,6 +31,12 @@ public class TestPigeon extends AbstractTestNGSpringContextTests {
@Autowired
private
ITestCaseService
caseService
;
@Autowired
private
CheckPointActuator
checkPointActuator
;
@Autowired
private
HttpClientActuator
httpClientActuator
;
@Parameters
({
"sql"
,
"envId"
,
"projectId"
})
@BeforeClass
public
void
beforeClass
(
String
sql
,
Long
envId
,
Long
projectId
)
{
...
...
@@ -50,10 +58,10 @@ public class TestPigeon extends AbstractTestNGSpringContextTests {
@Test
(
dataProvider
=
"testData"
)
public
void
test
(
Map
<
String
,
String
>
data
)
{
long
caseId
=
Long
.
parseLong
(
data
.
get
(
"id"
));
CaseActuator
caseActuator
=
new
CaseActuator
(
envId
,
projectId
);
CaseActuator
caseActuator
=
new
CaseActuator
(
checkPointActuator
,
httpClientActuator
);
TestCase
testCase
=
java
.
util
.
Optional
.
of
(
caseService
.
getById
(
caseId
))
.
orElseThrow
(()
->
new
GlobalException
(
String
.
format
(
"没有找到id = %d 的TestCase"
,
caseId
)));
TestCaseExecuteResult
testCaseExecuteResult
=
caseActuator
.
executeTestCase
(
testCase
);
TestCaseExecuteResult
testCaseExecuteResult
=
caseActuator
.
executeTestCase
(
testCase
,
envId
,
projectId
);
CheckPointResult
checkPointResult
=
testCaseExecuteResult
.
getCheckPointResult
();
Reporter
.
log
(
checkPointResult
.
toString
());
}
...
...
kt-web/src/main/java/org/matrix/autotest/controller/ConnectController.java
浏览文件 @
24c50546
...
...
@@ -6,11 +6,10 @@ import org.matrix.database.entity.Connect;
import
org.matrix.database.service.IConnectService
;
import
org.matrix.database.vo.CommonResult
;
import
org.matrix.database.vo.CommonResultObj
;
import
org.matrix.database.vo.PageResult
;
import
org.matrix.exception.GlobalException
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
...
...
@@ -25,7 +24,7 @@ import java.util.Optional;
@CrossOrigin
@RestController
@RequestMapping
(
"/connects"
)
@Api
(
tags
=
"对
连接池
connect的基本操作"
)
@Api
(
tags
=
"对
于数据库
connect的基本操作"
)
public
class
ConnectController
{
private
final
IConnectService
connectService
;
...
...
@@ -34,40 +33,29 @@ public class ConnectController {
this
.
connectService
=
connectService
;
}
// @GetMapping("")
// public ResponseEntity findAllPages(@RequestParam int page ,int size , String query){
// //query -> wrappers string -> 类型 字段名a , 字段值b
// // if else
// // for each
// // if eq then .eq(a,b)
// // if gt then .ge
// Wrappers.query(Connect.class)
// .eq(query)
// return Optional.of(ResponseEntity.ok(connectService.page(Page.of(++page, size), Wrappers.query())))
// .orElse(ResponseEntity.status(400).body())
//
// @ApiOperation(value = "分页查询")
// @PostMapping("/page")
// public ResponseEntity<CommonResultObj<PageResult>> findAllPage(@RequestBody PageResult pageResult) {
// pageResult = connectService.pageAll(pageResult);
// if (pageResult.getRows() != null) {
// return CommonResult.success(pageResult, "查询成功");
// } else {
// return CommonResult.failed("查询失败或无数据");
// }
// }
@ApiOperation
(
value
=
"分页查询"
)
@PostMapping
(
"/page"
)
public
ResponseEntity
<
CommonResultObj
<
PageResult
>>
findAllPage
(
@RequestBody
PageResult
pageResult
)
{
pageResult
=
connectService
.
pageAll
(
pageResult
);
if
(
pageResult
.
getRows
()
!=
null
)
{
return
CommonResult
.
success
(
pageResult
,
"查询成功"
);
}
else
{
return
CommonResult
.
failed
(
"查询失败或无数据"
);
}
}
/**
* 查询所有数据库
*
* @return 查询到的所有数据库
*/
@ApiOperation
(
value
=
"查询所有"
)
@GetMapping
public
ResponseEntity
<
CommonResultObj
<
List
<
Connect
>>>
findAll
()
{
List
<
Connect
>
list
=
connectService
.
list
();
if
(
list
!=
null
&&
list
.
size
()
!=
0
)
{
return
CommonResult
.
success
(
list
,
"查询成功"
);
}
else
{
return
CommonResult
.
failed
(
"查询失败或无数据"
);
}
public
ResponseEntity
<
CommonResultObj
<
List
<
Connect
>>>
findAllConnects
()
{
List
<
Connect
>
results
=
Optional
.
ofNullable
(
connectService
.
list
()).
orElse
(
new
ArrayList
<>());
return
results
.
size
()
!=
0
?
CommonResult
.
success
(
results
,
"查询成功"
)
:
CommonResult
.
failed
(
results
,
"查询失败或无数据"
);
}
/**
...
...
@@ -79,12 +67,8 @@ public class ConnectController {
@ApiOperation
(
value
=
"添加连接池"
)
@PostMapping
public
ResponseEntity
<
CommonResultObj
<
Connect
>>
insertConnect
(
@RequestBody
Connect
connect
)
{
int
i
=
connectService
.
insertConnect
(
connect
);
if
(
i
!=
0
)
{
return
CommonResult
.
success
(
connect
,
"添加成功"
);
}
else
{
return
CommonResult
.
failed
(
"添加失败"
);
}
return
CommonResult
.
pred
(
connectService:
:
save
,
connect
,
"添加成功"
,
"添加失败"
);
}
/**
...
...
@@ -96,12 +80,8 @@ public class ConnectController {
@ApiOperation
(
value
=
"修改连接池"
)
@PutMapping
public
ResponseEntity
<
CommonResultObj
<
Connect
>>
updateConnect
(
@RequestBody
Connect
connect
)
{
int
i
=
connectService
.
updateConnect
(
connect
);
if
(
i
!=
0
)
{
return
CommonResult
.
success
(
connect
,
"修改成功"
);
}
else
{
return
CommonResult
.
failed
(
"修改失败"
);
}
return
CommonResult
.
pred
(
connectService:
:
updateById
,
connect
,
"修改成功"
,
"修改失败"
);
}
/**
...
...
@@ -112,13 +92,9 @@ public class ConnectController {
*/
@ApiOperation
(
value
=
"根据id删除连接池"
)
@DeleteMapping
(
"/{id}"
)
public
ResponseEntity
<
CommonResultObj
<
String
>>
deleteConnect
(
@PathVariable
Integer
id
)
{
int
i
=
connectService
.
deleteConnect
(
id
);
if
(
i
!=
0
)
{
return
CommonResult
.
success
(
"id: "
+
id
+
"已删除"
,
"删除成功"
);
}
else
{
return
CommonResult
.
failed
(
"删除失败,或不存在需要删除的数据"
);
}
public
ResponseEntity
<
CommonResultObj
<
Integer
>>
deleteConnect
(
@PathVariable
Integer
id
)
{
return
CommonResult
.
pred
(
connectService:
:
removeById
,
id
,
"删除成功"
,
"删除失败"
);
}
}
...
...
kt-web/src/main/java/org/matrix/autotest/controller/MoveController.java
浏览文件 @
24c50546
...
...
@@ -66,6 +66,12 @@ public class MoveController {
@GetMapping
(
"/{moveId}"
)
public
ResponseEntity
<
CommonResultObj
<
MoveAction
>>
findById
(
@PathVariable
Long
moveId
)
{
// todo 关于空判断的后面可以再处理
Move
byId
=
moveService
.
getById
(
moveId
);
if
(
byId
==
null
){
throw
new
GlobalException
(
""
);
}
Move
move
=
ofNullable
(
moveService
.
getById
(
moveId
))
.
orElseThrow
(()
->
new
GlobalException
(
String
.
format
(
"没有查到指定的行为,你提供的行为id是%d"
,
moveId
)));
List
<
Action
>
actionList
=
ofNullable
(
actionService
.
list
(
Wrappers
.
lambdaQuery
(
Action
.
class
)
...
...
@@ -97,11 +103,9 @@ public class MoveController {
action
.
setMoveId
(
id
);
}
boolean
saveBatch
=
actionService
.
saveBatch
(
moveAction
.
getAction
());
if
(
save
&&
saveBatch
)
{
return
CommonResult
.
success
(
moveAction
,
"添加成功"
);
}
else
{
return
CommonResult
.
failed
(
"添加失败"
);
}
return
save
&&
saveBatch
?
CommonResult
.
success
(
moveAction
,
"添加成功"
)
:
CommonResult
.
failed
(
"添加失败"
);
}
/**
...
...
kt-web/src/main/java/org/matrix/autotest/controller/ProjectController.java
浏览文件 @
24c50546
...
...
@@ -9,7 +9,9 @@ import org.matrix.database.vo.CommonResultObj;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
/**
* <p>
...
...
@@ -38,13 +40,11 @@ public class ProjectController {
*/
@ApiOperation
(
value
=
"查询所有项目"
)
@GetMapping
public
ResponseEntity
<
CommonResultObj
<
List
<
Project
>>>
findAllProject
()
{
List
<
Project
>
results
=
projectService
.
findAllProject
();
if
(
results
!=
null
&&
results
.
size
()
!=
0
)
{
return
CommonResult
.
success
(
results
,
"查询成功"
);
}
else
{
return
CommonResult
.
failed
(
"查询失败或无数据"
);
}
public
ResponseEntity
<
CommonResultObj
<
List
<
Project
>>>
findAllProjects
()
{
List
<
Project
>
results
=
Optional
.
ofNullable
(
projectService
.
list
()).
orElse
(
new
ArrayList
<>());
return
results
.
size
()
!=
0
?
CommonResult
.
success
(
results
,
"查询成功"
)
:
CommonResult
.
failed
(
results
,
"查询失败或无数据"
);
}
/**
...
...
@@ -56,12 +56,8 @@ public class ProjectController {
@ApiOperation
(
value
=
"添加项目"
)
@PostMapping
public
ResponseEntity
<
CommonResultObj
<
Project
>>
insertProject
(
@RequestBody
Project
project
)
{
int
i
=
projectService
.
insertProject
(
project
);
if
(
i
!=
0
)
{
return
CommonResult
.
success
(
project
,
"添加成功"
);
}
else
{
return
CommonResult
.
failed
(
"添加失败或已存在同名项目"
);
}
return
CommonResult
.
pred
(
projectService:
:
save
,
project
,
"添加成功"
,
"添加失败或已存在同名项目"
);
}
/**
...
...
@@ -73,30 +69,21 @@ public class ProjectController {
@ApiOperation
(
value
=
"修改项目"
)
@PutMapping
public
ResponseEntity
<
CommonResultObj
<
Project
>>
updateProject
(
@RequestBody
Project
project
)
{
int
i
=
projectService
.
updateProject
(
project
);
if
(
i
!=
0
)
{
return
CommonResult
.
success
(
project
,
"修改成功"
);
}
else
{
return
CommonResult
.
failed
(
"修改失败"
);
}
return
CommonResult
.
pred
(
projectService:
:
updateById
,
project
,
"修改成功"
,
"修改失败"
);
}
/**
* 删除项目
*
* @param id 项目id
* @return
是否删除成功
* @return
删除的项目id, 以及是否删除成功的提示信息
*/
@ApiOperation
(
value
=
"
根据id
删除项目"
)
@ApiOperation
(
value
=
"删除项目"
)
@DeleteMapping
(
"/{id}"
)
public
ResponseEntity
<
CommonResultObj
<
String
>>
deleteProject
(
@PathVariable
Integer
id
)
{
int
i
=
projectService
.
deleteProject
(
id
);
if
(
i
!=
0
)
{
return
CommonResult
.
success
(
"id: "
+
id
+
"已删除"
,
"删除成功"
);
}
else
{
return
CommonResult
.
failed
(
"删除失败,或不存在需要删除的数据"
);
}
public
ResponseEntity
<
CommonResultObj
<
Integer
>>
deleteProject
(
@PathVariable
Integer
id
)
{
return
CommonResult
.
pred
(
projectService:
:
removeById
,
id
,
"删除成功"
,
"删除失败"
);
}
}
kt-web/src/main/resources/application.yml
浏览文件 @
24c50546
...
...
@@ -10,7 +10,7 @@ spring:
datasource
:
master
:
#增加默认数据源
driverClassName
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://192.168.100.248:3306/key_stone?useUnicode=true&characterEncoding=utf-8&useSSL=false
url
:
jdbc:mysql://192.168.100.248:3306/key_stone?useUnicode=true&characterEncoding=utf-8&useSSL=false
&serverTimezone=UTC
username
:
root
password
:
root
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论