Skip to content
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

[OING-343] refactor: 가족 이름 컬럼 타입 및 검증 로직 수정 #267

Merged
merged 4 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions family/src/main/java/com/oing/domain/Family.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Family extends BaseEntity {
@Column(name = "family_id", columnDefinition = "CHAR(26)", nullable = false)
private String id;

@Column(name = "family_name", columnDefinition = "CHAR(10)")
@Column(name = "family_name", columnDefinition = "CHAR(9)")
private String familyName;

@Column(name = "family_name_editor_id", columnDefinition = "CHAR(26)")
Expand Down Expand Up @@ -49,14 +49,6 @@ public void subtractNewPostScore() {
subtractScore(NEW_POST_SCORE);
}

public void addAllFamilyMembersPostsUploadedScore() {
addScore(ALL_FAMILY_MEMBERS_POSTS_UPLOADED_SCORE);
}

public void subtractAllFamilyMembersPostsUploadedScore() {
subtractScore(ALL_FAMILY_MEMBERS_POSTS_UPLOADED_SCORE);
}

public void addNewCommentScore() {
addScore(NEW_COMMENT_SCORE);
}
Expand Down Expand Up @@ -93,19 +85,16 @@ public void resetScore() {
this.score = 0;
}

public void updateFamilyName(String familyName, String loginFamilyId) {
if (familyName == null) {
this.familyName = null;
this.familyNameEditorId = null;
} else {
public void updateFamilyName(String familyName, String familyNameEditorId) {
if (familyName != null) {
validateFamilyName(familyName);
this.familyName = familyName;
this.familyNameEditorId = loginFamilyId;
}
this.familyName = familyName;
this.familyNameEditorId = familyNameEditorId;
}

private void validateFamilyName(String familyName) {
if ((familyName.codePoints().count() > 10) || familyName.isBlank()) {
if ((familyName.codePoints().count() > 9) || familyName.isBlank()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

회원 닉네임 로직처럼 사용자가 띄어쓰기 하나만 입력하면 예외던지도록 유지했습니다

throw new InvalidParameterException();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@Schema(description = "가족 이름 수정 요청")
public record UpdateFamilyNameRequest(

@Size(max = 10)
@Size(max = 9)
@Schema(description = "가족 이름", example = "오잉")
String familyName
) {
Expand Down
4 changes: 2 additions & 2 deletions family/src/test/java/com/oing/service/FamilyServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public class FamilyServiceTest {
}

@Test
void 열_자_초과_가족_이름_수정_예외_검증() {
void 아홉_자_초과_가족_이름_수정_예외_검증() {
// given
String newName = "wrong-length-name";
String newName = "wrong-length-nam";
String memberId = "1";
String familyId = "1";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `family` MODIFY `family_name` VARCHAR(9);
Loading