From a283dec6a2c75eff693e04a8037a5d9cfae5c78f Mon Sep 17 00:00:00 2001 From: Jianguo-Genius Date: Wed, 17 Jul 2024 14:23:45 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E9=82=AE=E7=AE=B1=E9=82=80=E8=AF=B7=E7=9A=84=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=93=8D=E4=BD=9C=E6=9D=A5=E6=BA=90=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E5=88=86=E9=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/i18n/project.properties | 2 +- .../resources/i18n/project_en_US.properties | 2 +- .../resources/i18n/project_zh_CN.properties | 2 +- .../resources/i18n/project_zh_TW.properties | 2 +- .../schedule/BaseScheduleConfigRequest.java | 1 + .../system/service/SimpleUserService.java | 12 +++++++++++- .../system/service/UserLogService.java | 17 +++++++++++++---- 7 files changed, 29 insertions(+), 9 deletions(-) diff --git a/backend/framework/sdk/src/main/resources/i18n/project.properties b/backend/framework/sdk/src/main/resources/i18n/project.properties index 6e77ac78bd..93c0595ba6 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project.properties @@ -122,7 +122,7 @@ ding_app_key_is_null=钉钉的AppKey不能为空 ding_app_secret_is_null=钉钉的AppSecret不能为空 # permission permission.project_user.name=用户 -permission.project_user.invite=邀请 +permission.project_user.invite=邀请用户 permission.project_group.name=用户组 permission.project_environment.name=环境管理 permission.project_file.name=文件管理 diff --git a/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties index a8b221e784..db1a108546 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties @@ -137,7 +137,7 @@ module.name.is.empty=Module parameter is empty module.name.is.error=Module parameter is error # permission permission.project_user.name=User -permission.project_user.invite=Invite +permission.project_user.invite=Invite User permission.project_group.name=User group permission.project_environment.name=Environment management permission.project_file.name=File management diff --git a/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties index 1c3f07f7b8..95c31987e2 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties @@ -137,7 +137,7 @@ ding_app_key_is_null=钉钉的AppKey不能为空 ding_app_secret_is_null=钉钉的AppSecret不能为空 # permission permission.project_user.name=用户 -permission.project_user.invite=邀请 +permission.project_user.invite=邀请用户 permission.project_group.name=用户组 permission.project_environment.name=环境管理 permission.project_file.name=文件管理 diff --git a/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties index bd9d5746d4..2dc4beeb8a 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties @@ -137,7 +137,7 @@ ding_app_key_is_null = 釘釘的AppKey不能為空 ding_app_secret_is_null =釘釘的AppSecret不能為空 # permission permission.project_user.name=用戶 -permission.project_user.invite=邀請 +permission.project_user.invite=邀請用户 permission.project_group.name=用戶組 permission.project_environment.name=環境管理 permission.project_file.name=文件管理 diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/schedule/BaseScheduleConfigRequest.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/schedule/BaseScheduleConfigRequest.java index abba98f478..20cf64bff1 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/schedule/BaseScheduleConfigRequest.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/schedule/BaseScheduleConfigRequest.java @@ -20,6 +20,7 @@ public class BaseScheduleConfigRequest { @Schema(description = "Cron表达式") @NotBlank + @Size(max = 255, message = "{length.too.large}") private String cron; @Schema(description = "运行配置") diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SimpleUserService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SimpleUserService.java index bfb534f1dd..8e11473309 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SimpleUserService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SimpleUserService.java @@ -4,6 +4,7 @@ import com.alibaba.excel.EasyExcelFactory; import io.metersphere.project.domain.Project; import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.sdk.constants.EmailInviteSource; +import io.metersphere.sdk.constants.OperationLogConstants; import io.metersphere.sdk.constants.ParamConstants; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.*; @@ -435,12 +436,18 @@ public class SimpleUserService { if (MapUtils.isNotEmpty(errorMap)) { throw new MSException(SystemResultCode.INVITE_EMAIL_EXIST, JSON.toJSONString(errorMap.keySet())); } + String logProjectId = "", logOrgId = ""; if (StringUtils.equals(inviteSource, EmailInviteSource.SYSTEM.name())) { + logProjectId = OperationLogConstants.SYSTEM; + logOrgId = OperationLogConstants.SYSTEM; //校验角色的合法性 globalUserRoleService.checkRoleIsGlobalAndHaveMember(request.getUserRoleIds(), true); request.setOrganizationId(EmailInviteSource.SYSTEM.name()); request.setProjectId(EmailInviteSource.SYSTEM.name()); } else if (StringUtils.equals(inviteSource, EmailInviteSource.ORGANIZATION.name())) { + logProjectId = OperationLogConstants.ORGANIZATION; + logOrgId = request.getOrganizationId(); + OrganizationService organizationService = CommonBeanFactory.getBean(OrganizationService.class); organizationService.checkOrgExistById(request.getOrganizationId()); organizationService.checkUseRoleExist(request.getUserRoleIds(), request.getOrganizationId()); @@ -452,12 +459,15 @@ public class SimpleUserService { throw new MSException(Translator.get("project_not_exist")); } request.setOrganizationId(project.getOrganizationId()); + + logProjectId = project.getId(); + logOrgId = project.getOrganizationId(); } List inviteList = userInviteService.batchInsert( request.getInviteEmails(), inviteUser.getId(), request.getUserRoleIds(), request.getOrganizationId(), request.getProjectId()); //记录日志 - userLogService.addEmailInviteLog(inviteList, inviteUser.getId()); + userLogService.addEmailInviteLog(inviteList, logProjectId, logOrgId, inviteUser.getId()); this.sendInviteEmail(inviteList, inviteUser.getName()); return new UserInviteResponse(inviteList); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLogService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLogService.java index 933b1682f4..60389b026d 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLogService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLogService.java @@ -294,15 +294,24 @@ public class UserLogService { operationLogService.batchAdd(logs); } - public void addEmailInviteLog(List userInviteList, String inviteUserId) { + public void addEmailInviteLog(List userInviteList, String projectId, String orgId, String inviteUserId) { + String module = null; + if (StringUtils.equals(projectId, OperationLogConstants.SYSTEM)) { + module = OperationLogModule.SETTING_SYSTEM_USER_SINGLE; + } else if (StringUtils.equals(projectId, OperationLogConstants.ORGANIZATION)) { + module = OperationLogModule.SETTING_ORGANIZATION_USER_ROLE; + } else { + module = OperationLogModule.PROJECT_MANAGEMENT_PERMISSION_USER_ROLE; + } User inviteUser = userMapper.selectByPrimaryKey(inviteUserId); List saveLogs = new ArrayList<>(); + String finalModule = module; userInviteList.forEach(userInvite -> { LogDTO log = LogDTOBuilder.builder() - .projectId(OperationLogConstants.SYSTEM) - .module(OperationLogModule.SETTING_SYSTEM_USER_SINGLE) + .projectId(projectId) + .module(finalModule) .createUser(inviteUserId) - .organizationId(OperationLogConstants.SYSTEM) + .organizationId(orgId) .sourceId(inviteUserId) .type(OperationLogType.ADD.name()) .content(inviteUser.getName() + Translator.get("user.invite.email") + ":" + userInvite.getEmail())