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:
kjs
2026-03-04 13:49:08 +09:00
parent f04d224b09
commit b4d5367e2b
26 changed files with 2620 additions and 140 deletions

View File

@@ -6,6 +6,7 @@ import {
} from "../services/commonCodeService";
import { AuthenticatedRequest } from "../types/auth";
import { logger } from "../utils/logger";
import { auditLogService } from "../services/auditLogService";
export class CommonCodeController {
private commonCodeService: CommonCodeService;
@@ -163,6 +164,18 @@ export class CommonCodeController {
Number(menuObjid)
);
auditLogService.log({
companyCode: companyCode || "",
userId: userId || "",
action: "CREATE",
resourceType: "CODE_CATEGORY",
resourceId: category?.categoryCode,
resourceName: category?.categoryName || categoryData.categoryName,
summary: `코드 카테고리 "${category?.categoryName || categoryData.categoryName}" 생성`,
ipAddress: (req as any).ip,
requestPath: req.originalUrl,
});
return res.status(201).json({
success: true,
data: category,
@@ -208,6 +221,18 @@ export class CommonCodeController {
companyCode
);
auditLogService.log({
companyCode: companyCode || "",
userId: userId || "",
action: "UPDATE",
resourceType: "CODE_CATEGORY",
resourceId: categoryCode,
resourceName: category?.categoryName,
summary: `코드 카테고리 "${categoryCode}" 수정`,
ipAddress: (req as any).ip,
requestPath: req.originalUrl,
});
return res.json({
success: true,
data: category,
@@ -245,6 +270,17 @@ export class CommonCodeController {
await this.commonCodeService.deleteCategory(categoryCode, companyCode);
auditLogService.log({
companyCode: companyCode || "",
userId: req.user?.userId || "",
action: "DELETE",
resourceType: "CODE_CATEGORY",
resourceId: categoryCode,
summary: `코드 카테고리 "${categoryCode}" 삭제`,
ipAddress: (req as any).ip,
requestPath: req.originalUrl,
});
return res.json({
success: true,
message: "카테고리 삭제 성공",
@@ -303,6 +339,18 @@ export class CommonCodeController {
effectiveMenuObjid
);
auditLogService.log({
companyCode: companyCode || "",
userId: userId || "",
action: "CREATE",
resourceType: "CODE",
resourceId: codeData.codeValue,
resourceName: codeData.codeName,
summary: `코드 "${codeData.codeName}" (${categoryCode}) 생성`,
ipAddress: (req as any).ip,
requestPath: req.originalUrl,
});
return res.status(201).json({
success: true,
data: code,