提交 3dd24695 authored 作者: mry's avatar mry

fix(base): get请求restful风格

上级 1b902988
......@@ -120,6 +120,12 @@
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
......
......@@ -35,4 +35,10 @@ public class Parameter {
@ApiModelProperty(value = "in")
private String in;
/**
* schema
*/
@ApiModelProperty(value = "schema")
private String schema;
}
......@@ -71,11 +71,10 @@ public class ConnectController {
*
* @param pageSize 每页多少条数据
* @param pageNum 当前第几页
* @param name 数据库名称
* @return 分页查询的结果, 数据库信息
*/
@ApiOperation(value = "分页查询数据库信息")
@GetMapping("/{projectId}")
@GetMapping("/page")
@Cacheable(cacheNames = "connectPageCache",
key = "#pageSize + '_' + #pageNum + '_' + #projectId",
condition = "#pageNum != null && #pageSize != null",
......@@ -83,12 +82,10 @@ public class ConnectController {
public ResponseEntity<CommonResultObj<Page<Connect>>> findPageConnects(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(required = false, defaultValue = "") String name,
@PathVariable Long projectId) {
Page<Connect> results = Optional.ofNullable(connectService.page(Page.of(pageNum, pageSize)
, Wrappers.lambdaQuery(Connect.class).eq(Connect::getProjectId, projectId)
.like(StringUtils.hasLength(name)
, Connect::getName, name))).orElse(new Page<>());
@RequestParam Long projectId) {
Page<Connect> results = Optional.ofNullable(connectService.page(Page.of(pageNum, pageSize), Wrappers.lambdaQuery(Connect.class)
.eq(Connect::getProjectId, projectId)))
.orElse(new Page<>());
PageTools.pageTool(pageSize, pageNum, results);
return CommonResult.success(results, "查询成功");
}
......@@ -102,16 +99,16 @@ public class ConnectController {
* @return 分页查询的结果, 数据库信息
*/
@ApiOperation(value = "条件查询数据库信息")
@GetMapping("/condition/{projectId}")
@GetMapping("/condition")
public ResponseEntity<CommonResultObj<Page<Connect>>> findConditionConnects(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(required = false, defaultValue = "") String name,
@PathVariable Long projectId) {
Page<Connect> results = Optional.ofNullable(connectService.page(Page.of(pageNum, pageSize)
, Wrappers.lambdaQuery(Connect.class).eq(Connect::getProjectId, projectId)
.like(StringUtils.hasLength(name)
, Connect::getName, name))).orElse(new Page<>());
@RequestParam Long projectId) {
Page<Connect> results = Optional.ofNullable(connectService.page(Page.of(pageNum, pageSize), Wrappers.lambdaQuery(Connect.class)
.eq(Connect::getProjectId, projectId)
.like(StringUtils.hasLength(name), Connect::getName, name)))
.orElse(new Page<>());
PageTools.pageTool(pageSize, pageNum, results);
return CommonResult.success(results, "查询成功");
}
......@@ -131,8 +128,7 @@ public class ConnectController {
evict = {@CacheEvict(cacheNames = "connectPageCache", allEntries = true)}
)
public ResponseEntity<CommonResultObj<Connect>> insertConnect(@RequestBody Connect connect) {
return CommonResult.pred(connectService::save, connect
, "添加成功", "添加失败");
return CommonResult.pred(connectService::save, connect, "添加成功", "添加失败");
}
/**
......@@ -150,8 +146,7 @@ public class ConnectController {
evict = {@CacheEvict(cacheNames = "connectPageCache", allEntries = true)}
)
public ResponseEntity<CommonResultObj<Connect>> updateConnect(@RequestBody Connect connect) {
return CommonResult.pred(connectService::updateById, connect
, "修改成功", "修改失败");
return CommonResult.pred(connectService::updateById, connect, "修改成功", "修改失败");
}
/**
......@@ -164,8 +159,7 @@ public class ConnectController {
@DeleteMapping("/{id}")
@CacheEvict(cacheNames = "connectPageCache", allEntries = true, condition = "#p0 != null")
public ResponseEntity<CommonResultObj<Long>> deleteConnect(@PathVariable Long id) {
return CommonResult.pred(connectService::removeById, id
, "删除成功", "删除失败或id不存在");
return CommonResult.pred(connectService::removeById, id, "删除成功", "删除失败或id不存在");
}
}
......@@ -44,12 +44,11 @@ public class DynamicVariableController {
*
* @param pageSize 每页多少条数据
* @param pageNum 当前第几页
* @param name 动参名称
* @param projectId 项目id
* @return 分页查询的结果, 动参
*/
@ApiOperation(value = "分页查询动参")
@GetMapping("/{projectId}")
@GetMapping("/page")
@Cacheable(cacheNames = "dynamicVariablePageCache",
key = "#pageSize + '_' + #pageNum + '_' + #projectId",
condition = "#pageNum != null && #pageSize != null",
......@@ -57,12 +56,10 @@ public class DynamicVariableController {
public ResponseEntity<CommonResultObj<Page<DynamicVariable>>> findPageDynamicVariable(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(required = false, defaultValue = "") String name,
@PathVariable Long projectId) {
Page<DynamicVariable> results = Optional.ofNullable(dynamicVariableService.page(Page.of(pageNum, pageSize)
, Wrappers.lambdaQuery(DynamicVariable.class).eq(DynamicVariable::getProjectId, projectId)
.like(StringUtils.hasLength(name)
, DynamicVariable::getName, name))).orElse(new Page<>());
@RequestParam Long projectId) {
Page<DynamicVariable> results = Optional.ofNullable(dynamicVariableService.page(Page.of(pageNum, pageSize), Wrappers.lambdaQuery(DynamicVariable.class)
.eq(DynamicVariable::getProjectId, projectId)))
.orElse(new Page<>());
PageTools.pageTool(pageSize, pageNum, results);
return CommonResult.success(results, "查询成功");
}
......@@ -77,16 +74,16 @@ public class DynamicVariableController {
* @return 分页查询的结果, 动参
*/
@ApiOperation(value = "条件查询动参")
@GetMapping("/condition/{projectId}")
@GetMapping("/condition")
public ResponseEntity<CommonResultObj<Page<DynamicVariable>>> findConditionDynamicVariable(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(required = false, defaultValue = "") String name,
@PathVariable Long projectId) {
Page<DynamicVariable> results = Optional.ofNullable(dynamicVariableService.page(Page.of(pageNum, pageSize)
, Wrappers.lambdaQuery(DynamicVariable.class).eq(DynamicVariable::getProjectId, projectId)
.like(StringUtils.hasLength(name)
, DynamicVariable::getName, name))).orElse(new Page<>());
@RequestParam Long projectId) {
Page<DynamicVariable> results = Optional.ofNullable(dynamicVariableService.page(Page.of(pageNum, pageSize), Wrappers.lambdaQuery(DynamicVariable.class)
.eq(DynamicVariable::getProjectId, projectId)
.like(StringUtils.hasLength(name), DynamicVariable::getName, name)))
.orElse(new Page<>());
PageTools.pageTool(pageSize, pageNum, results);
return CommonResult.success(results, "查询成功");
}
......@@ -106,8 +103,7 @@ public class DynamicVariableController {
evict = {@CacheEvict(cacheNames = "dynamicVariablePageCache", allEntries = true)}
)
public ResponseEntity<CommonResultObj<DynamicVariable>> insertDynamicVariable(@RequestBody DynamicVariable dynamicVariable) {
return CommonResult.pred(dynamicVariableService::save, dynamicVariable
, "添加成功", "添加失败");
return CommonResult.pred(dynamicVariableService::save, dynamicVariable, "添加成功", "添加失败");
}
/**
......@@ -125,8 +121,7 @@ public class DynamicVariableController {
evict = {@CacheEvict(cacheNames = "dynamicVariablePageCache", allEntries = true)}
)
public ResponseEntity<CommonResultObj<DynamicVariable>> updateDynamicVariable(@RequestBody DynamicVariable dynamicVariable) {
return CommonResult.pred(dynamicVariableService::updateById, dynamicVariable
, "修改成功", "修改失败");
return CommonResult.pred(dynamicVariableService::updateById, dynamicVariable, "修改成功", "修改失败");
}
/**
......@@ -139,8 +134,7 @@ public class DynamicVariableController {
@DeleteMapping("/{id}")
@CacheEvict(cacheNames = "dynamicVariablePageCache", allEntries = true, condition = "#p0 != null")
public ResponseEntity<CommonResultObj<Long>> deleteDynamicVariable(@PathVariable Long id) {
return CommonResult.pred(dynamicVariableService::removeById, id
, "删除成功", "删除失败或id不存在");
return CommonResult.pred(dynamicVariableService::removeById, id, "删除成功", "删除失败或id不存在");
}
}
......@@ -44,12 +44,11 @@ public class EnvironmentController {
*
* @param pageSize 每页多少条数据
* @param pageNum 当前第几页
* @param name 环境名称
* @param projectId 项目id
* @return 分页查询的结果, 环境
*/
@ApiOperation(value = "分页查询环境")
@GetMapping("/{projectId}")
@GetMapping("/page")
@Cacheable(cacheNames = "environmentPageCache",
key = "#pageSize + '_' + #pageNum + '_' + #projectId",
condition = "#pageNum != null && #pageSize != null",
......@@ -57,12 +56,10 @@ public class EnvironmentController {
public ResponseEntity<CommonResultObj<Page<Environment>>> findPageEnvironment(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(required = false, defaultValue = "") String name,
@PathVariable Long projectId) {
Page<Environment> results = Optional.ofNullable(environmentService.page(Page.of(pageNum, pageSize)
, Wrappers.lambdaQuery(Environment.class).eq(Environment::getProjectId, projectId)
.like(StringUtils.hasLength(name)
, Environment::getName, name))).orElse(new Page<>());
@RequestParam Long projectId) {
Page<Environment> results = Optional.ofNullable(environmentService.page(Page.of(pageNum, pageSize), Wrappers.lambdaQuery(Environment.class)
.eq(Environment::getProjectId, projectId)))
.orElse(new Page<>());
PageTools.pageTool(pageSize, pageNum, results);
return CommonResult.success(results, "查询成功");
}
......@@ -77,16 +74,16 @@ public class EnvironmentController {
* @return 分页查询的结果, 环境
*/
@ApiOperation(value = "条件查询环境")
@GetMapping("/condition/{projectId}")
@GetMapping("/condition")
public ResponseEntity<CommonResultObj<Page<Environment>>> findConditionEnvironment(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(required = false, defaultValue = "") String name,
@PathVariable Long projectId) {
Page<Environment> results = Optional.ofNullable(environmentService.page(Page.of(pageNum, pageSize)
, Wrappers.lambdaQuery(Environment.class).eq(Environment::getProjectId, projectId)
.like(StringUtils.hasLength(name)
, Environment::getName, name))).orElse(new Page<>());
@RequestParam Long projectId) {
Page<Environment> results = Optional.ofNullable(environmentService.page(Page.of(pageNum, pageSize), Wrappers.lambdaQuery(Environment.class)
.eq(Environment::getProjectId, projectId)
.like(StringUtils.hasLength(name), Environment::getName, name)))
.orElse(new Page<>());
PageTools.pageTool(pageSize, pageNum, results);
return CommonResult.success(results, "查询成功");
}
......@@ -106,8 +103,7 @@ public class EnvironmentController {
evict = {@CacheEvict(cacheNames = "environmentPageCache", allEntries = true)}
)
public ResponseEntity<CommonResultObj<Environment>> insertEnvironment(@RequestBody Environment environment) {
return CommonResult.pred(environmentService::save, environment
, "添加成功", "添加失败");
return CommonResult.pred(environmentService::save, environment, "添加成功", "添加失败");
}
/**
......@@ -125,8 +121,7 @@ public class EnvironmentController {
evict = {@CacheEvict(cacheNames = "environmentPageCache", allEntries = true)}
)
public ResponseEntity<CommonResultObj<Environment>> updateEnvironment(@RequestBody Environment environment) {
return CommonResult.pred(environmentService::updateById, environment
, "修改成功", "修改失败");
return CommonResult.pred(environmentService::updateById, environment, "修改成功", "修改失败");
}
/**
......@@ -139,8 +134,7 @@ public class EnvironmentController {
@DeleteMapping("/{id}")
@CacheEvict(cacheNames = "environmentPageCache", allEntries = true, condition = "#p0 != null")
public ResponseEntity<CommonResultObj<Long>> deleteEnvironment(@PathVariable Long id) {
return CommonResult.pred(environmentService::removeById, id
, "删除成功", "删除失败或id不存在");
return CommonResult.pred(environmentService::removeById, id, "删除成功", "删除失败或id不存在");
}
}
......@@ -68,12 +68,11 @@ public class MoveController {
*
* @param pageSize 每页多少条数据
* @param pageNum 当前第几页
* @param name 行为名称
* @param projectId 项目id
* @return 分页查询的结果, 行为
*/
@ApiOperation(value = "分页查询行为")
@GetMapping("/{projectId}")
@GetMapping("/page")
@Cacheable(cacheNames = "movePageName",
key = "#pageNum + '_' + #pageSize + '_' + #projectId",
condition = "#pageNum != null && #pageSize != null",
......@@ -81,12 +80,10 @@ public class MoveController {
public ResponseEntity<CommonResultObj<Page<Move>>> findPageConnects(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(required = false, defaultValue = "") String name,
@PathVariable Long projectId) {
Page<Move> results = Optional.ofNullable(moveService.page(Page.of(pageNum, pageSize)
, Wrappers.lambdaQuery(Move.class).eq(Move::getProjectId, projectId)
.like(StringUtils.hasLength(name)
, Move::getName, name))).orElse(new Page<>());
@RequestParam Long projectId) {
Page<Move> results = Optional.ofNullable(moveService.page(Page.of(pageNum, pageSize), Wrappers.lambdaQuery(Move.class)
.eq(Move::getProjectId, projectId)))
.orElse(new Page<>());
PageTools.pageTool(pageSize, pageNum, results);
return CommonResult.success(results, "查询成功");
}
......@@ -101,16 +98,16 @@ public class MoveController {
* @return 分页查询的结果, 行为
*/
@ApiOperation(value = "条件查询行为")
@GetMapping("/condition/{projectId}")
@GetMapping("/condition")
public ResponseEntity<CommonResultObj<Page<Move>>> findConditionConnects(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(required = false, defaultValue = "") String name,
@PathVariable Long projectId) {
Page<Move> results = Optional.ofNullable(moveService.page(Page.of(pageNum, pageSize)
, Wrappers.lambdaQuery(Move.class).eq(Move::getProjectId, projectId)
.like(StringUtils.hasLength(name)
, Move::getName, name))).orElse(new Page<>());
@RequestParam Long projectId) {
Page<Move> results = Optional.ofNullable(moveService.page(Page.of(pageNum, pageSize), Wrappers.lambdaQuery(Move.class)
.eq(Move::getProjectId, projectId)
.like(StringUtils.hasLength(name), Move::getName, name)))
.orElse(new Page<>());
PageTools.pageTool(pageSize, pageNum, results);
return CommonResult.success(results, "查询成功");
}
......@@ -122,7 +119,7 @@ public class MoveController {
* @return {@link MoveAction}
*/
@ApiOperation(value = "根据行为id查,行为以及,行为下的动作")
@GetMapping("/move/{moveId}")
@GetMapping("/{moveId}")
@Cacheable(cacheNames = "moveNames",
key = "#moveId",
condition = "#p0 != null",
......
......@@ -170,6 +170,7 @@ public class SwaggerController {
String methodIn = parameterMaps.get("in");
String methodName = parameterMaps.get("name");
String methodType = parameterMaps.get("type");
// String methodSchema = parameterMaps.get("schema");
Parameter parameter = new Parameter();
//传参格式
parameter.setIn(methodIn);
......@@ -177,6 +178,7 @@ public class SwaggerController {
parameter.setName(methodName);
//拿到参数类型
parameter.setType(methodType);
// parameter.setSchema(methodSchema);
parameterAllList.add(parameter);
}
interfaceInformation.setId(i++);
......
......@@ -57,11 +57,10 @@ public class TestCaseController {
*
* @param pageSize 每页多少条数据
* @param pageNum 当前第几页
* @param name 行为名称
* @param projectId 项目id
* @return 分页查询的结果, 用例
*/
@GetMapping("/{projectId}")
@GetMapping("/page")
@ApiOperation(value = "分页查询用例")
@Cacheable(cacheNames = "casePageCache",
key = "#pageNum + '_' + #pageSize + '_' + #projectId ",
......@@ -70,13 +69,9 @@ public class TestCaseController {
public ResponseEntity<CommonResultObj<Page<TestCase>>> findPageTestCase(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(required = false, defaultValue = "") String name,
@PathVariable Long projectId) {
Page<TestCase> results = Optional.ofNullable(testCaseService.page(Page.of(pageNum, pageSize)
, Wrappers.lambdaQuery(TestCase.class)
.eq(TestCase::getProjectId, projectId)
.like(StringUtils.hasLength(name), TestCase::getName, name)))
@RequestParam Long projectId) {
Page<TestCase> results = Optional.ofNullable(testCaseService.page(Page.of(pageNum, pageSize), Wrappers.lambdaQuery(TestCase.class)
.eq(TestCase::getProjectId, projectId)))
.orElse(new Page<>());
PageTools.pageTool(pageSize, pageNum, results);
return CommonResult.success(results, "查询成功");
......@@ -91,16 +86,14 @@ public class TestCaseController {
* @param projectId 项目id
* @return 分页查询的结果, 用例
*/
@GetMapping("/condition/{projectId}")
@GetMapping("/condition")
@ApiOperation(value = "条件查询用例")
public ResponseEntity<CommonResultObj<Page<TestCase>>> findConditionTestCase(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(required = false, defaultValue = "") String name,
@PathVariable Long projectId) {
Page<TestCase> results = Optional.ofNullable(testCaseService.page(Page.of(pageNum, pageSize)
, Wrappers.lambdaQuery(TestCase.class)
@RequestParam Long projectId) {
Page<TestCase> results = Optional.ofNullable(testCaseService.page(Page.of(pageNum, pageSize), Wrappers.lambdaQuery(TestCase.class)
.eq(TestCase::getProjectId, projectId)
.like(StringUtils.hasLength(name), TestCase::getName, name)))
.orElse(new Page<>());
......@@ -114,7 +107,7 @@ public class TestCaseController {
* @param testCaseId 用例id
* @return {@link TestCaseData}
*/
@GetMapping("/testCase/{testCaseId}")
@GetMapping("/{testCaseId}")
@ApiOperation(value = "根据用例id查,用例以及,用例下的数据组")
@Cacheable(cacheNames = "caseCache",
key = "#testCaseId", condition = "#p0 !=null",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论