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 index f668c37..45d079e 100644 --- a/test-test/src/main/java/com/test/test/controller/TestCaseController.java +++ b/test-test/src/main/java/com/test/test/controller/TestCaseController.java @@ -4,7 +4,7 @@ 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 com.test.test.domain.qo.GroupIdQO; import jakarta.annotation.Resource; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; @@ -33,7 +33,7 @@ public class TestCaseController extends BaseController { * 查询用例列表 */ @GetMapping("/list") - public TableDataInfo list(@Validated TestCaseListQO qo) { + public TableDataInfo list(@Validated GroupIdQO qo) { startPage(); List list = testCaseService.selectTestCaseList(qo); return getDataTable(list); diff --git a/test-test/src/main/java/com/test/test/controller/TestTaskController.java b/test-test/src/main/java/com/test/test/controller/TestTaskController.java new file mode 100644 index 0000000..7678acb --- /dev/null +++ b/test-test/src/main/java/com/test/test/controller/TestTaskController.java @@ -0,0 +1,83 @@ +package com.test.test.controller; + +import java.util.List; + +import com.test.common.utils.DateUtils; +import com.test.test.domain.qo.GroupIdQO; +import com.test.test.domain.qo.IDQO; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +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.TestTask; +import com.test.test.service.ITestTaskService; +import com.test.common.utils.poi.ExcelUtil; +import com.test.common.core.page.TableDataInfo; + +/** + * 自动化测试Controller + */ +@RestController +@RequestMapping("/test/task") +public class TestTaskController extends BaseController { + @Resource + private ITestTaskService testTaskService; + + /** + * 查询自动化测试列表 + */ + @GetMapping("/list") + public TableDataInfo list(GroupIdQO qo) { + startPage(); + List list = testTaskService.selectTestTaskList(qo); + return getDataTable(list); + } + + /** + * 获取自动化测试详细信息 + */ + @PostMapping(value = "/detail") + public AjaxResult getInfo(@RequestBody IDQO qo) { + return success(testTaskService.selectTestTaskById(qo.getId())); + } + + /** + * 新增自动化测试 + */ + @Log(title = "自动化测试", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult add(@RequestBody TestTask testTask) { + testTask.setCreateBy(getLoginUser().getUsername()); + testTask.setCreateTime(DateUtils.getNowDate()); + testTask.setStatus(0); + return toAjax(testTaskService.insertTestTask(testTask)); + } + + /** + * 修改自动化测试 + */ + @Log(title = "自动化测试", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + public AjaxResult edit(@RequestBody TestTask testTask) { + return toAjax(testTaskService.updateTestTask(testTask)); + } + + /** + * 删除自动化测试 + */ + @Log(title = "自动化测试", businessType = BusinessType.DELETE) + @PostMapping("/del") + public AjaxResult remove(@RequestBody IDQO qo) { + return toAjax(testTaskService.deleteTestTaskById(qo.getId())); + } +} diff --git a/test-test/src/main/java/com/test/test/domain/TestTask.java b/test-test/src/main/java/com/test/test/domain/TestTask.java new file mode 100644 index 0000000..b80f231 --- /dev/null +++ b/test-test/src/main/java/com/test/test/domain/TestTask.java @@ -0,0 +1,74 @@ +package com.test.test.domain; + +import com.test.common.core.domain.BaseEntity; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import com.test.common.annotation.Excel; + +/** + * 自动化测试对象 test_task + */ +@Getter +@Setter +@ToString +public class TestTask extends BaseEntity { + + /** + * 任务id + */ + private Long id; + + /** + * 任务名称 + */ + @Excel(name = "任务名称") + private String name; + + /** + * 节点id + */ + @Excel(name = "节点id") + private Long groupId; + + /** + * 项目id + */ + @Excel(name = "项目id") + private Long projectId; + + /** + * crontab表达式 + */ + @Excel(name = "crontab表达式") + private String crontab; + + /** + * 定时任务开关 + */ + @Excel(name = "定时任务开关") + private Integer status; + + /** + * 失败重试开关 + */ + @Excel(name = "失败重试开关") + private Integer retry; + + /** + * 失败重试次数 + */ + @Excel(name = "失败重试次数") + private Long retryCount; + + /** + * 并行开关 + */ + @Excel(name = "并行开关") + private Integer async; + + /** + * 删除标志(0代表存在 2代表删除) + */ + private String delFlag; +} 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/GroupIdQO.java similarity index 86% rename from test-test/src/main/java/com/test/test/domain/qo/TestCaseListQO.java rename to test-test/src/main/java/com/test/test/domain/qo/GroupIdQO.java index 56ed405..b690898 100644 --- a/test-test/src/main/java/com/test/test/domain/qo/TestCaseListQO.java +++ b/test-test/src/main/java/com/test/test/domain/qo/GroupIdQO.java @@ -4,7 +4,7 @@ import jakarta.validation.constraints.NotNull; import lombok.Data; @Data -public class TestCaseListQO { +public class GroupIdQO { @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 9b224eb..58cbbf7 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,7 +1,7 @@ package com.test.test.mapper; import com.test.test.domain.TestCase; -import com.test.test.domain.qo.TestCaseListQO; +import com.test.test.domain.qo.GroupIdQO; import java.util.List; @@ -18,7 +18,7 @@ public interface TestCaseMapper /** * 查询用例列表 */ - List selectTestCaseList(TestCaseListQO qo); + List selectTestCaseList(GroupIdQO qo); /** * 新增用例 diff --git a/test-test/src/main/java/com/test/test/mapper/TestTaskMapper.java b/test-test/src/main/java/com/test/test/mapper/TestTaskMapper.java new file mode 100644 index 0000000..c81531f --- /dev/null +++ b/test-test/src/main/java/com/test/test/mapper/TestTaskMapper.java @@ -0,0 +1,41 @@ +package com.test.test.mapper; + +import java.util.List; + +import com.test.test.domain.TestTask; +import com.test.test.domain.qo.GroupIdQO; + +/** + * 自动化测试Mapper接口 + */ +public interface TestTaskMapper { + /** + * 查询自动化测试 + */ + TestTask selectTestTaskById(Long id); + + /** + * 查询自动化测试列表 + */ + List selectTestTaskList(GroupIdQO testTask); + + /** + * 新增自动化测试 + */ + int insertTestTask(TestTask testTask); + + /** + * 修改自动化测试 + */ + int updateTestTask(TestTask testTask); + + /** + * 删除自动化测试 + */ + int deleteTestTaskById(Long id); + + /** + * 批量删除自动化测试 + */ + int deleteTestTaskByIds(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 index c79ebcc..a33bb51 100644 --- a/test-test/src/main/java/com/test/test/service/ITestCaseService.java +++ b/test-test/src/main/java/com/test/test/service/ITestCaseService.java @@ -1,7 +1,7 @@ package com.test.test.service; import com.test.test.domain.TestCase; -import com.test.test.domain.qo.TestCaseListQO; +import com.test.test.domain.qo.GroupIdQO; import java.util.List; @@ -27,7 +27,7 @@ public interface ITestCaseService * @param qo 用例 * @return 用例集合 */ - public List selectTestCaseList(TestCaseListQO qo); + public List selectTestCaseList(GroupIdQO qo); /** * 新增用例 diff --git a/test-test/src/main/java/com/test/test/service/ITestTaskService.java b/test-test/src/main/java/com/test/test/service/ITestTaskService.java new file mode 100644 index 0000000..4de22f6 --- /dev/null +++ b/test-test/src/main/java/com/test/test/service/ITestTaskService.java @@ -0,0 +1,41 @@ +package com.test.test.service; + +import java.util.List; +import com.test.test.domain.TestTask; +import com.test.test.domain.qo.GroupIdQO; + +/** + * 自动化测试Service接口 + */ +public interface ITestTaskService +{ + /** + * 查询自动化测试 + */ + TestTask selectTestTaskById(Long id); + + /** + * 查询自动化测试列表 + */ + List selectTestTaskList(GroupIdQO testTask); + + /** + * 新增自动化测试 + */ + int insertTestTask(TestTask testTask); + + /** + * 修改自动化测试 + */ + int updateTestTask(TestTask testTask); + + /** + * 批量删除自动化测试 + */ + int deleteTestTaskByIds(Long[] ids); + + /** + * 删除自动化测试信息 + */ + int deleteTestTaskById(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 index 842f45a..3d22868 100644 --- 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 @@ -68,7 +68,7 @@ public class TestCaseServiceImpl implements ITestCaseService * @return 用例 */ @Override - public List selectTestCaseList(TestCaseListQO qo) { + public List selectTestCaseList(GroupIdQO qo) { return testCaseMapper.selectTestCaseList(qo); } diff --git a/test-test/src/main/java/com/test/test/service/impl/TestTaskServiceImpl.java b/test-test/src/main/java/com/test/test/service/impl/TestTaskServiceImpl.java new file mode 100644 index 0000000..cd1c25e --- /dev/null +++ b/test-test/src/main/java/com/test/test/service/impl/TestTaskServiceImpl.java @@ -0,0 +1,70 @@ +package com.test.test.service.impl; + +import java.util.List; + +import com.test.common.utils.DateUtils; +import com.test.test.domain.qo.GroupIdQO; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import com.test.test.mapper.TestTaskMapper; +import com.test.test.domain.TestTask; +import com.test.test.service.ITestTaskService; + +/** + * 自动化测试Service业务层处理 + */ +@Service +public class TestTaskServiceImpl implements ITestTaskService { + + @Resource + private TestTaskMapper testTaskMapper; + + /** + * 查询自动化测试 + */ + @Override + public TestTask selectTestTaskById(Long id) { + return testTaskMapper.selectTestTaskById(id); + } + + /** + * 查询自动化测试列表 + */ + @Override + public List selectTestTaskList(GroupIdQO qo) { + return testTaskMapper.selectTestTaskList(qo); + } + + /** + * 新增自动化测试 + */ + @Override + public int insertTestTask(TestTask testTask) { + return testTaskMapper.insertTestTask(testTask); + } + + /** + * 修改自动化测试 + */ + @Override + public int updateTestTask(TestTask testTask) { + testTask.setUpdateTime(DateUtils.getNowDate()); + return testTaskMapper.updateTestTask(testTask); + } + + /** + * 批量删除自动化测试 + */ + @Override + public int deleteTestTaskByIds(Long[] ids) { + return testTaskMapper.deleteTestTaskByIds(ids); + } + + /** + * 删除自动化测试信息 + */ + @Override + public int deleteTestTaskById(Long id) { + return testTaskMapper.deleteTestTaskById(id); + } +} diff --git a/test-test/src/main/resources/mapper/test/TestCaseMapper.xml b/test-test/src/main/resources/mapper/test/TestCaseMapper.xml index 846430e..9eed395 100644 --- a/test-test/src/main/resources/mapper/test/TestCaseMapper.xml +++ b/test-test/src/main/resources/mapper/test/TestCaseMapper.xml @@ -33,7 +33,7 @@ from test_case - group_id = #{groupId} diff --git a/test-test/src/main/resources/mapper/test/TestTaskMapper.xml b/test-test/src/main/resources/mapper/test/TestTaskMapper.xml new file mode 100644 index 0000000..3539436 --- /dev/null +++ b/test-test/src/main/resources/mapper/test/TestTaskMapper.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, name, group_id, project_id, crontab, status, retry, retry_count, async, del_flag, create_by, create_time, update_by, update_time from test_task + + + + + + + + insert into test_task + + name, + group_id, + project_id, + crontab, + status, + retry, + retry_count, + async, + del_flag, + create_by, + create_time, + update_by, + update_time, + + + #{name}, + #{groupId}, + #{projectId}, + #{crontab}, + #{status}, + #{retry}, + #{retryCount}, + #{async}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update test_task + + name = #{name}, + group_id = #{groupId}, + project_id = #{projectId}, + crontab = #{crontab}, + status = #{status}, + retry = #{retry}, + retry_count = #{retryCount}, + async = #{async}, + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from test_task where id = #{id} + + + + delete from test_task where id in + + #{id} + + + \ No newline at end of file diff --git a/test-ui/src/assets/images/header.png b/test-ui/src/assets/images/header.png new file mode 100644 index 0000000..57030eb Binary files /dev/null and b/test-ui/src/assets/images/header.png differ diff --git a/test-ui/src/views/test/case/index.vue b/test-ui/src/views/test/case/index.vue index 471c478..fec42c2 100644 --- a/test-ui/src/views/test/case/index.vue +++ b/test-ui/src/views/test/case/index.vue @@ -62,7 +62,7 @@ export default { }); }, handleAdd() { - this.$prompt('请输入名称', '提示', { + this.$prompt('请输入名称', '新增', { confirmButtonText: '确定', cancelButtonText: '取消', inputPattern: /^(?!\s*$).+/, @@ -80,7 +80,7 @@ export default { }); }, handleRowClick(row) { - this.$tab.openPage("用例 - " + row.name, "/case/detail", {id: row.id}); + this.$tab.openPage(`用例[${row.name}]`, "/case/detail", {id: row.id}); }, handleDelete(id) { this.$modal.confirm('是否确认删除用例?').then(function () { diff --git a/test-ui/src/views/test/task/edit/clickOutside.js b/test-ui/src/views/test/task/edit/clickOutside.js new file mode 100644 index 0000000..f4019d3 --- /dev/null +++ b/test-ui/src/views/test/task/edit/clickOutside.js @@ -0,0 +1,18 @@ +// clickOutside.js +export default { + bind(el, binding, vnode) { + el.clickOutsideEvent = function (event) { + // 检查点击事件的目标元素是否是绑定指令的元素或其子元素 + if (!(el === event.target || el.contains(event.target))) { + // 如果不是,则调用传递给指令的方法 + vnode.context[binding.expression](event); + } + }; + // 添加事件监听器 + document.body.addEventListener("click", el.clickOutsideEvent); + }, + unbind(el) { + // 移除事件监听器 + document.body.removeEventListener("click", el.clickOutsideEvent); + }, +}; diff --git a/test-ui/src/views/test/task/edit/executionRecord.vue b/test-ui/src/views/test/task/edit/executionRecord.vue new file mode 100644 index 0000000..649104e --- /dev/null +++ b/test-ui/src/views/test/task/edit/executionRecord.vue @@ -0,0 +1,256 @@ + + + + diff --git a/test-ui/src/views/test/task/edit/executiveReport.vue b/test-ui/src/views/test/task/edit/executiveReport.vue new file mode 100644 index 0000000..e69de29 diff --git a/test-ui/src/views/test/task/edit/index.vue b/test-ui/src/views/test/task/edit/index.vue new file mode 100644 index 0000000..403f376 --- /dev/null +++ b/test-ui/src/views/test/task/edit/index.vue @@ -0,0 +1,125 @@ + + + + + diff --git a/test-ui/src/views/test/task/edit/lineChart.vue b/test-ui/src/views/test/task/edit/lineChart.vue new file mode 100644 index 0000000..0c26bb6 --- /dev/null +++ b/test-ui/src/views/test/task/edit/lineChart.vue @@ -0,0 +1,159 @@ + + + diff --git a/test-ui/src/views/test/task/edit/lineChartCover.vue b/test-ui/src/views/test/task/edit/lineChartCover.vue new file mode 100644 index 0000000..79db731 --- /dev/null +++ b/test-ui/src/views/test/task/edit/lineChartCover.vue @@ -0,0 +1,168 @@ + + + diff --git a/test-ui/src/views/test/task/edit/operationRecords.vue b/test-ui/src/views/test/task/edit/operationRecords.vue new file mode 100644 index 0000000..580607c --- /dev/null +++ b/test-ui/src/views/test/task/edit/operationRecords.vue @@ -0,0 +1,92 @@ + + + + + diff --git a/test-ui/src/views/test/task/edit/report/components/pieChart.vue b/test-ui/src/views/test/task/edit/report/components/pieChart.vue new file mode 100644 index 0000000..e545247 --- /dev/null +++ b/test-ui/src/views/test/task/edit/report/components/pieChart.vue @@ -0,0 +1,111 @@ + + + diff --git a/test-ui/src/views/test/task/edit/report/index.vue b/test-ui/src/views/test/task/edit/report/index.vue new file mode 100644 index 0000000..f1d06e9 --- /dev/null +++ b/test-ui/src/views/test/task/edit/report/index.vue @@ -0,0 +1,292 @@ + + + + + diff --git a/test-ui/src/views/test/task/edit/taskDetails.vue b/test-ui/src/views/test/task/edit/taskDetails.vue new file mode 100644 index 0000000..9d1d425 --- /dev/null +++ b/test-ui/src/views/test/task/edit/taskDetails.vue @@ -0,0 +1,735 @@ + + + + diff --git a/test-ui/src/views/test/task/edit/test1.vue b/test-ui/src/views/test/task/edit/test1.vue new file mode 100644 index 0000000..7d5e2f2 --- /dev/null +++ b/test-ui/src/views/test/task/edit/test1.vue @@ -0,0 +1,47 @@ + + + diff --git a/test-ui/src/views/test/task/edit/test2.vue b/test-ui/src/views/test/task/edit/test2.vue new file mode 100644 index 0000000..6d2fcd6 --- /dev/null +++ b/test-ui/src/views/test/task/edit/test2.vue @@ -0,0 +1,217 @@ + + + + + diff --git a/test-ui/src/views/test/task/index.vue b/test-ui/src/views/test/task/index.vue index 98deb69..f5a6829 100644 --- a/test-ui/src/views/test/task/index.vue +++ b/test-ui/src/views/test/task/index.vue @@ -1,24 +1,100 @@