-
Notifications
You must be signed in to change notification settings - Fork 0
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
[feat] 그룹 도메인 구현 #33
Open
jsoonworld
wants to merge
15
commits into
develop
Choose a base branch
from
feat/19
base: develop
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
[feat] 그룹 도메인 구현 #33
+749
−0
Conversation
This file contains 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
- SecureRandom을 사용하여 초대 코드를 무작위로 생성하도록 구현 - InviteCodePolicy를 통해 코드 길이 및 허용 문자 검증 - 생성된 코드가 정책을 따르는지 검증하는 로직 추가 - GroupInvitationCode로 변환하여 반환
- 그룹 초대 코드 검증 관련 예외 코드 추가 - 초대 코드가 비어 있는 경우 - 초대 코드의 길이가 6글자가 아닌 경우 - 초대 코드에 알파벳 대문자와 숫자 이외의 문자가 포함된 경우 - 그룹 이름 검증 관련 예외 코드 추가 - 그룹 이름이 비어 있는 경우 - 그룹 이름의 길이가 30자를 초과하는 경우 - 그룹 이름에 허용되지 않은 문자가 포함된 경우 - 그룹 멤버 수 검증 관련 예외 코드 추가 - 초기 그룹 멤버 수가 음수일 경우 - 그룹 멤버 수가 음수로 감소할 경우 - 그룹 멤버 수가 최대 50명을 초과할 경우 - 모든 예외 메시지에 `[GROUP ERROR]` 접두사 추가
- GroupErrorCode를 활용한 예외 메시지 관리 - 런타임 예외(RuntimeException)를 상속하여 예외 처리 용이 - 예외 발생 시 GroupErrorCode의 메시지를 포함하도록 구현
- SecureRandom을 빈으로 등록하여 무작위 코드 생성 지원 - 기본 초대 코드 정책(DefaultInviteCodePolicy) 빈 등록 - InviteCodeGenerator를 빈으로 등록하여 DI 가능하도록 설정
- 초대 코드의 기본 길이를 6자로 설정 - 허용 가능한 문자로 대문자 A-Z 및 숫자 0-9 지정 - 유효성 검사 로직 추가 (길이 6자, 허용 문자만 포함 여부 확인)
- BaseTimeEntity를 상속하여 생성 및 수정 시간 자동 관리 - 그룹 ID(groupId)를 기본 키로 설정 (AUTO_INCREMENT) - 초대 코드(GroupInvitationCode), 그룹 이름(GroupName), 프로필 이미지 키(GroupProfileImageKey), 멤버 수(GroupMemberCount)를 임베디드 값 객체로 저장 - 그룹 생성자에서 기본 멤버 수를 1명으로 설정 - 정적 팩토리 메서드 `Group.of()` 추가하여 객체 생성을 명확하게 표현
- 초대 코드의 길이를 반환하는 `codeLength()` 메서드 정의 - 허용 가능한 문자 목록을 반환하는 `allowedCharacters()` 메서드 정의 - 초대 코드 유효성을 검증하는 `validate(String code)` 메서드 정의 - 구현체에서 다양한 초대 코드 정책을 적용할 수 있도록 인터페이스 분리
- 초대 코드를 `@Embeddable` 값 객체로 정의하여 JPA에서 사용 가능하도록 설정 - 코드 길이를 6자로 제한하는 `CODE_LENGTH` 상수 추가 - 대문자 A-Z 및 숫자 0-9만 허용하는 `ALLOWED_CHARACTERS` 생성 - `validate()` 메서드를 통해 초대 코드의 유효성을 검증 - 비어 있지 않은지 확인 (`validateNotEmpty`) - 길이가 정확히 6자인지 확인 (`validateLength`) - 허용된 문자(A-Z, 0-9)만 포함하는지 확인 (`validateCharacters`) - 정적 팩토리 메서드 `from(String code)` 제공 - 코드 값을 반환하는 `value()` 메서드 추가 - 초대 코드를 문자열로 반환하는 `toString()` 오버라이드
- `@Embeddable`을 사용하여 JPA 내장 타입으로 설정 - 최대 멤버 수를 50명으로 제한하는 `MAX_MEMBERS` 상수 추가 - `from(Long count)` 정적 팩토리 메서드를 통해 객체 생성 - 초기 멤버 수가 음수일 경우 예외 발생 (`validateInitial`) - 멤버 수 증가/감소 기능 제공 - `increase()`: 멤버 수 1 증가 (`validateChange`로 검증) - `decrease()`: 멤버 수 1 감소 (`validateChange`로 검증) - 유효성 검사 추가 - 멤버 수가 음수일 경우 예외 발생 (`validateNonNegative`) - 멤버 수가 최대 50명을 초과할 경우 예외 발생 (`validateMaxLimit`) - 멤버 수를 문자열로 변환하는 `toString()` 오버라이드
- `@Embeddable`을 사용하여 JPA 내장 타입으로 설정 - 한글, 영문(대소문자), 숫자만 허용하는 정규식 패턴 적용 (`NAME_PATTERN`) - `from(String name)` 정적 팩토리 메서드를 통해 객체 생성 - 유효성 검사 로직 추가: - `validateEmpty()`: 그룹 이름이 `null`이거나 공백일 경우 예외 발생 - `validateLength()`: 그룹 이름의 길이가 30자를 초과할 경우 예외 발생 - `validatePattern()`: 허용되지 않은 문자가 포함된 경우 예외 발생 - 그룹 이름을 반환하는 `value()` 메서드 추가 - 문자열 변환을 위한 `toString()` 오버라이드
- `@Embeddable`을 사용하여 JPA 내장 타입으로 설정 - 프로필 이미지 키를 저장하는 `key` 필드 추가 - `from(String key)` 정적 팩토리 메서드를 통해 객체 생성 - `null` 값이 입력될 경우 기본 생성자를 사용하여 `null` 저장 - 프로필 이미지 키 값을 반환하는 `value()` 메서드 추가 - 문자열 변환을 위한 `toString()` 오버라이드
- 성공 케이스 - 유효한 초대 코드(6자리 영문 대문자 + 숫자 조합) 생성 테스트 - 실패 케이스 - 초대 코드가 `null` 또는 비어 있는 경우 예외 발생 검증 - 초대 코드의 길이가 6자가 아닌 경우 예외 발생 검증 - 초대 코드에 허용되지 않은 문자(특수 문자, 공백 포함) 포함 시 예외 발생 검증 - 초대 코드에 소문자가 포함된 경우 예외 발생 검증
- 성공 케이스 - 초기 멤버 수가 0인 경우 객체 정상 생성 검증 - 멤버 수 증가 시 정상적으로 값이 증가하는지 검증 - 멤버 수 감소 시 정상적으로 값이 감소하는지 검증 - 실패 케이스 - 멤버 수가 음수가 될 경우 예외 발생 검증 - 멤버 수가 최대값(50명)을 초과할 경우 예외 발생 검증 - 초기값이 음수인 경우 예외 발생 검증
- 성공 케이스 - 유효한 그룹 이름으로 객체 정상 생성 검증 (한글, 영문, 숫자 조합 허용) - 실패 케이스 - 그룹 이름이 `null` 또는 비어 있는 경우 예외 발생 검증 - 그룹 이름의 길이가 30자를 초과하는 경우 예외 발생 검증 - 그룹 이름에 특수 문자가 포함된 경우 예외 발생 검증 - 그룹 이름에 공백이 포함된 경우 예외 발생 검증
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🚀 What’s this PR about?
🛠️ What’s been done?
🧪 Testing Details
👀 Checkpoints for Reviewers
🎯 Related Issues