Skip to content

Commit

Permalink
feat :: max count on grid system
Browse files Browse the repository at this point in the history
  • Loading branch information
jombidev committed Oct 16, 2024
1 parent b3b6550 commit bf27dca
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ sealed class ChatQuestion(val type: PromptType) {
data class SelectableQuestion(val choices: List<PromptData.Selectable.Choice>) : ChatQuestion(PromptType.SELECTABLE)

@Serializable
data class GridQuestion(val xSize: Int, val ySize: Int) : ChatQuestion(PromptType.GRID)
data class GridQuestion(val xSize: Int, val ySize: Int, val maxCount: Int) : ChatQuestion(PromptType.GRID)

@Serializable
data object UserInputQuestion : ChatQuestion(PromptType.USER_INPUT)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/teamapi/palette/response/ErrorCode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ enum class ErrorCode(
QNA_INVALID_CHOICES(HttpStatus.BAD_REQUEST, "적절하지 않은 선택: '%s'. %s 선택지 중 하나가 필요합니다."),
QNA_INVALID_GRID_CHOICES(HttpStatus.BAD_REQUEST, "적절하지 않은 그리드: (%s). 0~%d 선택지 중 하나가 필요합니다."),
QNA_INVALID_GRID_DUPE(HttpStatus.BAD_REQUEST, "적절하지 않은 그리드: 중복이 없어야 합니다. possible dupes: (%s)"),
QNA_INVALID_GRID_ABOVE_MAX(HttpStatus.BAD_REQUEST, "적절하지 않은 그리드: 너무 많은 선택지. 최대 크기는 %d입니다."),
QNA_INVALID_GRID_ABOVE_MAX(HttpStatus.BAD_REQUEST, "적절하지 않은 그리드: 너무 많은 선택지. 최대 크기는 '%d'입니다."),
;

override fun getName() = name
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/teamapi/palette/service/ChatService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ChatService(

is ChatAnswer.GridAnswer -> {
val grid = pendingQuestion as PromptData.Grid
val maxSize = grid.question.xSize * grid.question.ySize
val maxSize = grid.question.maxCount
val exceeds = message.choice.filter { it >= maxSize }
if (exceeds.isNotEmpty())
throw CustomException(ErrorCode.QNA_INVALID_GRID_CHOICES, exceeds.joinToString(", "), maxSize - 1)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/teamapi/palette/service/RoomService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class RoomService(
),
PromptData.UserInput("product_explanation"),
PromptData.UserInput("title"),
PromptData.Grid("title_position", ChatQuestion.GridQuestion(3, 3))
PromptData.Grid("title_position", ChatQuestion.GridQuestion(1, 3, 1))
)
)
)
Expand Down

0 comments on commit bf27dca

Please sign in to comment.