From e5fd89049e1a8d2d5d8b5fd082dc4414a8933cdf Mon Sep 17 00:00:00 2001 From: kangsunlee Date: Tue, 29 Jul 2025 16:05:50 +0900 Subject: [PATCH] =?UTF-8?q?[README]=20Audi=20=EA=B3=B5=ED=86=B5=ED=95=84?= =?UTF-8?q?=EB=93=9C=20=EC=9E=90=EB=8F=99=EC=A3=BC=EC=9E=85=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a09b125..b8039a97 100644 --- a/README.md +++ b/README.md @@ -162,15 +162,38 @@ fileUrlPortIn.getAttachment(type, id); * AOP 기반 자동 주입 방식으로 생성/수정/삭제 시 필드 반복을 최소화합니다. * 공통 필드: `createdAt`, `createdBy`, `updatedAt`, `updatedBy`, `deletedAt`, `deletedBy`, `isDeleted` + +| 어노테이션 | 주입 필드 | +| ---------------- | ------------------------------------------ | +| `@CreateCommand` | createdAt, createdBy, updatedAt, updatedBy | +| `@UpdateCommand` | updatedAt, updatedBy | +| `@DeleteCommand` | deletedAt, deletedBy | + +### ✅ 기본 사용법 +모든 Command는 AuditCommand를 상속하고, Service/DAO 메서드에 어노테이션만 붙이면 자동으로 필드에 값이 주입됩니다. ```java @UpdateCommand public void update(UpdateCmd cmd) { - mapper.update(cmd); + mapper.update(cmd); // updatedAt, updatedBy 자동 주입 +} +``` +```java +public class UpdateCmd extends AuditCommand { + private Long seq; } ``` -복수 등록 또는 복합 로직은 `AuditUtil.create()` 방식 사용 +### ✅ 복합적인 CRUD 처리 시 +하나의 로직 안에서 insert, update, delete 등 여러 DB 작업이 함께 처리되는 경우, `AuditUtil`의 유틸 메서드를 사용합니다. +```java +// 관리자 등록 +mapper.insertAdmin(AuditUtil.create(cmd)); +// 관리자 역할 매핑 (다건) +mapper.insertAdminHasRoles( + AuditUtil.create(new SaveAdminHasRoleParam(cmd.getSeq(), cmd.getRoleIds())) +); +``` --- ## 🔁 XML 공통 필드 include