fix(项目设置): 项目全局用户组添加成员日志报错问题

--bug=1034838 --user=宋昌昌 【系统设置】系统设置模块日志1分钟出现一次Error https://www.tapd.cn/55049933/s/1457536
This commit is contained in:
song-cc-rock 2024-01-31 20:18:33 +08:00 committed by 刘瑞斌
parent 2abb928ec3
commit a7bc73fc4a
2 changed files with 28 additions and 11 deletions

View File

@ -5,13 +5,13 @@ import io.metersphere.project.mapper.ProjectMapper;
import io.metersphere.project.request.ProjectUserRoleEditRequest;
import io.metersphere.project.request.ProjectUserRoleMemberEditRequest;
import io.metersphere.sdk.constants.OperationLogConstants;
import io.metersphere.system.log.dto.LogDTO;
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.domain.UserRole;
import io.metersphere.system.domain.UserRoleExample;
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.log.dto.LogDTO;
import io.metersphere.system.mapper.UserRoleMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
@ -113,7 +113,16 @@ public class ProjectUserRoleLogService {
* @return 日志详情
*/
public LogDTO editMemberLog(ProjectUserRoleMemberEditRequest request) {
LogDTO dto = getLog(request.getUserRoleId());
Project project = getProject(request.getProjectId());
UserRole userRole = userRoleMapper.selectByPrimaryKey(request.getUserRoleId());
LogDTO dto = new LogDTO(
project.getId(),
project.getOrganizationId(),
OperationLogConstants.SYSTEM,
null,
null,
OperationLogModule.PROJECT_MANAGEMENT_PERMISSION_USER_ROLE,
userRole.getName());
dto.setType(OperationLogType.UPDATE.name());
dto.setModifiedValue(JSON.toJSONBytes(request));
return dto;

View File

@ -1,16 +1,16 @@
package io.metersphere.system.service;
import io.metersphere.sdk.constants.OperationLogConstants;
import io.metersphere.system.log.dto.LogDTO;
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.domain.UserRole;
import io.metersphere.system.domain.UserRoleExample;
import io.metersphere.system.mapper.UserRoleMapper;
import io.metersphere.system.dto.request.OrganizationUserRoleEditRequest;
import io.metersphere.system.dto.request.OrganizationUserRoleMemberEditRequest;
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.log.dto.LogDTO;
import io.metersphere.system.mapper.UserRoleMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -106,7 +106,15 @@ public class OrganizationUserRoleLogService {
* @return 日志详情
*/
public LogDTO editMemberLog(OrganizationUserRoleMemberEditRequest request) {
LogDTO dto = getLog(request.getUserRoleId());
UserRole userRole = userRoleMapper.selectByPrimaryKey(request.getUserRoleId());
LogDTO dto = new LogDTO(
OperationLogConstants.ORGANIZATION,
request.getOrganizationId(),
OperationLogConstants.SYSTEM,
null,
null,
OperationLogModule.SETTING_ORGANIZATION_USER_ROLE,
userRole.getName());
dto.setType(OperationLogType.UPDATE.name());
dto.setModifiedValue(JSON.toJSONBytes(request));
return dto;