feat(任务中心): 系统&组织&项目任务中心删除任务接口部分逻辑
This commit is contained in:
parent
8e2c51c1f7
commit
28a090f5dc
|
@ -80,4 +80,14 @@ public class ProjectTaskHubController {
|
||||||
public void stopTask(@PathVariable String id) {
|
public void stopTask(@PathVariable String id) {
|
||||||
baseTaskHubService.stopTask(id, SessionUtils.getUserId(), null, SessionUtils.getCurrentProjectId());
|
baseTaskHubService.stopTask(id, SessionUtils.getUserId(), null, SessionUtils.getCurrentProjectId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/exec-task/delete/{id}")
|
||||||
|
@Operation(summary = "项目-任务中心-用例执行任务-删除任务")
|
||||||
|
@Log(type = OperationLogType.DELETE, expression = "#msClass.projectDeleteLog(#id)", msClass = BaseTaskHubLogService.class)
|
||||||
|
@RequiresPermissions(PermissionConstants.PROJECT_CASE_TASK_CENTER_DELETE)
|
||||||
|
public void deleteTask(@PathVariable String id) {
|
||||||
|
|
||||||
|
baseTaskHubService.deleteTask(id, null, SessionUtils.getCurrentProjectId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ public class ProjectTaskHubControllerTests extends BaseTest {
|
||||||
public static final String PROJECT_STATISTICS = "/project/task-center/exec-task/statistics";
|
public static final String PROJECT_STATISTICS = "/project/task-center/exec-task/statistics";
|
||||||
public static final String PROJECT_RESOURCE_POOL_OPTIONS = "/project/task-center/resource-pool/options";
|
public static final String PROJECT_RESOURCE_POOL_OPTIONS = "/project/task-center/resource-pool/options";
|
||||||
public static final String PROJECT_TASK_STOP = "/project/task-center/exec-task/stop/";
|
public static final String PROJECT_TASK_STOP = "/project/task-center/exec-task/stop/";
|
||||||
|
public static final String PROJECT_TASK_DELETE = "/project/task-center/exec-task/delete/";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
|
@ -121,4 +122,19 @@ public class ProjectTaskHubControllerTests extends BaseTest {
|
||||||
// 返回请求正常
|
// 返回请求正常
|
||||||
Assertions.assertNotNull(resultHolder);
|
Assertions.assertNotNull(resultHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目执行任务删除
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
@Order(5)
|
||||||
|
public void projectTaskDelete() throws Exception {
|
||||||
|
MvcResult mvcResult = this.requestGetWithOkAndReturn(PROJECT_TASK_DELETE + "4");
|
||||||
|
// 获取返回值
|
||||||
|
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||||
|
// 返回请求正常
|
||||||
|
Assertions.assertNotNull(resultHolder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,4 +87,13 @@ public class OrganizationTaskHubController {
|
||||||
public void stopTask(@PathVariable String id) {
|
public void stopTask(@PathVariable String id) {
|
||||||
baseTaskHubService.stopTask(id, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), null);
|
baseTaskHubService.stopTask(id, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/exec-task/delete/{id}")
|
||||||
|
@Operation(summary = "组织-任务中心-用例执行任务-删除任务")
|
||||||
|
@Log(type = OperationLogType.DELETE, expression = "#msClass.orgDeleteLog(#id)", msClass = BaseTaskHubLogService.class)
|
||||||
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_CASE_TASK_CENTER_DELETE)
|
||||||
|
public void deleteTask(@PathVariable String id) {
|
||||||
|
baseTaskHubService.deleteTask(id, SessionUtils.getCurrentOrganizationId(), null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,15 @@ public class SystemTaskHubController {
|
||||||
baseTaskHubService.stopTask(id, SessionUtils.getUserId(), null, null);
|
baseTaskHubService.stopTask(id, SessionUtils.getUserId(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/exec-task/delete/{id}")
|
||||||
|
@Operation(summary = "系统-任务中心-用例执行任务-删除任务")
|
||||||
|
@Log(type = OperationLogType.DELETE, expression = "#msClass.systemDeleteLog(#id)", msClass = BaseTaskHubLogService.class)
|
||||||
|
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_DELETE)
|
||||||
|
public void deleteTask(@PathVariable String id) {
|
||||||
|
baseTaskHubService.deleteTask(id, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
//TODO 系统&组织&项目 任务按钮操作:删除 停止 失败重跑 查看报告 批量删除 批量停止 批量失败重跑
|
//TODO 系统&组织&项目 任务按钮操作:删除 停止 失败重跑 查看报告 批量删除 批量停止 批量失败重跑
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,4 +14,6 @@ public interface ExtExecTaskMapper {
|
||||||
List<TaskHubDTO> selectList(@Param("request") BasePageRequest request, @Param("orgId") String orgId, @Param("projectId") String projectId);
|
List<TaskHubDTO> selectList(@Param("request") BasePageRequest request, @Param("orgId") String orgId, @Param("projectId") String projectId);
|
||||||
|
|
||||||
void updateTaskStatus(@Param("execTask") ExecTask execTask);
|
void updateTaskStatus(@Param("execTask") ExecTask execTask);
|
||||||
|
|
||||||
|
void deleteTaskById(@Param("id") String id, @Param("orgId") String orgId, @Param("projectId") String projectId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,5 +32,19 @@
|
||||||
<if test="execTask.organizationId != null and execTask.organizationId != ''">
|
<if test="execTask.organizationId != null and execTask.organizationId != ''">
|
||||||
and organization_id = #{execTask.organizationId}
|
and organization_id = #{execTask.organizationId}
|
||||||
</if>
|
</if>
|
||||||
|
and `status` = 'RUNNING'
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteTaskById">
|
||||||
|
DELETE
|
||||||
|
FROM exec_task
|
||||||
|
WHERE id = #{id}
|
||||||
|
<if test="projectId != null and projectId != ''">
|
||||||
|
and project_id = #{projectId}
|
||||||
|
</if>
|
||||||
|
<if test="orgId != null and orgId != ''">
|
||||||
|
and organization_id = #{orgId}
|
||||||
|
</if>
|
||||||
|
and `status` in ('PENDING', 'STOPPED', 'COMPLETED')
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
|
@ -89,4 +89,69 @@ public class BaseTaskHubLogService {
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统删除任务日志
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public LogDTO systemDeleteLog(String id) {
|
||||||
|
ExecTask execTask = execTaskMapper.selectByPrimaryKey(id);
|
||||||
|
LogDTO dto = null;
|
||||||
|
if (execTask != null) {
|
||||||
|
dto = new LogDTO(
|
||||||
|
OperationLogConstants.SYSTEM,
|
||||||
|
OperationLogConstants.SYSTEM,
|
||||||
|
execTask.getId(),
|
||||||
|
null,
|
||||||
|
OperationLogType.DELETE.name(),
|
||||||
|
OperationLogModule.SETTING_SYSTEM_TASK_CENTER,
|
||||||
|
execTask.getTaskName());
|
||||||
|
}
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织删除任务日志
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public LogDTO orgDeleteLog(String id) {
|
||||||
|
ExecTask execTask = execTaskMapper.selectByPrimaryKey(id);
|
||||||
|
LogDTO dto = null;
|
||||||
|
if (execTask != null) {
|
||||||
|
dto = new LogDTO(
|
||||||
|
OperationLogConstants.ORGANIZATION,
|
||||||
|
null,
|
||||||
|
execTask.getId(),
|
||||||
|
null,
|
||||||
|
OperationLogType.DELETE.name(),
|
||||||
|
OperationLogModule.SETTING_ORGANIZATION_TASK_CENTER,
|
||||||
|
execTask.getTaskName());
|
||||||
|
}
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目删除任务日志
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public LogDTO projectDeleteLog(String id) {
|
||||||
|
ExecTask execTask = execTaskMapper.selectByPrimaryKey(id);
|
||||||
|
LogDTO dto = null;
|
||||||
|
if (execTask != null) {
|
||||||
|
dto = new LogDTO(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
execTask.getId(),
|
||||||
|
null,
|
||||||
|
OperationLogType.DELETE.name(),
|
||||||
|
OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER,
|
||||||
|
execTask.getTaskName());
|
||||||
|
}
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -398,7 +398,7 @@ public class BaseTaskHubService {
|
||||||
extExecTaskMapper.updateTaskStatus(execTask);
|
extExecTaskMapper.updateTaskStatus(execTask);
|
||||||
//2.更新任务明细状态
|
//2.更新任务明细状态
|
||||||
ExecTaskItemExample itemExample = new ExecTaskItemExample();
|
ExecTaskItemExample itemExample = new ExecTaskItemExample();
|
||||||
itemExample.createCriteria().andTaskIdEqualTo(id);
|
itemExample.createCriteria().andTaskIdEqualTo(id).andStatusEqualTo(ExecStatus.RUNNING.name());
|
||||||
ExecTaskItem execTaskItem = new ExecTaskItem();
|
ExecTaskItem execTaskItem = new ExecTaskItem();
|
||||||
execTaskItem.setStatus(ExecStatus.STOPPED.name());
|
execTaskItem.setStatus(ExecStatus.STOPPED.name());
|
||||||
execTaskItem.setExecutor(userId);
|
execTaskItem.setExecutor(userId);
|
||||||
|
@ -407,4 +407,14 @@ public class BaseTaskHubService {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteTask(String id, String orgId, String projectId) {
|
||||||
|
//1.删除任务
|
||||||
|
extExecTaskMapper.deleteTaskById(id, orgId, projectId);
|
||||||
|
//2.删除任务明细
|
||||||
|
ExecTaskItemExample itemExample = new ExecTaskItemExample();
|
||||||
|
itemExample.createCriteria().andTaskIdEqualTo(id);
|
||||||
|
execTaskItemMapper.deleteByExample(itemExample);
|
||||||
|
//TODO jmeter执行队列中移除
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||||
public static final String SYSTEM_RESOURCE_POOL_OPTIONS = "/system/task-center/resource-pool/options";
|
public static final String SYSTEM_RESOURCE_POOL_OPTIONS = "/system/task-center/resource-pool/options";
|
||||||
public static final String SYSTEM_RESOURCE_POOL_STATUS = "/system/task-center/resource-pool/status";
|
public static final String SYSTEM_RESOURCE_POOL_STATUS = "/system/task-center/resource-pool/status";
|
||||||
public static final String SYSTEM_TASK_STOP = "/system/task-center/exec-task/stop/";
|
public static final String SYSTEM_TASK_STOP = "/system/task-center/exec-task/stop/";
|
||||||
|
public static final String SYSTEM_TASK_DELETE = "/system/task-center/exec-task/delete/";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
|
@ -154,6 +155,21 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统执行任务删除
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
@Order(4)
|
||||||
|
public void systemTaskDelete() throws Exception {
|
||||||
|
MvcResult mvcResult = this.requestGetWithOkAndReturn(SYSTEM_TASK_DELETE + "4");
|
||||||
|
// 获取返回值
|
||||||
|
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||||
|
// 返回请求正常
|
||||||
|
Assertions.assertNotNull(resultHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组织任务中心测试用例
|
* 组织任务中心测试用例
|
||||||
*/
|
*/
|
||||||
|
@ -163,6 +179,7 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||||
public static final String ORG_STATISTICS = "/organization/task-center/exec-task/statistics";
|
public static final String ORG_STATISTICS = "/organization/task-center/exec-task/statistics";
|
||||||
public static final String ORG_RESOURCE_POOL_OPTIONS = "/organization/task-center/resource-pool/options";
|
public static final String ORG_RESOURCE_POOL_OPTIONS = "/organization/task-center/resource-pool/options";
|
||||||
public static final String ORG_TASK_STOP = "/organization/task-center/exec-task/stop/";
|
public static final String ORG_TASK_STOP = "/organization/task-center/exec-task/stop/";
|
||||||
|
public static final String ORG_TASK_DELETE = "/organization/task-center/exec-task/delete/";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(20)
|
@Order(20)
|
||||||
|
@ -259,6 +276,20 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||||
Assertions.assertNotNull(resultHolder);
|
Assertions.assertNotNull(resultHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织执行任务删除
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
@Order(5)
|
||||||
|
public void orgTaskDelete() throws Exception {
|
||||||
|
MvcResult mvcResult = this.requestGetWithOkAndReturn(ORG_TASK_DELETE + "4");
|
||||||
|
// 获取返回值
|
||||||
|
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||||
|
// 返回请求正常
|
||||||
|
Assertions.assertNotNull(resultHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -2,7 +2,8 @@ INSERT INTO `exec_task`(`id`, `num`, `task_name`, `status`, `case_count`, `resul
|
||||||
VALUES
|
VALUES
|
||||||
('1', 1, '测试任务1', 'SUCCESS', 10, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '100001', 1727676089639, 'wx', 1727676089639, 1727676089639),
|
('1', 1, '测试任务1', 'SUCCESS', 10, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '100001', 1727676089639, 'wx', 1727676089639, 1727676089639),
|
||||||
('2', 2, '测试任务2', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '12345567', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639),
|
('2', 2, '测试任务2', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '12345567', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639),
|
||||||
('3', 3, '测试任务3', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639);
|
('3', 3, '测试任务3', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639),
|
||||||
|
('4', 4, '删除任务4', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue