feat: Integrate audit logging for various operations
- Added audit logging functionality across multiple controllers, including menu, user, department, flow, screen, and table management. - Implemented logging for create, update, and delete actions, capturing relevant details such as company code, user information, and changes made. - Enhanced the category tree service with a new endpoint to check if category values are in use, improving data integrity checks. - Updated routes to include new functionalities and ensure proper logging for batch operations and individual record changes. - This integration improves traceability and accountability for data modifications within the application.
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
isCompanyAdmin,
|
||||
canAccessCompanyData,
|
||||
} from "../utils/permissionUtils";
|
||||
import { auditLogService } from "../services/auditLogService";
|
||||
|
||||
/**
|
||||
* 권한 그룹 목록 조회
|
||||
@@ -179,6 +180,20 @@ export const createRoleGroup = async (
|
||||
data: roleGroup,
|
||||
};
|
||||
|
||||
auditLogService.log({
|
||||
companyCode: companyCode || req.user?.companyCode || "",
|
||||
userId: req.user?.userId || "",
|
||||
userName: req.user?.userName || "",
|
||||
action: "CREATE",
|
||||
resourceType: "ROLE",
|
||||
resourceId: String(roleGroup?.objid || ""),
|
||||
resourceName: authName,
|
||||
summary: `권한 그룹 "${authName}" 생성`,
|
||||
changes: { after: { authName, authCode, companyCode } },
|
||||
ipAddress: (req as any).ip,
|
||||
requestPath: req.originalUrl,
|
||||
});
|
||||
|
||||
res.status(201).json(response);
|
||||
} catch (error) {
|
||||
logger.error("권한 그룹 생성 실패", { error });
|
||||
@@ -243,6 +258,23 @@ export const updateRoleGroup = async (
|
||||
data: roleGroup,
|
||||
};
|
||||
|
||||
auditLogService.log({
|
||||
companyCode: req.user?.companyCode || "",
|
||||
userId: req.user?.userId || "",
|
||||
userName: req.user?.userName || "",
|
||||
action: "UPDATE",
|
||||
resourceType: "ROLE",
|
||||
resourceId: String(objid),
|
||||
resourceName: authName,
|
||||
summary: `권한 그룹 "${authName}" 수정`,
|
||||
changes: {
|
||||
before: { authName: existingRoleGroup.authName, authCode: existingRoleGroup.authCode, status: existingRoleGroup.status },
|
||||
after: { authName, authCode, status },
|
||||
},
|
||||
ipAddress: (req as any).ip,
|
||||
requestPath: req.originalUrl,
|
||||
});
|
||||
|
||||
res.status(200).json(response);
|
||||
} catch (error) {
|
||||
logger.error("권한 그룹 수정 실패", { error });
|
||||
@@ -302,6 +334,19 @@ export const deleteRoleGroup = async (
|
||||
data: null,
|
||||
};
|
||||
|
||||
auditLogService.log({
|
||||
companyCode: existingRoleGroup.companyCode || req.user?.companyCode || "",
|
||||
userId: req.user?.userId || "",
|
||||
userName: req.user?.userName || "",
|
||||
action: "DELETE",
|
||||
resourceType: "ROLE",
|
||||
resourceId: String(objid),
|
||||
resourceName: existingRoleGroup.authName,
|
||||
summary: `권한 그룹 "${existingRoleGroup.authName}" 삭제`,
|
||||
ipAddress: (req as any).ip,
|
||||
requestPath: req.originalUrl,
|
||||
});
|
||||
|
||||
res.status(200).json(response);
|
||||
} catch (error) {
|
||||
logger.error("권한 그룹 삭제 실패", { error });
|
||||
|
||||
Reference in New Issue
Block a user