diff --git a/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLog.java b/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLog.java index 1b01147b14..d78acd3d77 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLog.java +++ b/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLog.java @@ -5,9 +5,8 @@ import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; -import lombok.Data; - import java.io.Serializable; +import lombok.Data; @Data public class OperationLog implements Serializable { @@ -21,6 +20,11 @@ public class OperationLog implements Serializable { @Size(min = 1, max = 50, message = "{operation_log.project_id.length_range}", groups = {Created.class, Updated.class}) private String projectId; + @Schema(title = "组织id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{operation_log.organization_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{operation_log.organization_id.length_range}", groups = {Created.class, Updated.class}) + private String organizationId; + @Schema(title = "操作时间") private Long createTime; @@ -43,7 +47,7 @@ public class OperationLog implements Serializable { @Schema(title = "操作模块/api/case/scenario/ui") private String module; - @Schema(title = "操作内容") + @Schema(title = "操作详情") private String content; @Schema(title = "操作路径") diff --git a/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLogExample.java b/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLogExample.java index 52d819cd16..4bea901000 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLogExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/OperationLogExample.java @@ -244,6 +244,76 @@ public class OperationLogExample { return (Criteria) this; } + public Criteria andOrganizationIdIsNull() { + addCriterion("organization_id is null"); + return (Criteria) this; + } + + public Criteria andOrganizationIdIsNotNull() { + addCriterion("organization_id is not null"); + return (Criteria) this; + } + + public Criteria andOrganizationIdEqualTo(String value) { + addCriterion("organization_id =", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdNotEqualTo(String value) { + addCriterion("organization_id <>", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdGreaterThan(String value) { + addCriterion("organization_id >", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdGreaterThanOrEqualTo(String value) { + addCriterion("organization_id >=", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdLessThan(String value) { + addCriterion("organization_id <", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdLessThanOrEqualTo(String value) { + addCriterion("organization_id <=", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdLike(String value) { + addCriterion("organization_id like", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdNotLike(String value) { + addCriterion("organization_id not like", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdIn(List values) { + addCriterion("organization_id in", values, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdNotIn(List values) { + addCriterion("organization_id not in", values, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdBetween(String value1, String value2) { + addCriterion("organization_id between", value1, value2, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdNotBetween(String value1, String value2) { + addCriterion("organization_id not between", value1, value2, "organizationId"); + return (Criteria) this; + } + public Criteria andCreateTimeIsNull() { addCriterion("create_time is null"); return (Criteria) this; diff --git a/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/OperationLogMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/OperationLogMapper.xml index e8b6c4fc4e..d88cfc3118 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/OperationLogMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/OperationLogMapper.xml @@ -4,6 +4,7 @@ + @@ -72,8 +73,8 @@ - id, project_id, create_time, create_user, source_id, `method`, `type`, `module`, - content, `path` + id, project_id, organization_id, create_time, create_user, source_id, `method`, `type`, + `module`, content, `path` + SELECT + t.id, + t.project_id, + t.organization_id, + t.create_time, + t.create_user, + t.type, + t.content + FROM + operation_log t + + + AND t.create_user = #{request.operUser, jdbcType=VARCHAR} + + + AND t.create_time BETWEEN #{request.startTime} AND #{request.endTime} + + + AND t.project_id != 'system' + + + AND t.project_id IN + + #{projectId} + + + + AND t.organization_id IN + + #{organizationId} + + + + AND t.type = #{request.type, jdbcType=VARCHAR} + + + AND t.module = #{module, jdbcType=VARCHAR} + + + AND t.content like #{request.content, jdbcType=VARCHAR} + + + ORDER BY t.oper_time DESC + + + + diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseOrganizationMapper.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseOrganizationMapper.java new file mode 100644 index 0000000000..8b4d5cf3dd --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseOrganizationMapper.java @@ -0,0 +1,10 @@ +package io.metersphere.sdk.mapper; + +import io.metersphere.system.domain.Organization; + +import java.util.List; + +public interface BaseOrganizationMapper { + + List selectOrganizationByIdList(List organizationIds); +} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseOrganizationMapper.xml b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseOrganizationMapper.xml new file mode 100644 index 0000000000..7d9e448757 --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseOrganizationMapper.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseProjectMapper.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseProjectMapper.java index 81eadc0203..4809bb6f3d 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseProjectMapper.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseProjectMapper.java @@ -2,7 +2,10 @@ package io.metersphere.sdk.mapper; import io.metersphere.project.domain.Project; +import java.util.List; + public interface BaseProjectMapper { Project selectOne(); + List selectProjectByIdList(List projectIds); } diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseProjectMapper.xml b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseProjectMapper.xml index 822c79715f..d7fc7865fe 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseProjectMapper.xml +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseProjectMapper.xml @@ -6,4 +6,14 @@ FROM project LIMIT 1 + + \ No newline at end of file diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseUserMapper.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseUserMapper.java index 3c67020e25..a860987659 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseUserMapper.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseUserMapper.java @@ -24,4 +24,6 @@ public interface BaseUserMapper { List selectByKeyword(String keyword); List selectUnDeletedUserIdByIdList(@Param("idList") List userIdList); + + List selectUserByIdList(List userIds); } diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseUserMapper.xml b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseUserMapper.xml index c9a55ebc0e..6d673d3642 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseUserMapper.xml +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseUserMapper.xml @@ -67,4 +67,14 @@ #{id} + + \ No newline at end of file diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/SystemParameterService.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/SystemParameterService.java index 7a4d6cfa00..ad57798d75 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/SystemParameterService.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/SystemParameterService.java @@ -217,6 +217,7 @@ public class SystemParameterService { public LogDTO addLog(List systemParameter) { LogDTO dto = new LogDTO( "system", + "", "system-parameter", null, OperationLogType.ADD.name(), @@ -232,6 +233,7 @@ public class SystemParameterService { public LogDTO updateLog(List systemParameter) { LogDTO dto = new LogDTO( "system", + "", "system-parameter", null, OperationLogType.ADD.name(), diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/TestResourcePoolService.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/TestResourcePoolService.java index e3bcf5b5f8..e7c6ec577b 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/TestResourcePoolService.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/TestResourcePoolService.java @@ -256,6 +256,7 @@ public class TestResourcePoolService { public LogDTO addLog(TestResourcePoolRequest request) { LogDTO dto = new LogDTO( "system", + "", request.getId(), null, OperationLogType.ADD.name(), @@ -273,6 +274,7 @@ public class TestResourcePoolService { if (pool != null) { LogDTO dto = new LogDTO( "system", + "", id, pool.getCreateUser(), OperationLogType.DELETE.name(), @@ -293,6 +295,7 @@ public class TestResourcePoolService { if (pool != null) { LogDTO dto = new LogDTO( "system", + "", pool.getId(), pool.getCreateUser(), OperationLogType.UPDATE.name(), diff --git a/backend/framework/sdk/src/main/resources/i18n/commons_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/commons_en_US.properties index 5554b4b9ec..963352d5bb 100644 --- a/backend/framework/sdk/src/main/resources/i18n/commons_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/commons_en_US.properties @@ -58,6 +58,10 @@ related_case_del_fail_suffix=TestCase, please disassociate first jmx_content_valid=JMX content is invalid container_delete_fail=The container failed to stop, please try again load_test_report_file_not_exist=There is no JTL file in the current report, please wait or execute it again to get it +startTime_must_be_less_than_endTime=Start time must be less than end time +start_time_is_null=Start time cannot be null +end_time_is_null=End time cannot be null + #organization organization_not_exists=Organization is not exists #test resource pool diff --git a/backend/framework/sdk/src/main/resources/i18n/commons_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/commons_zh_CN.properties index 7cd3d172d9..489dd59c65 100644 --- a/backend/framework/sdk/src/main/resources/i18n/commons_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/commons_zh_CN.properties @@ -58,6 +58,9 @@ related_case_del_fail_suffix=测试用例,请先解除关联 jmx_content_valid=JMX 内容无效,请检查 container_delete_fail=容器由于网络原因停止失败,请重试 load_test_report_file_not_exist=当前报告没有JTL文件,请等待或重新执行以便获取 +startTime_must_be_less_than_endTime=开始日期必须小于结束日期 +start_time_is_null=开始日期不能为空 +end_time_is_null=结束日期不能为空 organization_not_exists=工作空间不存在 #test resource pool diff --git a/backend/framework/sdk/src/main/resources/i18n/commons_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/commons_zh_TW.properties index 5a7dda5961..2b043269a9 100644 --- a/backend/framework/sdk/src/main/resources/i18n/commons_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/commons_zh_TW.properties @@ -58,6 +58,10 @@ related_case_del_fail_suffix=測試用例,請先解除關聯 jmx_content_valid=JMX 內容無效,請檢查 container_delete_fail=容器由於網絡原因停止失敗,請重試 load_test_report_file_not_exist=當前報告沒有JTL文件,請等待或重新執行以便獲取 +startTime_must_be_less_than_endTime=開始日期必須小於結束日期 +start_time_is_null=開始日期不能為空 +end_time_is_null=結束日期不能為空 + #organization organization_not_exists=工作空間不存在 #test resource pool diff --git a/backend/framework/sdk/src/main/resources/i18n/system_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/system_en_US.properties index 3a8ff7666c..630edaa1b5 100644 --- a/backend/framework/sdk/src/main/resources/i18n/system_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/system_en_US.properties @@ -44,14 +44,16 @@ notification.resource_name.length_range=Notification resource name must be betwe novice_statistics.id.not_blank=Novice statistics id must not be blank novice_statistics.guide_step.not_blank=Novice statistics guide step must not be blank novice_statistics.guide_step.length_range=Novice statistics guide step must be between {min} and {max} characters long -operating_log.id.not_blank=Operating log id must not be blank -operating_log.project_id.not_blank=Operating log project id must not be blank -operating_log.project_id.length_range=Operating log project id must be between {min} and {max} characters long -operating_log_resource.id.not_blank=Operating log resource id must not be blank -operating_log_resource.operating_log_id.not_blank=Operating log resource operating log id must not be blank -operating_log_resource.operating_log_id.length_range=Operating log resource operating log id must be between {min} and {max} characters long -operating_log_resource.source_id.not_blank=Operating log resource source id must not be blank -operating_log_resource.source_id.length_range=Operating log resource source id must be between {min} and {max} characters long +operation_log.id.not_blank=Operating log id must not be blank +operation_log.project_id.not_blank=Operating log project id must not be blank +operation_log.project_id.length_range=Operating log project id must be between {min} and {max} characters long +operation_log.organization_id.not_blank=Operation log organization id must not be blank +operation_log_resource.id.not_blank=Operating log resource id must not be blank +operation_log.organization_id.length_range=Operation log organization id must be between {min} and {max} characters long +operation_log_resource.operating_log_id.not_blank=Operating log resource operating log id must not be blank +operation_log_resource.operating_log_id.length_range=Operating log resource operating log id must be between {min} and {max} characters long +operation_log_resource.source_id.not_blank=Operating log resource source id must not be blank +operation_log_resource.source_id.length_range=Operating log resource source id must be between {min} and {max} characters long plugin.id.not_blank=Plugin id must not be blank plugin.plugin_id.not_blank=Plugin plugin id must not be blank plugin.plugin_id.length_range=Plugin plugin id must be between {min} and {max} characters long diff --git a/backend/framework/sdk/src/main/resources/i18n/system_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/system_zh_CN.properties index e0e2b8d665..cae0f42fd5 100644 --- a/backend/framework/sdk/src/main/resources/i18n/system_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/system_zh_CN.properties @@ -44,14 +44,16 @@ notification.resource_name.length_range=消息通知资源名称长度必须在{ novice_statistics.id.not_blank=新手村ID不能为空 novice_statistics.guide_step.not_blank=新手村步骤不能为空 novice_statistics.guide_step.length_range=新手村步骤长度必须在{min}和{max}之间 -operating_log.id.not_blank=操作日志ID不能为空 -operating_log.project_id.not_blank=操作日志项目ID不能为空 -operating_log.project_id.length_range=操作日志项目ID长度必须在{min}和{max}之间 -operating_log_resource.id.not_blank=操作日志资源ID不能为空 -operating_log_resource.operating_log_id.not_blank=操作日志资源操作日志ID不能为空 -operating_log_resource.operating_log_id.length_range=操作日志资源操作日志ID长度必须在{min}和{max}之间 -operating_log_resource.source_id.not_blank=操作日志资源来源ID不能为空 -operating_log_resource.source_id.length_range=操作日志资源来源ID长度必须在{min}和{max}之间 +operation_log.id.not_blank=操作日志ID不能为空 +operation_log.project_id.not_blank=操作日志项目ID不能为空 +operation_log.project_id.length_range=操作日志项目ID长度必须在{min}和{max}之间 +operation_log.organization_id.not_blank=操作日志组织ID不能为空 +operation_log.organization_id.length_range=操作日志组织ID长度必须在{min}和{max}之间 +operation_log_resource.id.not_blank=操作日志资源ID不能为空 +operation_log_resource.operating_log_id.not_blank=操作日志资源操作日志ID不能为空 +operation_log_resource.operating_log_id.length_range=操作日志资源操作日志ID长度必须在{min}和{max}之间 +operation_log_resource.source_id.not_blank=操作日志资源来源ID不能为空 +operation_log_resource.source_id.length_range=操作日志资源来源ID长度必须在{min}和{max}之间 plugin.id.not_blank=插件主键不能为空 plugin.plugin_id.not_blank=插件ID不能为空 plugin.plugin_id.length_range=插件ID长度必须在{min}和{max}之间 diff --git a/backend/framework/sdk/src/main/resources/i18n/system_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/system_zh_TW.properties index 2786f6cf6d..57ae3c9841 100644 --- a/backend/framework/sdk/src/main/resources/i18n/system_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/system_zh_TW.properties @@ -44,14 +44,16 @@ notification.resource_name.length_range=消息通知資源名稱長度必須在{ novice_statistics.id.not_blank=新手村ID不能為空 novice_statistics.guide_step.not_blank=新手村步驟不能為空 novice_statistics.guide_step.length_range=新手村步驟長度必須在{min}和{max}之間 -operating_log.id.not_blank=操作日誌ID不能為空 -operating_log.project_id.not_blank=操作日誌項目ID不能為空 -operating_log.project_id.length_range=操作日誌項目ID長度必須在{min}和{max}之間 -operating_log_resource.id.not_blank=操作日誌資源ID不能為空 -operating_log_resource.operating_log_id.not_blank=操作日誌資源操作日誌ID不能為空 -operating_log_resource.operating_log_id.length_range=操作日誌資源操作日誌ID長度必須在{min}和{max}之間 -operating_log_resource.source_id.not_blank=操作日誌資源來源ID不能為空 -operating_log_resource.source_id.length_range=操作日誌資源來源ID長度必須在{min}和{max}之間 +operation_log.id.not_blank=操作日誌ID不能為空 +operation_log.project_id.not_blank=操作日誌項目ID不能為空 +operation_log.project_id.length_range=操作日誌項目ID長度必須在{min}和{max}之間 +operation_log.organization_id.not_blank=操作日誌組織ID不能為空 +operation_log.organization_id.length_range=操作日誌組織ID長度必須在{min}和{max}之間 +operation_log_resource.id.not_blank=操作日誌資源ID不能為空 +operation_log_resource.operating_log_id.not_blank=操作日誌資源操作日誌ID不能為空 +operation_log_resource.operating_log_id.length_range=操作日誌資源操作日誌ID長度必須在{min}和{max}之間 +operation_log_resource.source_id.not_blank=操作日誌資源來源ID不能為空 +operation_log_resource.source_id.length_range=操作日誌資源來源ID長度必須在{min}和{max}之間 plugin.id.not_blank=插件主鍵不能為空 plugin.plugin_id.not_blank=插件ID不能為空 plugin.plugin_id.length_range=插件ID長度必須在{min}和{max}之間 diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiDefinitionLogService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiDefinitionLogService.java index 61379ceae2..7c1d03bfc8 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiDefinitionLogService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiDefinitionLogService.java @@ -30,6 +30,7 @@ public class ApiDefinitionLogService { public LogDTO addLog(ApiDefinitionDTO request) { LogDTO dto = new LogDTO( request.getProjectId(), + "", request.getId(), request.getCreateUser(), OperationLogType.ADD.name(), @@ -53,6 +54,7 @@ public class ApiDefinitionLogService { LogDTO dto = new LogDTO( request.getProjectId(), + "", request.getId(), request.getCreateUser(), OperationLogType.UPDATE.name(), @@ -78,6 +80,7 @@ public class ApiDefinitionLogService { ApiDefinition apiDefinition = apiDefinitionMapper.selectByPrimaryKey(request.getId()); LogDTO dto = new LogDTO( request.getProjectId(), + "", request.getId(), request.getCreateUser(), OperationLogType.DELETE.name(), @@ -106,6 +109,7 @@ public class ApiDefinitionLogService { apiDefinitions.forEach(item -> { LogDTO dto = new LogDTO( item.getProjectId(), + "", item.getId(), item.getCreateUser(), OperationLogType.DELETE.name(), @@ -132,6 +136,7 @@ public class ApiDefinitionLogService { apiDefinitions.forEach(item -> { LogDTO dto = new LogDTO( item.getProjectId(), + "", item.getId(), item.getCreateUser(), OperationLogType.UPDATE.name(), diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java new file mode 100644 index 0000000000..6f04821ed2 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java @@ -0,0 +1,67 @@ +package io.metersphere.system.controller; + + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import io.metersphere.sdk.constants.PermissionConstants; + +import io.metersphere.sdk.log.service.OperationLogService; +import io.metersphere.sdk.log.vo.OperationLogRequest; +import io.metersphere.sdk.log.vo.OperationLogResponse; +import io.metersphere.sdk.util.PageUtils; +import io.metersphere.sdk.util.Pager; +import io.metersphere.system.dto.OrganizationProjectOptionsDto; +import io.metersphere.system.dto.response.OrganizationProjectOptionsResponse; +import io.metersphere.system.service.OrganizationService; +import io.metersphere.system.service.SystemProjectService; +import io.swagger.v3.oas.annotations.Operation; +import jakarta.annotation.Resource; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/operating/log") +public class OperationLogController { + + @Resource + private OrganizationService organizationService; + + @Resource + private SystemProjectService systemProjectService; + + @Resource + private OperationLogService operationLogService; + + + @GetMapping("/get/options") + @Operation(summary = "获取组织/项目级联下拉框选项") + @RequiresPermissions(value = {PermissionConstants.SYSTEM_OPERATING_LOG_READ, PermissionConstants.ORGANIZATION_OPERATING_LOG_READ}, logical = Logical.OR) + public OrganizationProjectOptionsResponse getOptions() { + + //获取全部组织 + List organizationList = organizationService.getOrganizationOptions(); + //获取全部项目 + List projectList = systemProjectService.getprojectOptions(); + + OrganizationProjectOptionsResponse optionsResponse = new OrganizationProjectOptionsResponse(); + optionsResponse.setOrganizationList(organizationList); + optionsResponse.setProjectList(projectList); + + return optionsResponse; + } + + + @PostMapping("/list") + @Operation(summary = "操作日志列表查询") + @RequiresPermissions(PermissionConstants.SYSTEM_OPERATING_LOG_READ) + public Pager> list(@Validated @RequestBody OperationLogRequest request) { + Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), + StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc"); + return PageUtils.setPageInfo(page, operationLogService.list(request)); + } +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserController.java index 4822c5ec8d..1974e8e5b4 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserController.java @@ -12,6 +12,7 @@ import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; import io.metersphere.sdk.util.SessionUtils; +import io.metersphere.system.domain.User; import io.metersphere.system.dto.UserBatchCreateDTO; import io.metersphere.system.dto.UserRoleOption; import io.metersphere.system.dto.request.UserChangeEnableRequest; @@ -23,8 +24,10 @@ import io.metersphere.system.service.GlobalUserRoleService; import io.metersphere.system.service.UserService; import io.metersphere.validation.groups.Created; import io.metersphere.validation.groups.Updated; +import io.swagger.v3.oas.annotations.Operation; import jakarta.annotation.Resource; import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -92,4 +95,11 @@ public class UserController { public UserBatchProcessResponse deleteUser(@Validated @RequestBody UserChangeEnableRequest userBatchProcessRequest) { return userService.deleteUser(userBatchProcessRequest.getUserIdList()); } + + @GetMapping("/list") + @Operation(summary = "系统/组织日志页面,获取用户列表") + @RequiresPermissions(value = {PermissionConstants.SYSTEM_OPERATING_LOG_READ, PermissionConstants.ORGANIZATION_OPERATING_LOG_READ}, logical = Logical.OR) + public List getUserList() { + return userService.getUserList(); + } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/OrganizationProjectOptionsDto.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/OrganizationProjectOptionsDto.java new file mode 100644 index 0000000000..3e11638c28 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/OrganizationProjectOptionsDto.java @@ -0,0 +1,10 @@ +package io.metersphere.system.dto; + + +import lombok.Data; + +@Data +public class OrganizationProjectOptionsDto { + String id; + String name; +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/response/OrganizationProjectOptionsResponse.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/response/OrganizationProjectOptionsResponse.java new file mode 100644 index 0000000000..a5d27187c7 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/response/OrganizationProjectOptionsResponse.java @@ -0,0 +1,13 @@ +package io.metersphere.system.dto.response; + +import io.metersphere.system.dto.OrganizationProjectOptionsDto; +import lombok.Data; + +import java.util.List; + +@Data +public class OrganizationProjectOptionsResponse { + + List organizationList; + List projectList; +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java index 7a47af1233..d4c2ef10f9 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java @@ -2,6 +2,7 @@ package io.metersphere.system.mapper; import io.metersphere.system.domain.User; import io.metersphere.system.dto.OrganizationDTO; +import io.metersphere.system.dto.OrganizationProjectOptionsDto; import io.metersphere.system.dto.UserExtend; import io.metersphere.system.request.OrganizationDeleteRequest; import io.metersphere.system.request.OrganizationRequest; @@ -59,4 +60,10 @@ public interface ExtOrganizationMapper { * @return 组织管理员数据 */ List getOrgAdminList(String orgId); + + /** + * 获取组织列表(下拉框) + * @return 组织列表数据 + */ + List selectOrganizationOptions(); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml index 925d8e2278..c1a6448a23 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml @@ -90,4 +90,8 @@ join `user` u on urr.user_id = u.id where urr.role_id = 'org_admin'and urr.source_id = #{orgId} + + \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.java index 95143a9126..01797e62da 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.java @@ -2,6 +2,7 @@ package io.metersphere.system.mapper; import io.metersphere.sdk.dto.ProjectDTO; import io.metersphere.system.domain.User; +import io.metersphere.system.dto.OrganizationProjectOptionsDto; import io.metersphere.system.dto.UserExtend; import io.metersphere.system.request.ProjectMemberRequest; import io.metersphere.system.request.ProjectRequest; @@ -16,4 +17,6 @@ public interface ExtSystemProjectMapper { List getProjectList(@Param("request") ProjectRequest request); List getProjectAdminList(String projectId); + + List selectProjectOptions(); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.xml index 841de429e4..93c9333e4c 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.xml @@ -59,4 +59,9 @@ and user_role_relation.role_id = 'project_admin' + + + \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/AuthSourceLogService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/AuthSourceLogService.java index 063a33c9c9..f349c15896 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/AuthSourceLogService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/AuthSourceLogService.java @@ -30,6 +30,7 @@ public class AuthSourceLogService { public LogDTO addLog(AuthSourceRequest request) { LogDTO dto = new LogDTO( "system", + "", request.getId(), null, OperationLogType.ADD.name(), @@ -53,6 +54,7 @@ public class AuthSourceLogService { if (authSource != null) { LogDTO dto = new LogDTO( "system", + "", request.getId(), null, OperationLogType.UPDATE.name(), @@ -72,6 +74,7 @@ public class AuthSourceLogService { if (authSource != null) { LogDTO dto = new LogDTO( "system", + "", id, null, OperationLogType.UPDATE.name(), @@ -99,6 +102,7 @@ public class AuthSourceLogService { } LogDTO dto = new LogDTO( "system", + "", authSource.getId(), null, OperationLogType.DELETE.name(), diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/GlobalUserRoleLogService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/GlobalUserRoleLogService.java index 1caece5e11..de91b082dc 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/GlobalUserRoleLogService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/GlobalUserRoleLogService.java @@ -36,6 +36,7 @@ public class GlobalUserRoleLogService extends BaseUserRoleService { public LogDTO addLog(UserRoleUpdateRequest request) { LogDTO dto = new LogDTO( "system", + "", request.getId(), null, OperationLogType.ADD.name(), @@ -57,6 +58,7 @@ public class GlobalUserRoleLogService extends BaseUserRoleService { if (userRole != null) { LogDTO dto = new LogDTO( "system", + "", userRole.getId(), userRole.getCreateUser(), OperationLogType.UPDATE.name(), @@ -76,6 +78,7 @@ public class GlobalUserRoleLogService extends BaseUserRoleService { if (userRole != null) { LogDTO dto = new LogDTO( "system", + "", request.getUserRoleId(), userRole.getCreateUser(), OperationLogType.UPDATE.name(), @@ -104,6 +107,7 @@ public class GlobalUserRoleLogService extends BaseUserRoleService { } LogDTO dto = new LogDTO( "system", + "", userRole.getId(), null, OperationLogType.DELETE.name(), diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/GlobalUserRoleRelationLogService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/GlobalUserRoleRelationLogService.java index 5a31d0ba85..a0ea08e483 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/GlobalUserRoleRelationLogService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/GlobalUserRoleRelationLogService.java @@ -33,6 +33,7 @@ public class GlobalUserRoleRelationLogService extends BaseUserRoleRelationServic public LogDTO addLog(GlobalUserRoleRelationUpdateRequest request) { LogDTO dto = new LogDTO( "system", + "", null, null, OperationLogType.ADD.name(), @@ -56,6 +57,7 @@ public class GlobalUserRoleRelationLogService extends BaseUserRoleRelationServic if (userRoleRelation != null) { LogDTO dto = new LogDTO( "system", + "", id, userRoleRelation.getCreateUser(), OperationLogType.DELETE.name(), diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java index a0e516853e..3659f71420 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java @@ -6,6 +6,7 @@ import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.*; import io.metersphere.system.dto.OrganizationDTO; +import io.metersphere.system.dto.OrganizationProjectOptionsDto; import io.metersphere.system.dto.UserExtend; import io.metersphere.system.mapper.ExtOrganizationMapper; import io.metersphere.system.mapper.OrganizationMapper; @@ -107,4 +108,9 @@ public class OrganizationService{ }); return organizationDTOS; } + + + public List getOrganizationOptions() { + return extOrganizationMapper.selectOrganizationOptions(); + } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectLogService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectLogService.java index a5f31b92a9..b5de50fd77 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectLogService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectLogService.java @@ -30,6 +30,7 @@ public class SystemProjectLogService { public LogDTO addLog(AddProjectRequest project) { LogDTO dto = new LogDTO( "system", + "", null, null, OperationLogType.ADD.name(), @@ -51,6 +52,7 @@ public class SystemProjectLogService { if (project != null) { LogDTO dto = new LogDTO( "system", + "", project.getId(), project.getCreateUser(), OperationLogType.UPDATE.name(), @@ -70,6 +72,7 @@ public class SystemProjectLogService { if (project != null) { LogDTO dto = new LogDTO( "system", + "", project.getId(), project.getCreateUser(), OperationLogType.UPDATE.name(), @@ -96,6 +99,7 @@ public class SystemProjectLogService { if (project != null) { LogDTO dto = new LogDTO( "system", + "", id, project.getCreateUser(), OperationLogType.DELETE.name(), diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java index 59263f8365..f59e1b1d53 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java @@ -12,6 +12,7 @@ import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.User; import io.metersphere.system.domain.UserRoleRelation; import io.metersphere.system.domain.UserRoleRelationExample; +import io.metersphere.system.dto.OrganizationProjectOptionsDto; import io.metersphere.system.dto.UserExtend; import io.metersphere.system.mapper.ExtSystemProjectMapper; import io.metersphere.system.mapper.UserMapper; @@ -225,4 +226,8 @@ public class SystemProjectService { userGroupExample.createCriteria().andSourceIdEqualTo(projectId); userRoleRelationMapper.deleteByExample(userGroupExample); } + + public List getprojectOptions() { + return extSystemProjectMapper.selectProjectOptions(); + } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserRoleRelationService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserRoleRelationService.java index e19597133e..65903195f8 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserRoleRelationService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserRoleRelationService.java @@ -62,6 +62,7 @@ public class UserRoleRelationService { LogDTO log = new LogDTO(); log.setId(UUID.randomUUID().toString()); log.setProjectId("system"); + log.setOrganizationId(""); log.setType(operationType); log.setCreateUser(operator); log.setModule(OperationLogModule.SYSTEM_USER); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java index 72c531cc78..97e8056e3c 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java @@ -65,6 +65,7 @@ public class UserService { log.setId(UUID.randomUUID().toString()); log.setCreateUser(user.getCreateUser()); log.setProjectId("system"); + log.setOrganizationId(""); log.setType(OperationLogType.ADD.name()); log.setModule(OperationLogModule.SYSTEM_USER); log.setMethod("addUser"); @@ -290,6 +291,7 @@ public class UserService { if (user != null) { LogDTO dto = new LogDTO( "system", + "", request.getId(), null, OperationLogType.UPDATE.name(), @@ -312,6 +314,7 @@ public class UserService { LogDTO dto = new LogDTO( "system", + "", user.getId(), user.getCreateUser(), OperationLogType.DELETE.name(), @@ -326,4 +329,10 @@ public class UserService { }); return logDTOList; } + + public List getUserList() { + UserExample example = new UserExample(); + example.setOrderByClause("update_time desc"); + return userMapper.selectByExample(example); + } } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OperationLogControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OperationLogControllerTests.java new file mode 100644 index 0000000000..4148a8a636 --- /dev/null +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OperationLogControllerTests.java @@ -0,0 +1,112 @@ +package io.metersphere.system.controller; + +import base.BaseTest; +import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.sdk.log.vo.OperationLogRequest; +import io.metersphere.system.controller.param.OperationLogRequestDefinition; +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; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.jdbc.SqlConfig; + +import java.util.Arrays; + +@SpringBootTest +@AutoConfigureMockMvc +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +public class OperationLogControllerTests extends BaseTest { + + public static final String OPERATION_LOG_LIST = "/operating/log/list"; + + public static final String OPTIONS_LIST = "/operating/log/get/options"; + + + public static final String USER_LIST = "/system/user/list"; + + public static final String SYSTEM = "system"; + public static final String ORGANIZATION = "organization"; + + + /** + * 系统级别 查询 用例 + * @throws Exception + */ + @Test + @Order(1) + @Sql(scripts = {"/dml/init_operation_log_test.sql"}, + config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED), + executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) + public void testSystemOperationLogList() throws Exception { + //系统级别 全部 + OperationLogRequest request = buildParam(SYSTEM); + this.requestPostWithOkAndReturn(OPERATION_LOG_LIST, request); + + // @@异常参数校验 + updatedGroupParamValidateTest(OperationLogRequestDefinition.class, OPERATION_LOG_LIST); + // @@校验权限 + requestPostPermissionTest(PermissionConstants.SYSTEM_OPERATING_LOG_READ, OPERATION_LOG_LIST, request); + + } + + + /** + * 组织级别 查询 用例 + * @throws Exception + */ + @Test + @Order(3) + public void testOrganizationOperationLogList() throws Exception { + OperationLogRequest request = buildParam(ORGANIZATION); + //组织级别 全部 + this.requestPostWithOkAndReturn(OPERATION_LOG_LIST, request); + + //组织级别 指定组织查询 + request.setOrganizationIds(Arrays.asList("organization_id_001","organization_id_002")); + this.requestPostWithOkAndReturn(OPERATION_LOG_LIST, request); + + // @@异常参数校验 + updatedGroupParamValidateTest(OperationLogRequestDefinition.class, OPERATION_LOG_LIST); + // @@校验权限 + requestPostPermissionTest(PermissionConstants.SYSTEM_OPERATING_LOG_READ, OPERATION_LOG_LIST, request); + } + + + //TODO 项目级别 查询 用例 + + @Test + @Order(2) + public void testGetOptions() throws Exception { + this.requestGetWithOkAndReturn(OPTIONS_LIST); + + // @@校验权限 + requestGetPermissionTest(PermissionConstants.SYSTEM_OPERATING_LOG_READ, OPTIONS_LIST); + } + + @Test + @Order(3) + public void testUserList() throws Exception { + this.requestGetWithOkAndReturn(USER_LIST); + + // @@校验权限 + requestGetPermissionTest(PermissionConstants.SYSTEM_OPERATING_LOG_READ, OPTIONS_LIST); + } + + //TODO 异常用例补充 + + + private OperationLogRequest buildParam(String level) { + OperationLogRequest request = new OperationLogRequest(); + request.setCurrent(1); + request.setPageSize(10); + request.setStartTime(1689131059000l); + request.setEndTime(1689149059000l); + request.setLevel(level); + return request; + } + + +} diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationUserRoleControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationUserRoleControllerTests.java index 6826723eaa..c6d0be56f5 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationUserRoleControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationUserRoleControllerTests.java @@ -15,6 +15,7 @@ import io.metersphere.system.request.OrganizationUserRoleMemberEditRequest; import io.metersphere.system.request.OrganizationUserRoleMemberRequest; import io.metersphere.utils.JsonUtils; import jakarta.annotation.Resource; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.*; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -284,9 +285,12 @@ public class OrganizationUserRoleControllerTests extends BaseTest { // 返回的数据量不超过规定要返回的数据量相同 Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= request.getPageSize()); // 返回值中取出第一条数据, 并判断是否包含关键字default - User user = JSON.parseArray(JSON.toJSONString(pageData.getList()), User.class).get(0); - Assertions.assertTrue(StringUtils.contains(user.getName(), request.getUserName()) - || StringUtils.contains(user.getId(), request.getUserName())); + List userList = JSON.parseArray(JSON.toJSONString(pageData.getList()), User.class); + if(CollectionUtils.isNotEmpty(userList)) { + User user = userList.get(0); + Assertions.assertTrue(StringUtils.contains(user.getName(), request.getUserName()) + || StringUtils.contains(user.getId(), request.getUserName())); + } } @Test @@ -341,7 +345,7 @@ public class OrganizationUserRoleControllerTests extends BaseTest { OrganizationUserRoleMemberEditRequest request = new OrganizationUserRoleMemberEditRequest(); request.setOrganizationId("default-organization-2"); request.setUserRoleId("default-org-role-id-3"); - request.setUserId("default-admin"); + request.setUserId("admin"); this.requestPost(ORGANIZATION_USER_ROLE_REMOVE_MEMBER, request, status().isOk()); } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/param/OperationLogRequestDefinition.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/param/OperationLogRequestDefinition.java new file mode 100644 index 0000000000..3553d6de6c --- /dev/null +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/param/OperationLogRequestDefinition.java @@ -0,0 +1,35 @@ +package io.metersphere.system.controller.param; + +import jakarta.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +public class OperationLogRequestDefinition { + + + private String operUser; + + + @NotNull(message = "{start_time_is_null}") + private Long startTime; + @NotNull(message = "{end_time_is_null}") + private Long endTime; + + private List projectIds; + + private List organizationIds; + + private String type; + + + private String module; + + private String content; + + private String level; + +} diff --git a/backend/services/system-setting/src/test/resources/dml/init_operation_log_test.sql b/backend/services/system-setting/src/test/resources/dml/init_operation_log_test.sql new file mode 100644 index 0000000000..9bf851339e --- /dev/null +++ b/backend/services/system-setting/src/test/resources/dml/init_operation_log_test.sql @@ -0,0 +1,11 @@ +-- 模拟数据 +INSERT INTO organization (id, num, name, description, create_user, update_user, create_time, update_time) VALUES ('organization_id_001', 100010, '测试日志组织', '测试日志的组织', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000); + +INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES ('project_id_001', 100010, 'organization_id_001', '测试日志项目', '测试日志的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000); + + +-- 初始化日志记录 +INSERT INTO operation_log(`id`, `project_id`, `organization_id`, `create_time`, `create_user`, `source_id`, `method`, `type`, `module`, `content`, `path`) VALUES (uuid(), 'system', '', 1689141859000, 'admin', '1', 'post', 'add', 'SYSTEM_PARAMETER_SETTING', '认证配置', '/system/authsource/add'); +INSERT INTO operation_log(`id`, `project_id`, `organization_id`, `create_time`, `create_user`, `source_id`, `method`, `type`, `module`, `content`, `path`) VALUES (uuid(), '', 'organization_id_001', 1689141859000, 'admin', '1', 'post', 'add', 'SYSTEM_PARAMETER_SETTING', '认证配置', '/system/authsource/add'); +INSERT INTO operation_log(`id`, `project_id`, `organization_id`, `create_time`, `create_user`, `source_id`, `method`, `type`, `module`, `content`, `path`) VALUES (uuid(), 'project_id_001', 'organization_id_001', 1689141859000, 'admin', '1', 'post', 'add', 'SYSTEM_PARAMETER_SETTING', '认证配置', '/system/authsource/add'); +