-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] 대화방 제목 지정/수정 API #54
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
821ec2f
feat: 대화방 제목 지정/수정 API 추가
theminjunchoi 50b9289
fix: 제목 수정 동시성·검증 정합성 개선 (CodeRabbit 리뷰 반영)
theminjunchoi 299f59e
Merge remote-tracking branch 'origin/dev' into feat/53-conversation-t…
theminjunchoi deb5c42
chore: 대화방 제목 마이그레이션 V9 → V11 리네임
theminjunchoi 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
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
12 changes: 12 additions & 0 deletions
12
...in/kotlin/com/nexters/gamss/conversation/controller/dto/UpdateConversationTitleRequest.kt
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,12 @@ | ||
| package com.nexters.gamss.conversation.controller.dto | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema | ||
|
|
||
| /** | ||
| * 제목 유효성(공백·길이)은 [com.nexters.gamss.conversation.domain.ConversationTitle] 값 객체가 단일 검증한다. | ||
| * 그래서 여기서는 별도 제약을 두지 않는다 — 공백·초과는 INVALID_CONVERSATION_TITLE, 필드 누락은 INVALID_INPUT. | ||
| */ | ||
| data class UpdateConversationTitleRequest( | ||
| @field:Schema(description = "지정할 채팅방 제목(1~100자)", example = "비 오는 날의 짜증") | ||
| val title: String, | ||
| ) | ||
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
49 changes: 49 additions & 0 deletions
49
src/main/kotlin/com/nexters/gamss/conversation/domain/ConversationTitle.kt
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,49 @@ | ||
| package com.nexters.gamss.conversation.domain | ||
|
|
||
| import com.nexters.gamss.global.exception.BusinessException | ||
| import com.nexters.gamss.global.exception.ErrorCode | ||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Embeddable | ||
|
|
||
| /** | ||
| * 대화방 제목 값 객체. 앞뒤 공백을 정리하고 비어 있지 않음·최대 길이 불변식을 스스로 보장한다. | ||
| * (카드 요약과는 무관한 독립 개념이다.) | ||
| */ | ||
| @Embeddable | ||
| class ConversationTitle( | ||
| value: String, | ||
| ) { | ||
| @Column(name = "title", length = MAX_LENGTH) | ||
| val value: String = value.trim() | ||
|
|
||
| init { | ||
| validate(this.value) | ||
| } | ||
|
|
||
| private fun validate(value: String) { | ||
| if (value.isEmpty()) { | ||
| throw BusinessException(ErrorCode.INVALID_CONVERSATION_TITLE, "채팅방 제목은 비어 있을 수 없습니다.") | ||
| } | ||
| if (value.length > MAX_LENGTH) { | ||
| throw BusinessException(ErrorCode.INVALID_CONVERSATION_TITLE, "채팅방 제목은 ${MAX_LENGTH}자 이하여야 합니다.") | ||
| } | ||
| } | ||
|
|
||
| override fun equals(other: Any?): Boolean { | ||
| if (this === other) { | ||
| return true | ||
| } | ||
| if (other !is ConversationTitle) { | ||
| return false | ||
| } | ||
| return value == other.value | ||
| } | ||
|
|
||
| override fun hashCode(): Int = value.hashCode() | ||
|
|
||
| override fun toString(): String = value | ||
|
|
||
| companion object { | ||
| const val MAX_LENGTH = 100 | ||
| } | ||
| } |
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
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
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,2 @@ | ||
| -- 대화방 제목. 첫 생성 시에는 없고(null), 이후 클라이언트가 지정한다(여러 번 수정 가능). | ||
| ALTER TABLE conversations ADD COLUMN title VARCHAR(100) NULL; |
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
42 changes: 42 additions & 0 deletions
42
src/test/kotlin/com/nexters/gamss/conversation/domain/ConversationTitleTest.kt
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,42 @@ | ||
| package com.nexters.gamss.conversation.domain | ||
|
|
||
| import com.nexters.gamss.global.exception.BusinessException | ||
| import com.nexters.gamss.global.exception.ErrorCode | ||
| import kotlin.test.Test | ||
| import kotlin.test.assertEquals | ||
| import kotlin.test.assertFailsWith | ||
|
|
||
| class ConversationTitleTest { | ||
| @Test | ||
| fun `유효한 값으로 제목을 생성한다`() { | ||
| assertEquals("비 오는 날의 짜증", ConversationTitle("비 오는 날의 짜증").value) | ||
| } | ||
|
|
||
| @Test | ||
| fun `앞뒤 공백을 제거한다`() { | ||
| assertEquals("제목", ConversationTitle(" 제목 ").value) | ||
| } | ||
|
|
||
| @Test | ||
| fun `최대 길이까지 허용한다`() { | ||
| val value = "가".repeat(ConversationTitle.MAX_LENGTH) | ||
|
|
||
| assertEquals(value, ConversationTitle(value).value) | ||
| } | ||
|
|
||
| @Test | ||
| fun `공백만 있으면 INVALID_CONVERSATION_TITLE`() { | ||
| val exception = assertFailsWith<BusinessException> { ConversationTitle(" ") } | ||
|
|
||
| assertEquals(ErrorCode.INVALID_CONVERSATION_TITLE, exception.errorCode) | ||
| } | ||
|
|
||
| @Test | ||
| fun `최대 길이를 넘으면 INVALID_CONVERSATION_TITLE`() { | ||
| val tooLong = "가".repeat(ConversationTitle.MAX_LENGTH + 1) | ||
|
|
||
| val exception = assertFailsWith<BusinessException> { ConversationTitle(tooLong) } | ||
|
|
||
| assertEquals(ErrorCode.INVALID_CONVERSATION_TITLE, exception.errorCode) | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.