From 20a1d47c9925948a4ebbb7fa31d561a61a96416d Mon Sep 17 00:00:00 2001 From: "ella.oh" Date: Tue, 3 Jun 2025 19:42:18 +0900 Subject: [PATCH 1/4] =?UTF-8?q?#62=20feat:=20AOP=20=EA=B8=B0=EB=B0=98=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=20=EA=B2=AC=EC=A0=81=EC=84=9C=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4/=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=20=EC=8B=9C=EA=B0=84=20=EC=B8=A1=EC=A0=95=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/aop/PerformanceLogAspect.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 backend/src/main/java/com/postdm/backend/global/common/aop/PerformanceLogAspect.java diff --git a/backend/src/main/java/com/postdm/backend/global/common/aop/PerformanceLogAspect.java b/backend/src/main/java/com/postdm/backend/global/common/aop/PerformanceLogAspect.java new file mode 100644 index 0000000..571e764 --- /dev/null +++ b/backend/src/main/java/com/postdm/backend/global/common/aop/PerformanceLogAspect.java @@ -0,0 +1,21 @@ +package com.postdm.backend.global.common.aop; + +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; + +@Slf4j +@Aspect +@Component +public class PerformanceLogAspect { + @Around("execution(* com.postdm.backend.domain.estimate..*(..))") + public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable { + long start = System.currentTimeMillis(); + Object result = joinPoint.proceed(); + long end = System.currentTimeMillis(); + log.info("[PERF] " + joinPoint.getSignature() + " took " + (end - start) + "ms"); + return result; + } +} \ No newline at end of file From c743b2aecc6c54059eb05a3b05d184a1dde64ef3 Mon Sep 17 00:00:00 2001 From: "ella.oh" Date: Tue, 3 Jun 2025 19:42:58 +0900 Subject: [PATCH 2/4] =?UTF-8?q?#62=20feat:=20AOP=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/build.gradle b/backend/build.gradle index 5239151..658729f 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -31,6 +31,9 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-web' + // AOP + implementation 'org.springframework.boot:spring-boot-starter-aop' + // Email implementation 'org.springframework.boot:spring-boot-starter-mail' From e26c5409b02fccc4d7ddc60ad6428d88c137f55c Mon Sep 17 00:00:00 2001 From: "ella.oh" Date: Tue, 3 Jun 2025 19:44:10 +0900 Subject: [PATCH 3/4] =?UTF-8?q?#62=20feat:=20=EA=B2=AC=EC=A0=81=EC=84=9C?= =?UTF-8?q?=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EA=B0=80=20=EB=B9=84=EC=96=B4=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=20=EA=B2=BD=EC=9A=B0,=2010000=EA=B1=B4?= =?UTF-8?q?=EC=9D=98=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=9A=A9=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=9E=90=EB=8F=99=20=EC=82=BD=EC=9E=85=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20(=EB=A1=9C=EC=BB=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/estimate/entity/Estimate.java | 2 + .../global/init/DummyDataInitializer.java | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 backend/src/main/java/com/postdm/backend/global/init/DummyDataInitializer.java diff --git a/backend/src/main/java/com/postdm/backend/domain/estimate/entity/Estimate.java b/backend/src/main/java/com/postdm/backend/domain/estimate/entity/Estimate.java index 76f0924..82db4ad 100644 --- a/backend/src/main/java/com/postdm/backend/domain/estimate/entity/Estimate.java +++ b/backend/src/main/java/com/postdm/backend/domain/estimate/entity/Estimate.java @@ -2,6 +2,7 @@ import com.postdm.backend.domain.member.domain.entity.Member; import jakarta.persistence.*; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -25,6 +26,7 @@ public class Estimate { private LocalDateTime createdAt; + @Builder public Estimate(String content, Member member) { this.title = generateTitle(content); this.content = content; diff --git a/backend/src/main/java/com/postdm/backend/global/init/DummyDataInitializer.java b/backend/src/main/java/com/postdm/backend/global/init/DummyDataInitializer.java new file mode 100644 index 0000000..a30df95 --- /dev/null +++ b/backend/src/main/java/com/postdm/backend/global/init/DummyDataInitializer.java @@ -0,0 +1,46 @@ +package com.postdm.backend.global.init; + +import com.postdm.backend.domain.estimate.entity.Estimate; +import com.postdm.backend.domain.estimate.entity.EstimateRepository; +import com.postdm.backend.domain.member.domain.entity.Member; +import com.postdm.backend.domain.member.domain.repository.MemberRepository; +import com.postdm.backend.global.common.exception.CustomException; +import com.postdm.backend.global.common.response.ErrorCode; +import lombok.RequiredArgsConstructor; +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Component +@RequiredArgsConstructor +@Profile("dev") // 로컬에서만 실행되도록 제한 +public class DummyDataInitializer implements CommandLineRunner { + private final EstimateRepository estimateRepository; + private final MemberRepository memberRepository; + + @Override + public void run(String... args) { + if (estimateRepository.count() > 0) { + log.info("[INIT] 이미 견적서 데이터가 존재합니다. 초기화를 건너뜁니다."); + return; + } + + log.info("[INIT] 더미 견적서 생성 시작"); + + Member member = memberRepository.findById(1L) + .orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND)); + + for (int i = 0; i < 10000; i++) { + Estimate estimate = Estimate.builder() + .content("더미 데이터 자동 생성 " + i) + .member(member) + .build(); + estimateRepository.save(estimate); + } + + log.info("[INIT] 테스트용 견적서 10000건 삽입 완료"); + } +} \ No newline at end of file From c6916e202e78d188cfa6bb2a46463194c53de86c Mon Sep 17 00:00:00 2001 From: "ella.oh" Date: Tue, 3 Jun 2025 19:45:55 +0900 Subject: [PATCH 4/4] =?UTF-8?q?#62=20feat:=20=EA=B8=B0=EB=B3=B8=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=8C=8C=EC=9D=BC=EC=9D=84=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=ED=99=98=EA=B2=BD=EC=9C=BC=EB=A1=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20(=EB=A1=9C=EC=BB=AC=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=20=EC=8B=9C,=20=EB=B3=80=EA=B2=BD=20=ED=95=84=EC=9A=94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index 9374622..03341e3 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -2,7 +2,7 @@ spring: application: name: backend profiles: - active: ${SPRING_PROFILES_ACTIVE:dev} + active: ${SPRING_PROFILES_ACTIVE:prod} # 로컬 테스트 시, dev로 변경 # Swagger 설정 springdoc: