提交 047c7faf authored 作者: mry's avatar mry

feat(web): 完善crud,按行为id查询,按项目id查询

上级 8834ac31
......@@ -119,7 +119,7 @@ public class ActionController {
* @return 符合项目id的动作
*/
@ApiOperation(value = "根据项目id查询所有")
@GetMapping("/{projectId}")
@GetMapping("/project/{projectId}")
public CommonResult<List<Action>> findByProjectIdAction(@PathVariable Integer projectId) {
List<Action> results = actionService.findByProjectIdAction(projectId);
if (results != null && results.size() != 0) {
......@@ -127,9 +127,24 @@ public class ActionController {
} else {
return CommonResult.failed("查询失败或无数据");
}
//todo 未完成
}
/**
* 根据行为id查询动作
*
* @param moveId 行为id
* @return 符合行为id的动作
*/
@ApiOperation(value = "根据行为id查询所有")
@GetMapping("/move/{moveId}")
public CommonResult<List<Action>> findByMoveIdAction(@PathVariable Integer moveId) {
List<Action> results = actionService.findByMoveIdAction(moveId);
if (results != null && results.size() != 0) {
return CommonResult.success(results);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
}
......@@ -112,4 +112,21 @@ public class DynamicVariableController {
}
}
/**
* 根据项目id查询动作
*
* @param projectId 项目id
* @return 符合项目id的动作
*/
@ApiOperation(value = "根据项目id查询所有")
@GetMapping("/project/{projectId}")
public CommonResult<List<DynamicVariable>> findByProjectIdDynamicVariable(@PathVariable Integer projectId) {
List<DynamicVariable> results = dynamicVariableService.findByProjectIdDynamicVariable(projectId);
if (results != null && results.size() != 0) {
return CommonResult.success(results);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
}
\ No newline at end of file
......@@ -112,5 +112,22 @@ public class EnvironmentController {
}
}
/**
* 根据项目id查询动作
*
* @param projectId 项目id
* @return 符合项目id的动作
*/
@ApiOperation(value = "根据项目id查询所有")
@GetMapping("/project/{projectId}")
public CommonResult<List<Environment>> findByProjectIdEnvironment(@PathVariable Integer projectId) {
List<Environment> results = environmentService.findByProjectIdEnvironment(projectId);
if (results != null && results.size() != 0) {
return CommonResult.success(results);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
}
......@@ -112,5 +112,22 @@ public class MoveController {
}
}
/**
* 根据项目id查询动作
*
* @param projectId 项目id
* @return 符合项目id的动作
*/
@ApiOperation(value = "根据项目id查询所有")
@GetMapping("/project/{projectId}")
public CommonResult<List<Move>> findByProjectIdMove(@PathVariable Integer projectId) {
List<Move> results = moveService.findByProjectIdMove(projectId);
if (results != null && results.size() != 0) {
return CommonResult.success(results);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
}
......@@ -37,9 +37,9 @@ public class TestCaseController {
@GetMapping
public CommonResult<List<TestCase>> findAllTestCase() {
List<TestCase> results = testCaseService.findAllTestCase();
if(results != null && results.size() != 0){
if (results != null && results.size() != 0) {
return CommonResult.success(results);
}else {
} else {
return CommonResult.failed("查询失败或无数据");
}
}
......@@ -54,9 +54,9 @@ public class TestCaseController {
@GetMapping("/{id}")
public CommonResult<TestCase> findByIdTestCase(@PathVariable Integer id) {
TestCase result = testCaseService.findByIdTestCase(id);
if (result != null){
if (result != null) {
return CommonResult.success(result);
}else {
} else {
return CommonResult.failed("查询失败或无数据");
}
}
......@@ -71,9 +71,9 @@ public class TestCaseController {
@PostMapping
public CommonResult<TestCase> insertTestCase(@RequestBody TestCase testCase) {
int i = testCaseService.insertTestCase(testCase);
if (i != 0){
if (i != 0) {
return CommonResult.success(testCase);
}else {
} else {
return CommonResult.failed("添加失败");
}
}
......@@ -88,9 +88,9 @@ public class TestCaseController {
@PutMapping("/{id}")
public CommonResult<TestCase> updateTestCase(@RequestBody TestCase testCase) {
int i = testCaseService.updateTestCase(testCase);
if (i != 0){
if (i != 0) {
return CommonResult.success(testCase);
}else {
} else {
return CommonResult.failed("修改失败");
}
}
......@@ -105,12 +105,29 @@ public class TestCaseController {
@DeleteMapping("/{id}")
public CommonResult<TestCase> deleteTestCase(@PathVariable Integer id) {
int i = testCaseService.deleteTestCase(id);
if (i != 0){
if (i != 0) {
return CommonResult.success("删除成功");
}else {
} else {
return CommonResult.failed("删除失败,或不存在需要删除的数据");
}
}
/**
* 根据项目id查询动作
*
* @param projectId 项目id
* @return 符合项目id的动作
*/
@ApiOperation(value = "根据项目id查询所有")
@GetMapping("/project/{projectId}")
public CommonResult<List<TestCase>> findByProjectIdTestCase(@PathVariable Integer projectId) {
List<TestCase> results = testCaseService.findByProjectIdTestCase(projectId);
if (results != null && results.size() != 0) {
return CommonResult.success(results);
} else {
return CommonResult.failed("查询失败或无数据");
}
}
}
......@@ -2,6 +2,7 @@ package org.matrix.autotest.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.matrix.autotest.entity.Action;
import org.matrix.autotest.entity.Move;
import java.util.List;
......@@ -62,4 +63,12 @@ public interface ActionService extends IService<Action> {
*/
List<Action> findByProjectIdAction(Integer projectId);
/**
* 根据行为id查询动作
*
* @param moveId 行为id
* @return 符合行为id的动作
*/
List<Action> findByMoveIdAction(Integer moveId);
}
......@@ -53,4 +53,12 @@ public interface DynamicVariableService extends IService<DynamicVariable> {
*/
int deleteDynamicVariable(Integer id);
/**
* 根据项目id查询动作
*
* @param projectId 项目id
* @return 符合项目id的动作
*/
List<DynamicVariable> findByProjectIdDynamicVariable(Integer projectId);
}
......@@ -53,4 +53,12 @@ public interface EnvironmentService extends IService<Environment> {
*/
int deleteEnvironment(Integer id);
/**
* 根据项目id查询动作
*
* @param projectId 项目id
* @return 符合项目id的动作
*/
List<Environment> findByProjectIdEnvironment(Integer projectId);
}
......@@ -58,4 +58,11 @@ public class ActionServiceImpl extends ServiceImpl<ActionMapper, Action> impleme
return actionMapper.selectList(queryWrapper);
}
@Override
public List<Action> findByMoveIdAction(Integer moveId) {
QueryWrapper<Action> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("move_id", moveId);
return actionMapper.selectList(queryWrapper);
}
}
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.DynamicVariableMapper;
import org.matrix.autotest.entity.DynamicVariable;
......@@ -51,4 +52,11 @@ public class DynamicVariableServiceImpl extends ServiceImpl<DynamicVariableMappe
return dynamicVariableMapper.deleteById(id);
}
@Override
public List<DynamicVariable> findByProjectIdDynamicVariable(Integer projectId) {
QueryWrapper<DynamicVariable> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("project_id", projectId);
return dynamicVariableMapper.selectList(queryWrapper);
}
}
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.EnvironmentMapper;
import org.matrix.autotest.entity.Environment;
......@@ -50,4 +51,11 @@ public class EnvironmentServiceImpl extends ServiceImpl<EnvironmentMapper, Envir
return environmentMapper.deleteById(id);
}
@Override
public List<Environment> findByProjectIdEnvironment(Integer projectId) {
QueryWrapper<Environment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("project_id", projectId);
return environmentMapper.selectList(queryWrapper);
}
}
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.MoveMapper;
import org.matrix.autotest.entity.Move;
......@@ -50,4 +51,11 @@ public class MoveServiceImpl extends ServiceImpl<MoveMapper, Move> implements Mo
return moveMapper.deleteById(id);
}
@Override
public List<Move> findByProjectIdMove(Integer projectId) {
QueryWrapper<Move> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("project_id", projectId);
return moveMapper.selectList(queryWrapper);
}
}
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.TestCaseMapper;
import org.matrix.autotest.entity.TestCase;
......@@ -50,4 +51,11 @@ public class TestCaseServiceImpl extends ServiceImpl<TestCaseMapper, TestCase> i
return testCaseMapper.deleteById(id);
}
@Override
public List<TestCase> findByProjectIdTestCase(Integer projectId) {
QueryWrapper<TestCase> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("project_id", projectId);
return testCaseMapper.selectList(queryWrapper);
}
}
......@@ -53,4 +53,12 @@ public interface MoveService extends IService<Move> {
*/
int deleteMove(Integer id);
/**
* 根据项目id查询动作
*
* @param projectId 项目id
* @return 符合项目id的动作
*/
List<Move> findByProjectIdMove(Integer projectId);
}
......@@ -53,4 +53,12 @@ public interface TestCaseService extends IService<TestCase> {
*/
int deleteTestCase(Integer id);
/**
* 根据项目id查询动作
*
* @param projectId 项目id
* @return 符合项目id的动作
*/
List<TestCase> findByProjectIdTestCase(Integer projectId);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论