generated from Loopers-dev-lab/loop-pack-be-l2-vol2-java
-
Notifications
You must be signed in to change notification settings - Fork 44
[volume-1]회원가입/내 정보 조회/비밀번호 수정 기능 작성 #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
katiekim17
wants to merge
8
commits into
Loopers-dev-lab:katiekim17
Choose a base branch
from
katiekim17:volume-1
base: katiekim17
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c0dcfd8
remove: deprecated codeguide
hanyoung-kurly 49e1d72
feat: 회원가입 구현
katiekim17 d4a67a7
feat: 회원가입 구현
katiekim17 5860d33
feat: 내 정보 조회
ksonepick-dev fd56b5e
feat: 내 정보 조회 구현
katiekim17 e6e5d94
feat: 비밀번호 구현
katiekim17 df0e330
feat: 헤더인증 추가(테스트에도 추가)
katiekim17 2f40dc7
docs: 회원 도메인 플로우 다이어그램 추가
katiekim17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Bash(./gradlew test:*)", | ||
| "Bash(./gradlew :apps:commerce-api:test:*)" | ||
| ] | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Tech Stack & Versions | ||
|
|
||
| | Category | Technology | Version | | ||
| |----------|------------|---------| | ||
| | Language | Java | 21 | | ||
| | Framework | Spring Boot | 3.4.4 | | ||
| | Dependency Management | Spring Dependency Management | 1.1.7 | | ||
| | Cloud | Spring Cloud | 2024.0.1 | | ||
| | Build Tool | Gradle (Kotlin DSL) | 8.13+ | | ||
| | API Documentation | SpringDoc OpenAPI | 2.7.0 | | ||
| | ORM | Spring Data JPA + QueryDSL | (managed by Spring Boot) | | ||
| | Database | MySQL | 8.0 | | ||
| | Cache | Redis (Master-Replica) | - | | ||
| | Messaging | Kafka | 3.5.1 | | ||
| | Monitoring | Micrometer + Prometheus | (managed by Spring Boot) | | ||
| | Logging | Logback + Slack Appender | 1.6.1 | | ||
| | Testing | JUnit 5, Mockito 5.14.0, SpringMockk 4.0.2, Instancio 5.0.2 | - | | ||
| | Containers | TestContainers | (managed by Spring Boot) | | ||
|
|
||
| ## Build & Run Commands | ||
|
|
||
| ```bash | ||
| # Build all modules | ||
| ./gradlew build | ||
|
|
||
| # Run tests (profile: test, timezone: Asia/Seoul) | ||
| ./gradlew test | ||
|
|
||
| # Run specific app | ||
| ./gradlew :apps:commerce-api:bootRun | ||
| ./gradlew :apps:commerce-batch:bootRun --args='--job.name=jobName' | ||
| ./gradlew :apps:commerce-streamer:bootRun | ||
|
|
||
| # Build specific module | ||
| ./gradlew :apps:commerce-api:build | ||
|
|
||
| # Run single test class | ||
| ./gradlew test --tests "com.loopers.ExampleServiceIntegrationTest" | ||
|
|
||
| # Run single test method | ||
| ./gradlew test --tests "com.loopers.ExampleServiceIntegrationTest.testMethodName" | ||
|
|
||
| # Test with coverage report | ||
| ./gradlew test jacocoTestReport | ||
| ``` | ||
|
|
||
| **Java version**: 21 (configured via Gradle toolchain) | ||
|
|
||
| ## Local Infrastructure | ||
|
|
||
| ```bash | ||
| # Start MySQL, Redis (master+replica), Kafka | ||
| docker-compose -f docker/infra-compose.yml up | ||
|
|
||
| # Start Prometheus + Grafana monitoring | ||
| docker-compose -f docker/monitoring-compose.yml up | ||
| ``` | ||
|
|
||
| - MySQL: localhost:3307 (root/root, application/application) | ||
| - Redis Master: localhost:6379, Replica: localhost:6380 | ||
| - Kafka: localhost:19092, Kafka UI: localhost:9099 | ||
| - Grafana: localhost:3000 (admin/admin) | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Multi-Module Structure | ||
|
|
||
| ``` | ||
| loopers-java-spring-template/ | ||
| ├── apps/ # Executable Spring Boot applications | ||
| │ ├── commerce-api # REST API (web, actuator, springdoc-openapi) | ||
| │ ├── commerce-batch # Batch jobs (spring-batch) | ||
| │ └── commerce-streamer # Event streaming (web, kafka) | ||
| ├── modules/ # Reusable infrastructure configurations | ||
| │ ├── jpa # JPA, QueryDSL, MySQL connector | ||
| │ ├── redis # Spring Data Redis (master-replica) | ||
| │ └── kafka # Spring Kafka | ||
| └── supports/ # Cross-cutting add-on modules | ||
| ├── jackson # Jackson serialization (Kotlin module, JSR310) | ||
| ├── logging # Logback, Slack appender | ||
| └── monitoring # Micrometer, Prometheus registry | ||
| ``` | ||
|
|
||
| ### Module Dependencies | ||
|
|
||
| | App | modules | supports | | ||
| |-----|---------|----------| | ||
| | commerce-api | jpa, redis | jackson, logging, monitoring | | ||
| | commerce-batch | jpa, redis | jackson, logging, monitoring | | ||
| | commerce-streamer | jpa, redis, kafka | jackson, logging, monitoring | | ||
|
|
||
| ### Layer Architecture (commerce-api) | ||
| ``` | ||
| interfaces/api/ → Controllers, DTOs, OpenAPI specs | ||
| application/ → Facades (use case orchestration) | ||
| domain/ → Entities, Services, Repository interfaces | ||
| infrastructure/ → Repository implementations, adapters | ||
| ``` | ||
|
|
||
| ### Key Patterns | ||
| - **Controllers**: Implement `*ApiSpec` interfaces for OpenAPI documentation | ||
| - **Facades**: Orchestrate domain services, convert domain models to DTOs | ||
| - **Services**: `@Component` with `@Transactional`, contain business logic | ||
| - **Repositories**: Interface in `domain/`, implementation in `infrastructure/` | ||
| - **Entities**: Extend `BaseEntity` (provides id, createdAt, updatedAt, deletedAt) | ||
| - **Response wrapper**: All APIs return `ApiResponse<T>` | ||
| - **Error handling**: `CoreException` with `ErrorType` enum, caught by `ApiControllerAdvice` | ||
|
|
||
| ### Soft Delete | ||
| Entities use `deletedAt` field via `BaseEntity`: | ||
| ```java | ||
| entity.delete(); // marks as deleted | ||
| entity.restore(); // restores | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| - Profile-based: local, test, dev, qa, prd | ||
| - Config imports in application.yml: jpa.yml, redis.yml, logging.yml, monitoring.yml | ||
| - Management endpoints on port 8081 (/health, /prometheus) | ||
|
|
||
| ## Testing | ||
|
|
||
| - Framework: JUnit 5 + AssertJ + Mockito + SpringMockk + Instancio | ||
| - `DatabaseCleanUp` utility truncates tables between tests (from jpa test fixtures) | ||
| - `RedisCleanUp` available from redis test fixtures | ||
| - TestContainers support for MySQL, Redis, Kafka | ||
|
|
||
| ## 개발 규칙 | ||
|
|
||
| ### 진행 Workflow - 증강 코딩 | ||
| - **대원칙**: 방향성 및 주요 의사 결정은 개발자에게 제안만 할 수 있으며, 최종 승인된 사항을 기반으로 작업 수행 | ||
| - **중간 결과 보고**: AI가 반복적인 동작을 하거나, 요청하지 않은 기능을 구현, 테스트 삭제를 임의로 진행할 경우 개발자가 개입 | ||
| - **설계 주도권 유지**: AI가 임의판단을 하지 않고, 방향성에 대한 제안 등을 진행할 수 있으나 개발자의 승인을 받은 후 수행 | ||
|
|
||
| ### 개발 Workflow - TDD (Red → Green → Refactor) | ||
| - 모든 테스트는 3A 원칙으로 작성 (Arrange - Act - Assert) | ||
|
|
||
| | Phase | 설명 | | ||
| |-------|------| | ||
| | **Red** | 요구사항을 만족하는 실패하는 테스트 케이스 먼저 작성 | | ||
| | **Green** | Red Phase의 테스트가 모두 통과할 수 있는 최소한의 코드 작성 (오버엔지니어링 금지) | | ||
| | **Refactor** | 불필요한 private 함수 지양, 객체지향적 코드 작성, unused import 제거, 성능 최적화. 모든 테스트 통과 필수 | | ||
|
|
||
| ### 주의사항 | ||
|
|
||
| **Never Do:** | ||
| - 실제 동작하지 않는 코드, 불필요한 Mock 데이터를 이용한 구현 금지 | ||
| - null-safety 하지 않은 코드 작성 금지 (Java의 경우 Optional 활용) | ||
| - println 코드 남기지 말 것 | ||
|
|
||
| **Recommendation:** | ||
| - 실제 API를 호출해 확인하는 E2E 테스트 코드 작성 | ||
| - 재사용 가능한 객체 설계 | ||
| - 성능 최적화에 대한 대안 및 제안 | ||
| - 개발 완료된 API는 `http/*.http` 파일에 분류해 작성 | ||
|
|
||
| **Priority:** | ||
| 1. 실제 동작하는 해결책만 고려 | ||
| 2. null-safety, thread-safety 고려 | ||
| 3. 테스트 가능한 구조로 설계 | ||
| 4. 기존 코드 패턴 분석 후 일관성 유지 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| # Flow Diagrams | ||
|
|
||
| ## 1. 회원가입 (POST /api/v1/members) | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| autonumber | ||
| participant Client | ||
| participant Controller | ||
| participant Facade | ||
| participant Service | ||
| participant DB | ||
|
|
||
| Client->>Controller: POST /api/v1/members (SignUpRequest) | ||
| Controller->>Facade: signupMember(request) | ||
| Facade->>Facade: Request to MemberModel 변환 | ||
| Facade->>Service: saveMember(memberModel) | ||
| Service->>DB: findByLoginId (중복 체크) | ||
| DB-->>Service: Optional.empty() | ||
| Service->>Service: passwordEncoder.encode() | ||
| Service->>DB: save(memberModel) | ||
| DB-->>Service: savedMember | ||
| Service-->>Facade: MemberModel | ||
| Facade->>Facade: MemberModel to MemberInfo 변환 | ||
| Facade-->>Controller: MemberInfo | ||
| Controller-->>Client: 201 Created (SignUpResponse) | ||
| ``` | ||
|
|
||
| ### 예외 흐름 | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| autonumber | ||
| participant Client | ||
| participant Controller | ||
| participant Facade | ||
| participant Service | ||
| participant DB | ||
|
|
||
| Client->>Controller: POST /api/v1/members (중복 ID) | ||
| Controller->>Facade: signupMember(request) | ||
| Facade->>Service: saveMember(memberModel) | ||
| Service->>DB: findByLoginId | ||
| DB-->>Service: Optional.of(existingMember) | ||
| Service-->>Controller: CoreException (CONFLICT) | ||
| Controller-->>Client: 409 Conflict | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 2. 내 정보 조회 (GET /api/v1/members/me) | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| autonumber | ||
| participant Client | ||
| participant Controller | ||
| participant Facade | ||
| participant Service | ||
| participant DB | ||
|
|
||
| Client->>Controller: GET /api/v1/members/me | ||
| Note over Client,Controller: Headers: X-Loopers-LoginId, X-Loopers-LoginPw | ||
| Controller->>Facade: getMyInfo(loginId, password) | ||
| Facade->>Service: authenticate(loginId, password) | ||
| Service->>DB: findByLoginId | ||
| DB-->>Service: MemberModel | ||
| Service->>Service: passwordEncoder.matches() | ||
| Service-->>Facade: MemberModel (인증 성공) | ||
| Facade->>Facade: MemberModel to MemberInfo 변환 (이름 마스킹) | ||
| Facade-->>Controller: MemberInfo | ||
| Controller-->>Client: 200 OK (MemberInfoResponse) | ||
| ``` | ||
|
|
||
| ### 예외 흐름 - 인증 실패 | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| autonumber | ||
| participant Client | ||
| participant Controller | ||
| participant Facade | ||
| participant Service | ||
| participant DB | ||
|
|
||
| Client->>Controller: GET /api/v1/members/me (틀린 비밀번호) | ||
| Controller->>Facade: getMyInfo(loginId, wrongPassword) | ||
| Facade->>Service: authenticate(loginId, wrongPassword) | ||
| Service->>DB: findByLoginId | ||
| DB-->>Service: MemberModel | ||
| Service->>Service: passwordEncoder.matches() = false | ||
| Service-->>Controller: CoreException (UNAUTHORIZED) | ||
| Controller-->>Client: 401 Unauthorized | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 3. 비밀번호 변경 (PATCH /api/v1/members/me/password) | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| autonumber | ||
| participant Client | ||
| participant Controller | ||
| participant Facade | ||
| participant Service | ||
| participant DB | ||
|
|
||
| Client->>Controller: PATCH /api/v1/members/me/password | ||
| Note over Client,Controller: Headers: X-Loopers-LoginId, X-Loopers-LoginPw | ||
| Note over Client,Controller: Body: oldPassword, newPassword | ||
| Controller->>Facade: changePassword(loginId, headerPw, oldPw, newPw) | ||
| Facade->>Service: authenticate(loginId, headerPw) | ||
| Service->>DB: findByLoginId | ||
| DB-->>Service: MemberModel | ||
| Service->>Service: passwordEncoder.matches(headerPw) | ||
| Service-->>Facade: 인증 성공 | ||
| Facade->>Facade: new MemberModel(loginId, oldPw) | ||
| Facade->>Service: changePassword(memberModel, newPw) | ||
| Service->>Service: passwordEncoder.matches(oldPw) 검증 | ||
| Service->>Service: newPw != oldPw 검증 | ||
| Service->>Service: validatePassword(newPw) 규칙 검증 | ||
| Service->>Service: passwordEncoder.encode(newPw) | ||
| Service->>DB: Dirty Checking (자동 저장) | ||
| Service-->>Facade: void | ||
| Facade-->>Controller: void | ||
| Controller-->>Client: 200 OK | ||
| ``` | ||
|
|
||
| ### 예외 흐름 - Body의 기존 비밀번호 불일치 | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| autonumber | ||
| participant Client | ||
| participant Controller | ||
| participant Facade | ||
| participant Service | ||
|
|
||
| Client->>Controller: PATCH (헤더 인증 OK, Body oldPw 틀림) | ||
| Controller->>Facade: changePassword(...) | ||
| Facade->>Service: authenticate() 성공 | ||
| Facade->>Service: changePassword(wrongOldPw, newPw) | ||
| Service->>Service: passwordEncoder.matches(wrongOldPw) = false | ||
| Service-->>Controller: CoreException (UNAUTHORIZED) | ||
| Controller-->>Client: 401 Unauthorized | ||
| ``` | ||
|
|
||
| ### 예외 흐름 - 새 비밀번호가 기존과 동일 | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| autonumber | ||
| participant Client | ||
| participant Controller | ||
| participant Facade | ||
| participant Service | ||
|
|
||
| Client->>Controller: PATCH (newPw == oldPw) | ||
| Controller->>Facade: changePassword(...) | ||
| Facade->>Service: authenticate() 성공 | ||
| Facade->>Service: changePassword(oldPw, samePassword) | ||
| Service->>Service: oldPw 검증 성공 | ||
| Service->>Service: newPw == oldPw 체크 | ||
| Service-->>Controller: CoreException (BAD_REQUEST) | ||
| Controller-->>Client: 400 Bad Request | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java
Length of output: 451
🏁 Script executed:
Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java
Length of output: 270
🏁 Script executed:
Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java
Length of output: 67
🏁 Script executed:
Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java
Length of output: 1230
🏁 Script executed:
Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java
Length of output: 1361
🏁 Script executed:
Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java
Length of output: 1003
🏁 Script executed:
Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java
Length of output: 233
🌐 Web query:
Gradle wildcard task pattern syntax colon test:*💡 Result:
In Gradle task paths,
:is a separator, not a wildcard operator. Sotest:*(or:test:*) is not valid Gradle task-selection syntax—Gradle doesn’t support*wildcards for choosing tasks by name/path on the command line. Instead, Gradle supports task selectors (e.g.,testruns thetesttask across subprojects) and name abbreviation (unique prefixes / camel-case abbreviations). [1]What to use instead:
Run
testfor all subprojects (from the root):./gradlew test(task selector across the multi-project build) [1]Run
testin one subproject:./gradlew :subproject:test(orsubproject:test) [1]If you meant “wildcard” for tests inside the
testtask (not tasks):./gradlew test --tests '*SomePattern*'(test filtering supports*) [2]Sources:
[1] Gradle User Manual – Command-Line Interface (multi-project task paths, task selectors, name abbreviation) (docs.gradle.org)
[2] Gradle User Manual – Testing in Java & JVM projects (test filtering,
--tests, wildcard*) (docs.gradle.org)Citations:
🌐 Web query:
Gradle task selector patterns documentation💡 Result:
Gradle documents “task selector patterns” as task paths/selectors plus name abbreviation (pattern expansion) in the Gradle User Manual:
Task selectors / task paths (multi-project):
:subproject:taskName(orsubproject:taskName).gradle testrunstestin all subprojects that have it).Source: Gradle Command-Line Interface → “Executing tasks in multi-project builds”. [1]
Name abbreviation / “patterns” (what most people mean by selector patterns):
gradle che→check).foBaorfBmatchesfooBarandfoo-bar).gradle mAL:cT).Source: Gradle Command-Line Interface → “Name abbreviation”. [1]
If you want the shorter “basics” page for task paths (but it doesn’t cover the abbreviation patterns in as much detail), see: Command-Line Interface Basics → “Executing tasks”. [2]
Sources
[1] Gradle User Manual — Command-Line Interface: https://docs.gradle.org/current/userguide/command_line_interface.html
[2] Gradle User Manual — Command-Line Interface Basics: https://docs.gradle.org/current/userguide/command_line_interface_basics.html
🏁 Script executed:
Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java
Length of output: 112
Gradle 태스크 패턴 문법을 표준 형식으로 수정한다.
test:*형식은 Gradle 공식 명령어가 아니다. Gradle은 태스크 경로에서:를 구분자로 사용하지만*와일드카드를 지원하지 않는다. 현재 패턴./gradlew test:*와./gradlew :apps:commerce-api:test:*는 표준 Gradle 문법이 아니므로 의도한 권한이 제대로 부여되지 않을 위험이 있다.운영 관점에서 다음과 같이 수정한다:
./gradlew test(모든 모듈의 테스트 태스크)./gradlew :apps:commerce-api:test(commerce-api 모듈만 테스트)이렇게 수정하면 Claude가 정확한 Gradle 태스크를 실행할 수 있으며, 저장소 구조와의 명확한 대응이 보장된다. 추가로 권한 시스템이 실제로 이 패턴들을 인식하는지 테스트한다.
🤖 Prompt for AI Agents