Skip to content

Commit

Permalink
refactor: 리뷰 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
Hwanvely committed Aug 12, 2024
1 parent e126830 commit ec8c42f
Show file tree
Hide file tree
Showing 23 changed files with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,25 @@ class SnackgameController(
현재는 점수 수정만 가능하며, 기존 점수가 덮어쓰기된다."""
)
@PutMapping("/{sessionId}/score")
@PutMapping("/{sessionId}")
fun update(
@Authenticated member: Member,
@PathVariable sessionId: Long,
@RequestBody request: @Valid SnackgameUpdateRequest,
@RequestBody @Valid request: SnackgameUpdateRequest,
): SnackgameResponse = snackgameService.update(member.id, sessionId, request)

@Operation(
summary = "스낵게임 세션 수 삽입",
description = """
지정한 세션에 수들을 삽입한다. 황금사과를 제거한 경우 초기화된 판을 응답한다.
"""

)
@PutMapping("/{sessionId}")
@PutMapping("/{sessionId}/moves")
fun placeMoves(
@Authenticated member: Member,
@PathVariable sessionId: Long,
@RequestBody requests: @Valid List<StreakRequest>
@RequestBody @Valid requests: List<StreakRequest>
): ResponseEntity<SnackgameResponse> = snackgameService.placeMoves(member.id, sessionId, requests)
.map { game ->
ResponseEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ class Board() {
companion object {
private const val REMOVABLE_SUM = 10;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ class BoardConverter : AttributeConverter<Board, String> {
throw RuntimeException(e)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ class Coordinate(val y: Int, val x: Int) {
", x=" + x +
'}'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ private fun pickIndexIn(size: Int): Int {

private fun allPositive(vararg numbers: Int): Boolean {
return numbers.all { it > 0 }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class Streak(private val coordinates: MutableList<Coordinate>) {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package com.snackgame.server.game.snackgame.exception
import com.snackgame.server.common.exception.Kind

class EmptySnackException(message: String, kind: Kind = Kind.BAD_REQUEST) : SnackgameException(message, kind) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import com.snackgame.server.common.exception.Kind

class InaccuratePercentileException(percentile: Double) : SnackgameException(
"백분위 계산이 잘못되었습니다: $percentile", Kind.INTERNAL_SERVER_ERROR
)
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.snackgame.server.game.snackgame.exception

class InvalidBoardSizeException : SnackgameException("잘못된 크기의 게임판입니다.") {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package com.snackgame.server.game.snackgame.exception

class InvalidCoordinateException : SnackgameException("잘못된 좌표입니다.") {

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.snackgame.server.game.snackgame.exception

class NegativeCoordinateException : SnackgameException("좌표는 음수가 아니어야 합니다.") {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package com.snackgame.server.game.snackgame.exception
import com.snackgame.server.common.exception.Kind

class SnackNotRemovableException(message: String, kind: Kind = Kind.BAD_REQUEST) : SnackgameException(message, kind) {
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.snackgame.server.game.snackgame.exception

class SnackNumberRangeException : SnackgameException("잘못된 범위의 숫자입니다.") {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ import com.snackgame.server.common.exception.BusinessException
import com.snackgame.server.common.exception.Kind

abstract class SnackgameException(message: String, kind: Kind = Kind.BAD_REQUEST) : BusinessException(kind, message)

Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ data class StreakRequest(
return Streak(coordinates)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class EmptySnack private constructor() : Snack() {
override fun exists(): Boolean {
return false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class GoldenSnack private constructor(number: Int) : Snack(number) {
override fun exists(): Boolean {
return true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ class PlainSnack private constructor(number: Int) : Snack(number) {
override fun exists(): Boolean {
return true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ abstract class Snack protected constructor(
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class SnackDeserializer : StdDeserializer<Snack>(Snack.javaClass) {
else -> PlainSnack.of(number)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ class BoardTest {
board.removeSnacksIn(streak)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ class SnackgameTest {
game.removeSnacks(streak)
assertThat(game.score).isEqualTo(expectedScore)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class StreakTest {
Coordinate(2, 1),
)
)
println(properStreak.toCoordinates().size)
assertDoesNotThrow { properStreak.validateStreak() }
}
}
}

0 comments on commit ec8c42f

Please sign in to comment.