From 899b80a1df8ea7c5d5007f827e7d46949bc9ebbe Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Mon, 29 Jan 2024 14:29:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=B3=BB=E7=BB=9F):=20=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E6=B3=A8=E9=87=8A=E7=9A=84=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/job/CleanUpReportJob.java | 31 ------------ .../CreateApplicationResourceService.java | 49 ------------------- .../CreateApplicationResourceTests.java | 27 ---------- 3 files changed, 107 deletions(-) delete mode 100644 backend/services/project-management/src/main/java/io/metersphere/project/job/CleanUpReportJob.java delete mode 100644 backend/services/project-management/src/main/java/io/metersphere/project/service/CreateApplicationResourceService.java delete mode 100644 backend/services/project-management/src/test/java/io/metersphere/project/controller/CreateApplicationResourceTests.java diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/job/CleanUpReportJob.java b/backend/services/project-management/src/main/java/io/metersphere/project/job/CleanUpReportJob.java deleted file mode 100644 index 9ef7d1e070..0000000000 --- a/backend/services/project-management/src/main/java/io/metersphere/project/job/CleanUpReportJob.java +++ /dev/null @@ -1,31 +0,0 @@ - -//TODO 后续清理 (合并完没问题再清理)=====清理报告定时任务只有一个,cron表达式凌晨定时扫描 - -/* -package io.metersphere.project.job; - -import io.metersphere.system.schedule.BaseScheduleJob; -import org.quartz.JobExecutionContext; -import org.quartz.JobKey; -import org.quartz.TriggerKey; - -public class CleanUpReportJob extends BaseScheduleJob { - - - - @Override - protected void businessExecute(JobExecutionContext context) { - //TODO 定时任务执行 清除报告 invokerReportServices - //serviceInvoker.invokeReportServices(projectId); - } - - public static JobKey getJobKey(String projectId) { - return new JobKey(projectId, CleanUpReportJob.class.getName()); - } - - public static TriggerKey getTriggerKey(String projectId) { - return new TriggerKey(projectId, CleanUpReportJob.class.getName()); - } -} -*/ - diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/CreateApplicationResourceService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/CreateApplicationResourceService.java deleted file mode 100644 index 805f1a16c6..0000000000 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/CreateApplicationResourceService.java +++ /dev/null @@ -1,49 +0,0 @@ - -//TODO 后续清理(合并完没问题再清理)=====清理报告定时任务只有一个,cron表达式凌晨定时扫描 创建项目不再创建定时任务 -/* -package io.metersphere.project.service; - -import io.metersphere.project.job.CleanUpReportJob; -import io.metersphere.sdk.constants.ScheduleResourceType; -import io.metersphere.sdk.constants.ScheduleType; -import io.metersphere.system.domain.Schedule; -import io.metersphere.system.schedule.ScheduleService; -import io.metersphere.system.service.CreateProjectResourceService; -import jakarta.annotation.Resource; -import org.springframework.stereotype.Component; - -*/ -/** - * @author wx - *//* - -@Component -public class CreateApplicationResourceService implements CreateProjectResourceService { - - - @Resource - private ScheduleService scheduleService; - - @Override - public void createResources(String projectId) { - //初始化清理报告定时任务 - Schedule request = new Schedule(); - request.setName("Clean Report Job"); - request.setResourceId(projectId); - request.setKey(projectId); - request.setProjectId(projectId); - request.setEnable(true); - request.setCreateUser("admin"); - request.setType(ScheduleType.CRON.name()); - // 每天凌晨2点执行清理任务 - request.setValue("0 0 2 * * ?"); - request.setJob(CleanUpReportJob.class.getName()); - request.setResourceType(ScheduleResourceType.CLEAN_REPORT.name()); - scheduleService.addSchedule(request); - scheduleService.addOrUpdateCronJob(request, - CleanUpReportJob.getJobKey(projectId), - CleanUpReportJob.getTriggerKey(projectId), - CleanUpReportJob.class); - } -} -*/ diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/CreateApplicationResourceTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/CreateApplicationResourceTests.java deleted file mode 100644 index 00086bc26f..0000000000 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/CreateApplicationResourceTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/* -package io.metersphere.project.controller; - -import io.metersphere.project.service.CreateApplicationResourceService; -import jakarta.annotation.Resource; -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -@TestMethodOrder(MethodOrderer.OrderAnnotation.class) -@AutoConfigureMockMvc -public class CreateApplicationResourceTests { - - @Resource - private CreateApplicationResourceService resourceService; - - @Test - @Order(1) - public void testCleanupResource() throws Exception { - resourceService.createResources("test_project_id"); - } -} -*/