fix: add Log creator

This commit is contained in:
guoyuqi 2023-08-07 17:53:09 +08:00 committed by fit2-zhao
parent 05ede65b23
commit d41eef401f
1 changed files with 38 additions and 14 deletions

View File

@ -325,7 +325,16 @@ public class OrganizationService {
userRoleRelationMapper.insert(userRoleRelation); userRoleRelationMapper.insert(userRoleRelation);
//add Log //add Log
String path = add ? "/organization/add-member" : "/organization/role/update-member"; String path = add ? "/organization/add-member" : "/organization/role/update-member";
setLog(organizationId, OperationLogConstants.ORGANIZATION, path, OperationLogModule.ORGANIZATION_MEMBER, "成员", logDTOList, memberId, userRoleRelation, add); String type = add ? OperationLogType.ADD.name() : OperationLogType.UPDATE.name();
LogDTO dto = new LogDTO(
OperationLogConstants.ORGANIZATION,
organizationId,
memberId,
createUserId,
type,
OperationLogModule.ORGANIZATION_MEMBER,
"成员");
setLog(dto, path, logDTOList, userRoleRelation);
} }
} }
}); });
@ -336,16 +345,7 @@ public class OrganizationService {
operationLogService.batchAdd(logDTOList); operationLogService.batchAdd(logDTOList);
} }
private static void setLog(String organizationId, String projectId, String path, String module, String content, List<LogDTO> logDTOList, String memberId, Object originalValue, boolean add) { private static void setLog(LogDTO dto, String path, List<LogDTO> logDTOList, Object originalValue) {
String type = add ? OperationLogType.ADD.name() : OperationLogType.UPDATE.name();
LogDTO dto = new LogDTO(
projectId,
organizationId,
memberId,
null,
type,
module,
content);
dto.setPath(path); dto.setPath(path);
dto.setMethod(HttpMethodConstants.POST.name()); dto.setMethod(HttpMethodConstants.POST.name());
dto.setOriginalValue(JSON.toJSONBytes(originalValue)); dto.setOriginalValue(JSON.toJSONBytes(originalValue));
@ -386,7 +386,15 @@ public class OrganizationService {
UserRoleRelation userRoleRelation = buildUserRoleRelation(userId, memberId, projectId, InternalUserRole.PROJECT_MEMBER.getValue()); UserRoleRelation userRoleRelation = buildUserRoleRelation(userId, memberId, projectId, InternalUserRole.PROJECT_MEMBER.getValue());
userRoleRelationMapper.insert(userRoleRelation); userRoleRelationMapper.insert(userRoleRelation);
//add Log //add Log
setLog(requestOrganizationId, projectId, "/organization/project/add-member", OperationLogModule.PROJECT_PROJECT_MEMBER, "", logDTOList, memberId, userRoleRelation, true); LogDTO dto = new LogDTO(
projectId,
requestOrganizationId,
memberId,
userId,
OperationLogType.ADD.name(),
OperationLogModule.PROJECT_PROJECT_MEMBER,
"");
setLog(dto, "/organization/project/add-member", logDTOList, userRoleRelation);
} }
}); });
}); });
@ -509,7 +517,15 @@ public class OrganizationService {
userRoleRelationMapper.insert(userRoleRelation); userRoleRelationMapper.insert(userRoleRelation);
//add Log //add Log
String path = "/organization/update-member"; String path = "/organization/update-member";
setLog(organizationId, OperationLogConstants.ORGANIZATION, path, OperationLogModule.ORGANIZATION_MEMBER, "成员", logDTOList, memberId, userRoleRelation, false); LogDTO dto = new LogDTO(
projectId,
organizationId,
memberId,
createUserId,
OperationLogType.UPDATE.name(),
OperationLogModule.ORGANIZATION_MEMBER,
"成员");
setLog(dto, path, logDTOList, userRoleRelation);
}); });
} }
@ -538,7 +554,15 @@ public class OrganizationService {
userRoleRelationMapper.insert(userRoleRelation); userRoleRelationMapper.insert(userRoleRelation);
//add Log //add Log
String path = "/organization/update-member"; String path = "/organization/update-member";
setLog(organizationId, OperationLogConstants.ORGANIZATION, path, OperationLogModule.ORGANIZATION_MEMBER, "成员", logDTOList, memberId, userRoleRelation, false); LogDTO dto = new LogDTO(
OperationLogConstants.ORGANIZATION,
organizationId,
memberId,
createUserId,
OperationLogType.UPDATE.name(),
OperationLogModule.ORGANIZATION_MEMBER,
"成员");
setLog(dto, path, logDTOList, userRoleRelation);
}); });
} }