diff --git a/backend/framework/domain/src/main/resources/migration/3.0.0/dml/V3.0.0_11_1__data.sql b/backend/framework/domain/src/main/resources/migration/3.0.0/dml/V3.0.0_11_1__data.sql index eabdaf3d5c..caccc650ea 100644 --- a/backend/framework/domain/src/main/resources/migration/3.0.0/dml/V3.0.0_11_1__data.sql +++ b/backend/framework/domain/src/main/resources/migration/3.0.0/dml/V3.0.0_11_1__data.sql @@ -122,5 +122,10 @@ VALUES (uuid(), 'functional_default', '', 1, UNIX_TIMESTAMP() * 1000, UNIX_TIMES INSERT INTO template_custom_field(id, field_id, template_id, required, pos, api_field_id, default_value) VALUES(uuid(), (select id from custom_field where name = 'functional_priority'), (select id from template where name = 'functional_default'), 1, 0, NULL, NULL); + +-- 初始化内置消息机器人 +Insert into project_robot(id, project_id, name, platform, webhook, type, app_key, app_secret, enable, create_user, create_time, update_user, update_time, description) VALUES (UUID_SHORT(), 'default_project', '站内信', 'IN_SITE', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null); +Insert into project_robot(id, project_id, name, platform, webhook, type, app_key, app_secret, enable, create_user, create_time, update_user, update_time, description) VALUES (UUID_SHORT(), 'default_project', '邮件', 'MAIL', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null); + -- set innodb lock wait timeout to default SET SESSION innodb_lock_wait_timeout = DEFAULT; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectRobotController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectRobotController.java index c00a9d3091..6d60639f60 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectRobotController.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectRobotController.java @@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; -@Tag(name = "项目机器人管理") +@Tag(name = "项目管理-项目与权限-消息管理-机器人") @RestController @RequestMapping("/project/robot/") public class ProjectRobotController { @@ -32,7 +32,7 @@ public class ProjectRobotController { @PostMapping("/list/page") - @Operation(summary = "获取机器人列表") + @Operation(summary = "项目管理-项目与权限-消息管理-获取机器人列表") @RequiresPermissions(PermissionConstants.PROJECT_MESSAGE_READ) public Pager> listResourcePools(@Validated @RequestBody ProjectRobotRequest request) { Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), true); @@ -40,7 +40,7 @@ public class ProjectRobotController { } @PostMapping("add") - @Operation(summary = "新增机器人管理") + @Operation(summary = "项目管理-项目与权限-消息管理-新增机器人") @RequiresPermissions(PermissionConstants.PROJECT_MESSAGE_READ_ADD) public void add(@Validated({Created.class}) @RequestBody ProjectRobotDTO projectRobotDTO) { ProjectRobot projectRobot = new ProjectRobot(); @@ -53,7 +53,7 @@ public class ProjectRobotController { } @PostMapping("update") - @Operation(summary = "更新机器人") + @Operation(summary = "项目管理-项目与权限-消息管理-更新机器人") @RequiresPermissions(PermissionConstants.PROJECT_MESSAGE_READ_UPDATE) public void update(@Validated({Updated.class}) @RequestBody ProjectRobotDTO projectRobotDTO) { ProjectRobot projectRobot = new ProjectRobot(); @@ -66,21 +66,21 @@ public class ProjectRobotController { } @GetMapping("get/{id}") - @Operation(summary = "获取机器人详情") + @Operation(summary = "项目管理-项目与权限-消息管理-获取机器人详情") @RequiresPermissions(PermissionConstants.PROJECT_MESSAGE_READ) public ProjectRobotDTO getDetail(@PathVariable(value = "id") String id) { return projectRobotService.getDetail(id); } @GetMapping("delete/{id}") - @Operation(summary = "删除机器人") + @Operation(summary = "项目管理-项目与权限-消息管理-删除机器人") @RequiresPermissions(PermissionConstants.PROJECT_MESSAGE_READ_DELETE) public void delete(@PathVariable(value = "id") String id) { projectRobotService.delete(id); } @GetMapping("enable/{id}") - @Operation(summary = "禁用机器人") + @Operation(summary = "项目管理-项目与权限-消息管理-禁用机器人") @RequiresPermissions(PermissionConstants.PROJECT_MESSAGE_READ_UPDATE) public void enable(@PathVariable(value = "id") String id) { projectRobotService.enable(id, SessionUtils.getUserId(), System.currentTimeMillis()); diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/enums/ProjectRobotPlatform.java b/backend/services/project-management/src/main/java/io/metersphere/project/enums/ProjectRobotPlatform.java index e2375afa78..4c8d2d522f 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/enums/ProjectRobotPlatform.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/enums/ProjectRobotPlatform.java @@ -1,5 +1,5 @@ package io.metersphere.project.enums; public enum ProjectRobotPlatform { - DING_TALK, LARK, WE_COM, CUSTOM + DING_TALK, LARK, WE_COM, CUSTOM, IN_SITE, MAIL } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupRobotResourceService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupRobotResourceService.java new file mode 100644 index 0000000000..6e911d9aeb --- /dev/null +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupRobotResourceService.java @@ -0,0 +1,28 @@ +package io.metersphere.project.service; + +import io.metersphere.project.domain.ProjectRobotExample; +import io.metersphere.project.mapper.ProjectRobotMapper; +import io.metersphere.sdk.service.CleanupProjectResourceService; +import io.metersphere.sdk.util.LogUtils; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; + +@Component +public class CleanupRobotResourceService implements CleanupProjectResourceService { + + @Resource + private ProjectRobotMapper robotMapper; + + @Override + public void deleteResources(String projectId) { + ProjectRobotExample projectExample = new ProjectRobotExample(); + projectExample.createCriteria().andProjectIdEqualTo(projectId); + robotMapper.deleteByExample(projectExample); + LogUtils.info("删除当前项目[" + projectId + "]相关接口测试资源"); + } + + @Override + public void cleanReportResources(String projectId) { + LogUtils.info("清理当前项目[" + projectId + "]相关接口测试报告资源"); + } +}