提交 8834ac31 authored 作者: mry's avatar mry

perf(web): 优化crud

上级 6703c998
......@@ -9,4 +9,5 @@ public class TestConfig {
public static final String DB_BASE_NAME = "user";
public static final String DB_USERNAME = "root";
public static final String DB_PASSWORD = "root";
}
......@@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.matrix.autotest.entity.Action;
import org.matrix.autotest.service.ActionService;
import org.matrix.autotest.utils.CommonResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -34,8 +35,13 @@ public class ActionController {
*/
@ApiOperation(value = "查询所有动作")
@GetMapping
public List<Action> findAllAction() {
return actionService.findAllAction();
public CommonResult<List<Action>> findAllAction() {
List<Action> results = actionService.findAllAction();
if (results != null && results.size() != 0) {
return CommonResult.success(results);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -46,8 +52,13 @@ public class ActionController {
*/
@ApiOperation(value = "根据id查询动作")
@GetMapping("/{id}")
public Action findByIdAction(@PathVariable Integer id) {
return actionService.findByIdAction(id);
public CommonResult<Action> findByIdAction(@PathVariable Integer id) {
Action result = actionService.findByIdAction(id);
if (result != null) {
return CommonResult.success(result);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -58,8 +69,13 @@ public class ActionController {
*/
@ApiOperation(value = "添加动作")
@PostMapping
public Action insertAction(@RequestBody Action action) {
return actionService.insertAction(action);
public CommonResult<Action> insertAction(@RequestBody Action action) {
int i = actionService.insertAction(action);
if (i != 0) {
return CommonResult.success(action);
} else {
return CommonResult.failed("添加失败");
}
}
/**
......@@ -70,21 +86,50 @@ public class ActionController {
*/
@ApiOperation(value = "根据id修改动作")
@PutMapping("/{id}")
public Action updateAction(@RequestBody Action action) {
return actionService.updateAction(action);
public CommonResult<Action> updateAction(@RequestBody Action action) {
int i = actionService.updateAction(action);
if (i != 0) {
return CommonResult.success(action);
} else {
return CommonResult.failed("修改失败");
}
}
/**
* 删除动作
*
* @param action 动作
* @return 删除的动作
* @param id 动作id
* @return 是否删除成功
*/
@ApiOperation(value = "根据id删除动作")
@DeleteMapping("/{id}")
public Action deleteAction(@RequestBody Action action) {
return actionService.deleteAction(action);
public CommonResult<Action> deleteAction(@PathVariable Integer id) {
int i = actionService.deleteAction(id);
if (i != 0) {
return CommonResult.success("删除成功");
} else {
return CommonResult.failed("删除失败,或不存在需要删除的数据");
}
}
/**
* 根据项目id查询动作
*
* @param projectId 项目id
* @return 符合项目id的动作
*/
@ApiOperation(value = "根据项目id查询所有")
@GetMapping("/{projectId}")
public CommonResult<List<Action>> findByProjectIdAction(@PathVariable Integer projectId) {
List<Action> results = actionService.findByProjectIdAction(projectId);
if (results != null && results.size() != 0) {
return CommonResult.success(results);
} else {
return CommonResult.failed("查询失败或无数据");
}
//todo 未完成
}
}
......@@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.matrix.autotest.entity.Connect;
import org.matrix.autotest.service.ConnectService;
import org.matrix.autotest.utils.CommonResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -30,12 +31,17 @@ public class ConnectController {
/**
* 查询所有连接池
*
* @return 连接池
* @return 查询到的所有连接池
*/
@ApiOperation(value = "查询所有连接池")
@GetMapping
public List<Connect> findAllConnect() {
return connectService.findAllConnect();
public CommonResult<List<Connect>> findAllConnect() {
List<Connect> results = connectService.findAllConnect();
if (results != null && results.size() != 0) {
return CommonResult.success(results);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -46,8 +52,13 @@ public class ConnectController {
*/
@ApiOperation(value = "根据id查询连接池")
@GetMapping("/{id}")
public Connect findByIdConnect(@PathVariable Integer id) {
return connectService.findByIdConnect(id);
public CommonResult<Connect> findByIdConnect(@PathVariable Integer id) {
Connect result = connectService.findByIdConnect(id);
if (result != null) {
return CommonResult.success(result);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -58,8 +69,13 @@ public class ConnectController {
*/
@ApiOperation(value = "添加连接池")
@PostMapping
public Connect insertConnect(@RequestBody Connect connect) {
return connectService.insertConnect(connect);
public CommonResult<Connect> insertConnect(@RequestBody Connect connect) {
int i = connectService.insertConnect(connect);
if (i != 0) {
return CommonResult.success(connect);
} else {
return CommonResult.failed("添加失败");
}
}
/**
......@@ -70,20 +86,31 @@ public class ConnectController {
*/
@ApiOperation(value = "根据id修改连接池")
@PutMapping("/{id}")
public Connect updateConnect(@RequestBody Connect connect) {
return connectService.updateConnect(connect);
public CommonResult<Connect> updateConnect(@RequestBody Connect connect) {
int i = connectService.updateConnect(connect);
if (i != 0) {
return CommonResult.success(connect);
} else {
return CommonResult.failed("修改失败");
}
}
/**
* 删除连接池
*
* @param connect 连接池
* @return 删除的连接池
* @param id 连接池id
* @return 是否删除成功
*/
@ApiOperation(value = "根据id删除连接池")
@DeleteMapping("/{id}")
public Connect deleteConnect(@RequestBody Connect connect) {
return connectService.deleteConnect(connect);
public CommonResult<Connect> deleteConnect(@PathVariable Integer id) {
int i = connectService.deleteConnect(id);
if (i != 0) {
return CommonResult.success("删除成功");
} else {
return CommonResult.failed("删除失败,或不存在需要删除的数据");
}
}
}
......@@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.matrix.autotest.entity.DynamicVariable;
import org.matrix.autotest.service.DynamicVariableService;
import org.matrix.autotest.utils.CommonResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -30,12 +31,17 @@ public class DynamicVariableController {
/**
* 查询所有动态变量
*
* @return 动态变量
* @return 查询到的所有动态变量
*/
@ApiOperation(value = "查询所有动态变量")
@GetMapping
public List<DynamicVariable> findAllDynamicVariable() {
return dynamicVariableService.findAllDynamicVariable();
public CommonResult<List<DynamicVariable>> findAllDynamicVariable() {
List<DynamicVariable> results = dynamicVariableService.findAllDynamicVariable();
if (results != null && results.size() != 0) {
return CommonResult.success(results);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -46,8 +52,13 @@ public class DynamicVariableController {
*/
@ApiOperation(value = "根据id查询动态变量")
@GetMapping("/{id}")
public DynamicVariable findByIdDynamicVariable(@PathVariable Integer id) {
return dynamicVariableService.findByIdDynamicVariable(id);
public CommonResult<DynamicVariable> findByIdDynamicVariable(@PathVariable Integer id) {
DynamicVariable result = dynamicVariableService.findByIdDynamicVariable(id);
if (result != null) {
return CommonResult.success(result);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -58,8 +69,13 @@ public class DynamicVariableController {
*/
@ApiOperation(value = "添加动态变量")
@PostMapping
public DynamicVariable insertDynamicVariable(@RequestBody DynamicVariable dynamicVariable) {
return dynamicVariableService.insertDynamicVariable(dynamicVariable);
public CommonResult<DynamicVariable> insertDynamicVariable(@RequestBody DynamicVariable dynamicVariable) {
int i = dynamicVariableService.insertDynamicVariable(dynamicVariable);
if (i != 0) {
return CommonResult.success(dynamicVariable);
} else {
return CommonResult.failed("添加失败");
}
}
/**
......@@ -70,20 +86,30 @@ public class DynamicVariableController {
*/
@ApiOperation(value = "根据id修改动态变量")
@PutMapping("/{id}")
public DynamicVariable updateDynamicVariable(@RequestBody DynamicVariable dynamicVariable) {
return dynamicVariableService.updateDynamicVariable(dynamicVariable);
public CommonResult<DynamicVariable> updateDynamicVariable(@RequestBody DynamicVariable dynamicVariable) {
int i = dynamicVariableService.updateDynamicVariable(dynamicVariable);
if (i != 0) {
return CommonResult.success(dynamicVariable);
} else {
return CommonResult.failed("修改失败");
}
}
/**
* 删除动态变量
*
* @param dynamicVariable 动态变量
* @return 删除的动态变量
* @param id 动态变量id
* @return 是否删除成功
*/
@ApiOperation(value = "根据id删除动态变量")
@DeleteMapping("/{id}")
public DynamicVariable deleteDynamicVariable(@RequestBody DynamicVariable dynamicVariable) {
return dynamicVariableService.deleteDynamicVariable(dynamicVariable);
public CommonResult<DynamicVariable> deleteDynamicVariable(@PathVariable Integer id) {
int i = dynamicVariableService.deleteDynamicVariable(id);
if (i != 0) {
return CommonResult.success("删除成功");
} else {
return CommonResult.failed("删除失败,或不存在需要删除的数据");
}
}
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.matrix.autotest.entity.Environment;
import org.matrix.autotest.service.EnvironmentService;
import org.matrix.autotest.utils.CommonResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -18,7 +19,7 @@ import java.util.List;
*/
@RestController
@RequestMapping("/environments")
@Api(tags = "对实例表example的基本操作")
@Api(tags = "对实例表environment的基本操作")
public class EnvironmentController {
private final EnvironmentService environmentService;
......@@ -30,12 +31,17 @@ public class EnvironmentController {
/**
* 查询所有实例
*
* @return 实例
* @return 查询到的所有实例
*/
@ApiOperation(value = "查询所有实例")
@GetMapping
public List<Environment> findAllEnvironment() {
return environmentService.findAllEnvironment();
public CommonResult<List<Environment>> findAllEnvironment() {
List<Environment> results = environmentService.findAllEnvironment();
if (results != null && results.size() != 0) {
return CommonResult.success(results);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -46,8 +52,13 @@ public class EnvironmentController {
*/
@ApiOperation(value = "根据id查询实例")
@GetMapping("/{id}")
public Environment findByIdEnvironment(@PathVariable Integer id) {
return environmentService.findByIdEnvironment(id);
public CommonResult<Environment> findByIdEnvironment(@PathVariable Integer id) {
Environment result = environmentService.findByIdEnvironment(id);
if (result != null) {
return CommonResult.success(result);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -58,8 +69,13 @@ public class EnvironmentController {
*/
@ApiOperation(value = "添加实例")
@PostMapping
public Environment insertEnvironment(@RequestBody Environment environment) {
return environmentService.insertEnvironment(environment);
public CommonResult<Environment> insertEnvironment(@RequestBody Environment environment) {
int i = environmentService.insertEnvironment(environment);
if (i != 0) {
return CommonResult.success(environment);
} else {
return CommonResult.failed("添加失败");
}
}
/**
......@@ -70,20 +86,31 @@ public class EnvironmentController {
*/
@ApiOperation(value = "根据id修改实例")
@PutMapping("/{id}")
public Environment updateEnvironment(@RequestBody Environment environment) {
return environmentService.updateEnvironment(environment);
public CommonResult<Environment> updateEnvironment(@RequestBody Environment environment) {
int i = environmentService.updateEnvironment(environment);
if (i != 0) {
return CommonResult.success(environment);
} else {
return CommonResult.failed("修改失败");
}
}
/**
* 删除实例
*
* @param environment 实例
* @return 删除的实例
* @param id 实例id
* @return 是否删除成功
*/
@ApiOperation(value = "根据id删除实例")
@DeleteMapping("/{id}")
public Environment deleteEnvironment(@RequestBody Environment environment){
return environmentService.deleteEnvironment(environment);
public CommonResult<Environment> deleteEnvironment(@PathVariable Integer id) {
int i = environmentService.deleteEnvironment(id);
if (i != 0) {
return CommonResult.success("删除成功");
} else {
return CommonResult.failed("删除失败,或不存在需要删除的数据");
}
}
}
......@@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.matrix.autotest.entity.Move;
import org.matrix.autotest.service.MoveService;
import org.matrix.autotest.utils.CommonResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -30,12 +31,17 @@ public class MoveController {
/**
* 查询所有行为
*
* @return 行为
* @return 查询到的所有行为
*/
@ApiOperation(value = "查询所有行为")
@GetMapping
public List<Move> findAllMove() {
return moveService.findAllMove();
public CommonResult<List<Move>> findAllMove() {
List<Move> results = moveService.findAllMove();
if (results != null && results.size() != 0) {
return CommonResult.success(results);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -46,8 +52,13 @@ public class MoveController {
*/
@ApiOperation(value = "根据id查询行为")
@GetMapping("/{id}")
public Move findByIdMove(@PathVariable Integer id) {
return moveService.findByIdMove(id);
public CommonResult<Move> findByIdMove(@PathVariable Integer id) {
Move result = moveService.findByIdMove(id);
if (result != null) {
return CommonResult.success(result);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -58,8 +69,13 @@ public class MoveController {
*/
@ApiOperation(value = "添加行为")
@PostMapping
public Move insertMove(@RequestBody Move move) {
return moveService.insertMove(move);
public CommonResult<Move> insertMove(@RequestBody Move move) {
int i = moveService.insertMove(move);
if (i != 0) {
return CommonResult.success(move);
} else {
return CommonResult.failed("添加失败");
}
}
/**
......@@ -70,20 +86,31 @@ public class MoveController {
*/
@ApiOperation(value = "根据id修改行为")
@PutMapping("/{id}")
public Move updateMove(@RequestBody Move move) {
return moveService.updateMove(move);
public CommonResult<Move> updateMove(@RequestBody Move move) {
int i = moveService.updateMove(move);
if (i != 0) {
return CommonResult.success(move);
} else {
return CommonResult.failed("修改失败");
}
}
/**
* 删除行为
*
* @param move 行为
* @return 删除的行为
* @param id 行为id
* @return 是否删除成功
*/
@ApiOperation(value = "根据id删除行为")
@DeleteMapping("/{id}")
public Move deleteMove(@RequestBody Move move) {
return moveService.deleteMove(move);
public CommonResult<Move> deleteMove(@PathVariable Integer id) {
int i = moveService.deleteMove(id);
if (i != 0) {
return CommonResult.success("删除成功");
} else {
return CommonResult.failed("删除失败,或不存在需要删除的数据");
}
}
}
......@@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.matrix.autotest.entity.Project;
import org.matrix.autotest.service.ProjectService;
import org.matrix.autotest.utils.CommonResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -30,12 +31,17 @@ public class ProjectController {
/**
* 查询所有项目
*
* @return 项目
* @return 查询到的所有项目
*/
@ApiOperation(value = "查询所有项目")
@GetMapping
public List<Project> findAllProject() {
return projectService.findAllProject();
public CommonResult<List<Project>> findAllProject() {
List<Project> results = projectService.findAllProject();
if (results != null && results.size() != 0){
return CommonResult.success(results);
}else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -46,8 +52,13 @@ public class ProjectController {
*/
@ApiOperation(value = "根据id查询项目")
@GetMapping("/{id}")
public Project findByIdProject(@PathVariable Integer id) {
return projectService.findByIdProject(id);
public CommonResult<Project> findByIdProject(@PathVariable Integer id) {
Project result = projectService.findByIdProject(id);
if (result != null){
return CommonResult.success(result);
}else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -58,8 +69,13 @@ public class ProjectController {
*/
@ApiOperation(value = "添加项目")
@PostMapping
public Project insertProject(@RequestBody Project project) {
return projectService.insertProject(project);
public CommonResult<Project> insertProject(@RequestBody Project project) {
int i = projectService.insertProject(project);
if (i != 0){
return CommonResult.success(project);
}else {
return CommonResult.failed("添加失败");
}
}
/**
......@@ -70,20 +86,31 @@ public class ProjectController {
*/
@ApiOperation(value = "根据id修改项目")
@PutMapping("/{id}")
public Project updateProject(@RequestBody Project project) {
return projectService.updateProject(project);
public CommonResult<Project> updateProject(@RequestBody Project project) {
int i = projectService.updateProject(project);
if (i != 0){
return CommonResult.success(project);
}else {
return CommonResult.failed("修改失败");
}
}
/**
* 删除项目
*
* @param project 项目
* @return 删除的项目
* @param id 项目id
* @return 是否删除成功
*/
@ApiOperation(value = "根据id删除项目")
@DeleteMapping("/{id}")
public Project deleteProject(@RequestBody Project project) {
return projectService.deleteProject(project);
public CommonResult<Project> deleteProject(@PathVariable Integer id) {
int i = projectService.deleteProject(id);
if (i != 0){
return CommonResult.success("删除成功");
}else {
return CommonResult.failed("删除失败,或不存在需要删除的数据");
}
}
}
......@@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.matrix.autotest.entity.TestCase;
import org.matrix.autotest.service.TestCaseService;
import org.matrix.autotest.utils.CommonResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -30,12 +31,17 @@ public class TestCaseController {
/**
* 查询所有用例
*
* @return 用例
* @return 查询到的所有用例
*/
@ApiOperation(value = "查询所有用例")
@GetMapping
public List<TestCase> findAllTestCase() {
return testCaseService.findAllTestCase();
public CommonResult<List<TestCase>> findAllTestCase() {
List<TestCase> results = testCaseService.findAllTestCase();
if(results != null && results.size() != 0){
return CommonResult.success(results);
}else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -46,8 +52,13 @@ public class TestCaseController {
*/
@ApiOperation(value = "根据id查询用例")
@GetMapping("/{id}")
public TestCase findByIdTestCase(@PathVariable Integer id) {
return testCaseService.findByIdTestCase(id);
public CommonResult<TestCase> findByIdTestCase(@PathVariable Integer id) {
TestCase result = testCaseService.findByIdTestCase(id);
if (result != null){
return CommonResult.success(result);
}else {
return CommonResult.failed("查询失败或无数据");
}
}
/**
......@@ -58,8 +69,13 @@ public class TestCaseController {
*/
@ApiOperation(value = "添加用例")
@PostMapping
public TestCase insertTestCase(@RequestBody TestCase testCase) {
return testCaseService.insertTestCase(testCase);
public CommonResult<TestCase> insertTestCase(@RequestBody TestCase testCase) {
int i = testCaseService.insertTestCase(testCase);
if (i != 0){
return CommonResult.success(testCase);
}else {
return CommonResult.failed("添加失败");
}
}
/**
......@@ -70,20 +86,31 @@ public class TestCaseController {
*/
@ApiOperation(value = "根据id修改用例")
@PutMapping("/{id}")
public TestCase updateTestCase(@RequestBody TestCase testCase) {
return testCaseService.updateTestCase(testCase);
public CommonResult<TestCase> updateTestCase(@RequestBody TestCase testCase) {
int i = testCaseService.updateTestCase(testCase);
if (i != 0){
return CommonResult.success(testCase);
}else {
return CommonResult.failed("修改失败");
}
}
/**
* 删除用例
*
* @param testCase 用例
* @return 删除的用例
* @param id 用例id
* @return 是否删除成功
*/
@ApiOperation(value = "根据id删除用例")
@DeleteMapping("/{id}")
public TestCase deleteTestCase(@RequestBody TestCase testCase) {
return testCaseService.deleteTestCase(testCase);
public CommonResult<TestCase> deleteTestCase(@PathVariable Integer id) {
int i = testCaseService.deleteTestCase(id);
if (i != 0){
return CommonResult.success("删除成功");
}else {
return CommonResult.failed("删除失败,或不存在需要删除的数据");
}
}
}
......@@ -69,6 +69,12 @@ public class Action {
@ApiModelProperty(value = "详细参数")
private String detail;
/**
* 实例
*/
@ApiModelProperty(value = "实例")
private String env;
@ApiModelProperty(value = "添加时间")
private LocalDateTime createTime;
......
......@@ -34,24 +34,32 @@ public interface ActionService extends IService<Action> {
* 添加动作
*
* @param action 动作
* @return 添加的动作
* @return 影响行数
*/
Action insertAction(Action action);
int insertAction(Action action);
/**
* 修改动作
*
* @param action 动作
* @return 修改后的动作
* @return 影响行数
*/
Action updateAction(Action action);
int updateAction(Action action);
/**
* 删除动作
*
* @param action 动作
* @return 删除的动作
* @param id 动作id
* @return 影响行数
*/
int deleteAction(Integer id);
/**
* 根据项目id查询动作
*
* @param projectId 项目id
* @return 符合项目id的动作
*/
Action deleteAction(Action action);
List<Action> findByProjectIdAction(Integer projectId);
}
......@@ -17,7 +17,7 @@ public interface ConnectService extends IService<Connect> {
/**
* 查询所有连接池
*
* @return 连接池
* @return 查询到的所有连接池
*/
List<Connect> findAllConnect();
......@@ -33,23 +33,24 @@ public interface ConnectService extends IService<Connect> {
* 添加连接池
*
* @param connect 连接池
* @return 添加的连接池
* @return 影响行数
*/
Connect insertConnect(Connect connect);
int insertConnect(Connect connect);
/**
* 修改连接池
*
* @param connect 连接池
* @return 修改后的连接池
* @return 影响行数
*/
Connect updateConnect(Connect connect);
int updateConnect(Connect connect);
/**
* 删除连接池
*
* @param connect 连接池
* @return 删除的连接池
* @param id 连接池id
* @return 影响行数
*/
Connect deleteConnect(Connect connect);
int deleteConnect(Integer id);
}
......@@ -17,7 +17,7 @@ public interface DynamicVariableService extends IService<DynamicVariable> {
/**
* 查询所有动态变量
*
* @return 动态变量
* @return 查询到的所有动态变量
*/
List<DynamicVariable> findAllDynamicVariable();
......@@ -33,23 +33,24 @@ public interface DynamicVariableService extends IService<DynamicVariable> {
* 添加动态变量
*
* @param dynamicVariable 动态变量
* @return 添加的动态变量
* @return 影响行数
*/
DynamicVariable insertDynamicVariable(DynamicVariable dynamicVariable);
int insertDynamicVariable(DynamicVariable dynamicVariable);
/**
* 修改动态变量
*
* @param dynamicVariable 动态变量
* @return 修改后的动态变量
* @return 影响行数
*/
DynamicVariable updateDynamicVariable(DynamicVariable dynamicVariable);
int updateDynamicVariable(DynamicVariable dynamicVariable);
/**
* 删除动态变量
*
* @param dynamicVariable 动态变量
* @return 删除的动态变量
* @param id 动态变量
* @return 影响行数
*/
DynamicVariable deleteDynamicVariable(DynamicVariable dynamicVariable);
int deleteDynamicVariable(Integer id);
}
......@@ -17,7 +17,7 @@ public interface EnvironmentService extends IService<Environment> {
/**
* 查询所有实例
*
* @return 实例
* @return 查询到的所有实例
*/
List<Environment> findAllEnvironment();
......@@ -33,23 +33,24 @@ public interface EnvironmentService extends IService<Environment> {
* 添加实例
*
* @param environment 实例
* @return 添加的实例
* @return 影响行数
*/
Environment insertEnvironment(Environment environment);
int insertEnvironment(Environment environment);
/**
* 修改实例
*
* @param environment 实例
* @return 修改后的实例
* @return 影响行数
*/
Environment updateEnvironment(Environment environment);
int updateEnvironment(Environment environment);
/**
* 删除实例
*
* @param environment 实例
* @return 删除的实例
* @param id 实例
* @return 影响行数
*/
Environment deleteEnvironment(Environment environment);
int deleteEnvironment(Integer id);
}
package org.matrix.autotest.service.Impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.matrix.autotest.dao.ActionMapper;
import org.matrix.autotest.entity.Action;
......@@ -36,21 +37,25 @@ public class ActionServiceImpl extends ServiceImpl<ActionMapper, Action> impleme
}
@Override
public Action insertAction(Action action) {
actionMapper.insert(action);
return action;
public int insertAction(Action action) {
return actionMapper.insert(action);
}
@Override
public Action updateAction(Action action) {
actionMapper.updateById(action);
return action;
public int updateAction(Action action) {
return actionMapper.updateById(action);
}
@Override
public Action deleteAction(Action action) {
actionMapper.deleteById(action.getId());
return action;
public int deleteAction(Integer id) {
return actionMapper.deleteById(id);
}
@Override
public List<Action> findByProjectIdAction(Integer projectId) {
QueryWrapper<Action> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("project_id", projectId);
return actionMapper.selectList(queryWrapper);
}
}
......@@ -36,21 +36,18 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
}
@Override
public Connect insertConnect(Connect connect) {
connectMapper.insert(connect);
return connect;
public int insertConnect(Connect connect) {
return connectMapper.insert(connect);
}
@Override
public Connect updateConnect(Connect connect) {
connectMapper.updateById(connect);
return connect;
public int updateConnect(Connect connect) {
return connectMapper.updateById(connect);
}
@Override
public Connect deleteConnect(Connect connect) {
connectMapper.deleteById(connect.getId());
return connect;
public int deleteConnect(Integer id) {
return connectMapper.deleteById(id);
}
}
......@@ -37,20 +37,18 @@ public class DynamicVariableServiceImpl extends ServiceImpl<DynamicVariableMappe
}
@Override
public DynamicVariable insertDynamicVariable(DynamicVariable dynamicVariable) {
dynamicVariableMapper.insert(dynamicVariable);
return dynamicVariable;
public int insertDynamicVariable(DynamicVariable dynamicVariable) {
return dynamicVariableMapper.insert(dynamicVariable);
}
@Override
public DynamicVariable updateDynamicVariable(DynamicVariable dynamicVariable) {
dynamicVariableMapper.updateById(dynamicVariable);
return dynamicVariable;
public int updateDynamicVariable(DynamicVariable dynamicVariable) {
return dynamicVariableMapper.updateById(dynamicVariable);
}
@Override
public DynamicVariable deleteDynamicVariable(DynamicVariable dynamicVariable) {
dynamicVariableMapper.deleteById(dynamicVariable.getId());
return dynamicVariable;
public int deleteDynamicVariable(Integer id) {
return dynamicVariableMapper.deleteById(id);
}
}
......@@ -36,21 +36,18 @@ public class EnvironmentServiceImpl extends ServiceImpl<EnvironmentMapper, Envir
}
@Override
public Environment insertEnvironment(Environment environment) {
environmentMapper.insert(environment);
return environment;
public int insertEnvironment(Environment environment) {
return environmentMapper.insert(environment);
}
@Override
public Environment updateEnvironment(Environment environment) {
environmentMapper.updateById(environment);
return environment;
public int updateEnvironment(Environment environment) {
return environmentMapper.updateById(environment);
}
@Override
public Environment deleteEnvironment(Environment environment) {
environmentMapper.deleteById(environment.getId());
return environment;
public int deleteEnvironment(Integer id) {
return environmentMapper.deleteById(id);
}
}
......@@ -36,20 +36,18 @@ public class MoveServiceImpl extends ServiceImpl<MoveMapper, Move> implements Mo
}
@Override
public Move insertMove(Move move) {
moveMapper.insert(move);
return move;
public int insertMove(Move move) {
return moveMapper.insert(move);
}
@Override
public Move updateMove(Move move) {
moveMapper.updateById(move);
return move;
public int updateMove(Move move) {
return moveMapper.updateById(move);
}
@Override
public Move deleteMove(Move move) {
moveMapper.deleteById(move.getId());
return move;
public int deleteMove(Integer id) {
return moveMapper.deleteById(id);
}
}
......@@ -36,20 +36,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
}
@Override
public Project insertProject(Project project) {
projectMapper.insert(project);
return project;
public int insertProject(Project project) {
return projectMapper.insert(project);
}
@Override
public Project updateProject(Project project) {
projectMapper.updateById(project);
return project;
public int updateProject(Project project) {
return projectMapper.updateById(project);
}
@Override
public Project deleteProject(Project project) {
projectMapper.deleteById(project.getId());
return project;
public int deleteProject(Integer id) {
return projectMapper.deleteById(id);
}
}
......@@ -36,20 +36,18 @@ public class TestCaseServiceImpl extends ServiceImpl<TestCaseMapper, TestCase> i
}
@Override
public TestCase insertTestCase(TestCase testCase) {
testCaseMapper.insert(testCase);
return testCase;
public int insertTestCase(TestCase testCase) {
return testCaseMapper.insert(testCase);
}
@Override
public TestCase updateTestCase(TestCase testCase) {
testCaseMapper.updateById(testCase);
return testCase;
public int updateTestCase(TestCase testCase) {
return testCaseMapper.updateById(testCase);
}
@Override
public TestCase deleteTestCase(TestCase testCase) {
testCaseMapper.deleteById(testCase.getId());
return testCase;
public int deleteTestCase(Integer id) {
return testCaseMapper.deleteById(id);
}
}
......@@ -17,7 +17,7 @@ public interface MoveService extends IService<Move> {
/**
* 查询所有行为
*
* @return 行为
* @return 查询到的所有行为
*/
List<Move> findAllMove();
......@@ -33,23 +33,24 @@ public interface MoveService extends IService<Move> {
* 添加行为
*
* @param move 行为
* @return 添加的行为
* @return 影响行数
*/
Move insertMove(Move move);
int insertMove(Move move);
/**
* 修改行为
*
* @param move 行为
* @return 修改后的行为
* @return 影响行数
*/
Move updateMove(Move move);
int updateMove(Move move);
/**
* 删除行为
*
* @param move 行为
* @return 删除的行为
* @param id 行为id
* @return 影响行数
*/
Move deleteMove(Move move);
int deleteMove(Integer id);
}
......@@ -17,7 +17,7 @@ public interface ProjectService extends IService<Project> {
/**
* 查询所有项目
*
* @return 项目
* @return 查询到的所有项目
*/
List<Project> findAllProject();
......@@ -33,23 +33,24 @@ public interface ProjectService extends IService<Project> {
* 添加项目
*
* @param project 项目
* @return 添加的项目
* @return 影响行数
*/
Project insertProject(Project project);
int insertProject(Project project);
/**
* 修改项目
*
* @param project 项目
* @return 修改后的项目
* @return 影响行数
*/
Project updateProject(Project project);
int updateProject(Project project);
/**
* 删除项目
*
* @param project 项目
* @return 删除的项目
* @param id 项目id
* @return 影响行数
*/
Project deleteProject(Project project);
int deleteProject(Integer id);
}
......@@ -17,7 +17,7 @@ public interface TestCaseService extends IService<TestCase> {
/**
* 查询所有用例
*
* @return 用例
* @return 查询到的所有用例
*/
List<TestCase> findAllTestCase();
......@@ -33,23 +33,24 @@ public interface TestCaseService extends IService<TestCase> {
* 添加用例
*
* @param testCase 用例
* @return 添加的用例
* @return 影响行数
*/
TestCase insertTestCase(TestCase testCase);
int insertTestCase(TestCase testCase);
/**
* 修改用例
*
* @param testCase 用例
* @return 修改后的用例
* @return 影响行数
*/
TestCase updateTestCase(TestCase testCase);
int updateTestCase(TestCase testCase);
/**
* 删除用例
*
* @param testCase 用例
* @return 删除的用例
* @param id 用例
* @return 影响行数
*/
TestCase deleteTestCase(TestCase testCase);
int deleteTestCase(Integer id);
}
package org.matrix.autotest.utils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author mry
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> {
/**
* 状态码
*/
private long code;
/**
* 提示信息
*/
private String message;
/**
* 数据封装
*/
private T data;
/**
* 成功返回结果
*/
public static <T> CommonResult<T> success() {
return new CommonResult<>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), null);
}
/**
* 失败返回结果
*/
public static <T> CommonResult<T> failed() {
return new CommonResult<>(ResultCode.FAILED.getCode(), ResultCode.FAILED.getMessage(), null);
}
/**
* 成功返回结果
*
* @param message 提示信息
*/
public static <T> CommonResult<T> success(String message) {
return new CommonResult<>(ResultCode.SUCCESS.getCode(), message, null);
}
/**
* 失败返回结果
*
* @param message 提示信息
*/
public static <T> CommonResult<T> failed(String message) {
return new CommonResult<>(ResultCode.FAILED.getCode(), message, null);
}
/**
* 成功返回结果
*
* @param data 获取的数据
*/
public static <T> CommonResult<T> success(T data) {
return new CommonResult<T>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data);
}
/**
* 失败返回结果
*
* @param data 获取的数据
*/
public static <T> CommonResult<T> failed(T data) {
return new CommonResult<T>(ResultCode.FAILED.getCode(), ResultCode.FAILED.getMessage(), data);
}
/**
* 成功返回结果
*
* @param data 获取的数据
* @param message 提示信息
*/
public static <T> CommonResult<T> success(T data, String message) {
return new CommonResult<T>(ResultCode.SUCCESS.getCode(), message, data);
}
/**
* 失败返回结果
*
* @param data 获取的数据
* @param message 提示信息
*/
public static <T> CommonResult<T> failed(T data, String message) {
return new CommonResult<T>(ResultCode.FAILED.getCode(), message, data);
}
}
package org.matrix.autotest.utils;
/**
* @author mry
*/
public enum ResultCode {
/**
* SUCCESS 操作成功
* FAILED 操作失败
*/
SUCCESS(200, "操作成功"),
FAILED(500, "操作失败");
private final long code;
private final String message;
ResultCode(long code, String message) {
this.code = code;
this.message = message;
}
public long getCode() {
return code;
}
public String getMessage() {
return message;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论