diff --git a/test-test/src/main/java/com/test/test/controller/TestApiController.java b/test-test/src/main/java/com/test/test/controller/TestApiController.java index b1c4ff1..9cf1d94 100644 --- a/test-test/src/main/java/com/test/test/controller/TestApiController.java +++ b/test-test/src/main/java/com/test/test/controller/TestApiController.java @@ -17,8 +17,6 @@ import com.test.common.core.page.TableDataInfo; /** * 接口Controller - * - * @author xiaoe */ @RestController @RequestMapping("/test/api") diff --git a/test-test/src/main/java/com/test/test/controller/TestCaseController.java b/test-test/src/main/java/com/test/test/controller/TestCaseController.java new file mode 100644 index 0000000..f668c37 --- /dev/null +++ b/test-test/src/main/java/com/test/test/controller/TestCaseController.java @@ -0,0 +1,79 @@ +package com.test.test.controller; + +import java.util.List; + +import com.test.common.utils.DateUtils; +import com.test.test.domain.qo.IDQO; +import com.test.test.domain.qo.TestCaseListQO; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.test.common.annotation.Log; +import com.test.common.core.controller.BaseController; +import com.test.common.core.domain.AjaxResult; +import com.test.common.enums.BusinessType; +import com.test.test.domain.TestCase; +import com.test.test.service.ITestCaseService; +import com.test.common.core.page.TableDataInfo; + +/** + * 用例Controller + */ +@RestController +@RequestMapping("/test/case") +public class TestCaseController extends BaseController { + @Resource + private ITestCaseService testCaseService; + + /** + * 查询用例列表 + */ + @GetMapping("/list") + public TableDataInfo list(@Validated TestCaseListQO qo) { + startPage(); + List list = testCaseService.selectTestCaseList(qo); + return getDataTable(list); + } + + /** + * 获取用例详细信息 + */ + @PostMapping(value = "/detail") + public AjaxResult getInfo(@RequestBody IDQO qo) { + return success(testCaseService.selectTestCaseById(qo.getId())); + } + + /** + * 新增用例 + */ + @Log(title = "用例", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult add(@RequestBody TestCase testCase) { + testCase.setCreateBy(getLoginUser().getUsername()); + testCase.setCreateTime(DateUtils.getNowDate()); + testCase.setStatus(1L); + return toAjax(testCaseService.insertTestCase(testCase)); + } + + /** + * 修改用例 + */ + @Log(title = "用例", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + public AjaxResult edit(@RequestBody TestCase testCase) { + return toAjax(testCaseService.updateTestCase(testCase)); + } + + /** + * 删除用例 + */ + @Log(title = "用例", businessType = BusinessType.DELETE) + @PostMapping("/del") + public AjaxResult remove(@RequestBody IDQO qo) { + return toAjax(testCaseService.deleteTestCaseById(qo.getId())); + } +} diff --git a/test-test/src/main/java/com/test/test/domain/qo/TestCaseListQO.java b/test-test/src/main/java/com/test/test/domain/qo/TestCaseListQO.java new file mode 100644 index 0000000..56ed405 --- /dev/null +++ b/test-test/src/main/java/com/test/test/domain/qo/TestCaseListQO.java @@ -0,0 +1,10 @@ +package com.test.test.domain.qo; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class TestCaseListQO { + @NotNull(message = "父节点id不能为空") + private Long groupId; +} diff --git a/test-test/src/main/java/com/test/test/mapper/TestCaseMapper.java b/test-test/src/main/java/com/test/test/mapper/TestCaseMapper.java index 6a428e7..9b224eb 100644 --- a/test-test/src/main/java/com/test/test/mapper/TestCaseMapper.java +++ b/test-test/src/main/java/com/test/test/mapper/TestCaseMapper.java @@ -1,62 +1,42 @@ package com.test.test.mapper; import com.test.test.domain.TestCase; +import com.test.test.domain.qo.TestCaseListQO; import java.util.List; /** * 用例Mapper接口 - * - * @author test - * @date 2025-02-18 */ public interface TestCaseMapper { /** * 查询用例 - * - * @param id 用例主键 - * @return 用例 */ - public TestCase selectTestCaseById(Long id); + TestCase selectTestCaseById(Long id); /** * 查询用例列表 - * - * @param testCase 用例 - * @return 用例集合 */ - public List selectTestCaseList(TestCase testCase); + List selectTestCaseList(TestCaseListQO qo); /** * 新增用例 - * - * @param testCase 用例 - * @return 结果 */ - public int insertTestCase(TestCase testCase); + int insertTestCase(TestCase testCase); /** * 修改用例 - * - * @param testCase 用例 - * @return 结果 */ - public int updateTestCase(TestCase testCase); + int updateTestCase(TestCase testCase); /** * 删除用例 - * - * @param id 用例主键 - * @return 结果 */ - public int deleteTestCaseById(Long id); + int deleteTestCaseById(Long id); /** * 批量删除用例 - * - * @param ids 需要删除的数据主键集合 - * @return 结果 */ - public int deleteTestCaseByIds(Long[] ids); + int deleteTestCaseByIds(Long[] ids); } diff --git a/test-test/src/main/java/com/test/test/service/ITestCaseService.java b/test-test/src/main/java/com/test/test/service/ITestCaseService.java new file mode 100644 index 0000000..0da03ab --- /dev/null +++ b/test-test/src/main/java/com/test/test/service/ITestCaseService.java @@ -0,0 +1,41 @@ +package com.test.test.service; + +import java.util.List; + +import com.test.test.domain.TestCase; +import com.test.test.domain.qo.TestCaseListQO; + +/** + * 用例Service接口 + */ +public interface ITestCaseService { + /** + * 查询用例 + */ + TestCase selectTestCaseById(Long id); + + /** + * 查询用例列表 + */ + List selectTestCaseList(TestCaseListQO qo); + + /** + * 新增用例 + */ + int insertTestCase(TestCase testCase); + + /** + * 修改用例 + */ + int updateTestCase(TestCase testCase); + + /** + * 批量删除用例 + */ + int deleteTestCaseByIds(Long[] ids); + + /** + * 删除用例信息 + */ + int deleteTestCaseById(Long id); +} diff --git a/test-test/src/main/java/com/test/test/service/impl/TestCaseServiceImpl.java b/test-test/src/main/java/com/test/test/service/impl/TestCaseServiceImpl.java new file mode 100644 index 0000000..2daebb4 --- /dev/null +++ b/test-test/src/main/java/com/test/test/service/impl/TestCaseServiceImpl.java @@ -0,0 +1,69 @@ +package com.test.test.service.impl; + +import java.util.List; + +import com.test.common.utils.DateUtils; +import com.test.test.domain.qo.TestCaseListQO; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import com.test.test.mapper.TestCaseMapper; +import com.test.test.domain.TestCase; +import com.test.test.service.ITestCaseService; + +/** + * 用例Service业务层处理 + */ +@Service +public class TestCaseServiceImpl implements ITestCaseService { + @Resource + private TestCaseMapper testCaseMapper; + + /** + * 查询用例 + */ + @Override + public TestCase selectTestCaseById(Long id) { + return testCaseMapper.selectTestCaseById(id); + } + + /** + * 查询用例列表 + */ + @Override + public List selectTestCaseList(TestCaseListQO qo) { + return testCaseMapper.selectTestCaseList(qo); + } + + /** + * 新增用例 + */ + @Override + public int insertTestCase(TestCase testCase) { + return testCaseMapper.insertTestCase(testCase); + } + + /** + * 修改用例 + */ + @Override + public int updateTestCase(TestCase testCase) { + testCase.setUpdateTime(DateUtils.getNowDate()); + return testCaseMapper.updateTestCase(testCase); + } + + /** + * 批量删除用例 + */ + @Override + public int deleteTestCaseByIds(Long[] ids) { + return testCaseMapper.deleteTestCaseByIds(ids); + } + + /** + * 删除用例信息 + */ + @Override + public int deleteTestCaseById(Long id) { + return testCaseMapper.deleteTestCaseById(id); + } +} diff --git a/test-test/src/main/resources/mapper/test/TestCaseMapper.xml b/test-test/src/main/resources/mapper/test/TestCaseMapper.xml index 410e0cd..846430e 100644 --- a/test-test/src/main/resources/mapper/test/TestCaseMapper.xml +++ b/test-test/src/main/resources/mapper/test/TestCaseMapper.xml @@ -33,15 +33,12 @@ from test_case - - and group_id = #{groupId} - and project_id = #{projectId} - and name like concat('%', #{name}, '%') - and importance = #{importance} - and status = #{status} + group_id = #{groupId} + order by create_time desc