From a81ae45f3fab96534327f995dbf9735b6bf3ee54 Mon Sep 17 00:00:00 2001 From: Park - Jeonghwan <990706leo@gmail.com> Date: Thu, 17 Oct 2024 18:44:58 +0900 Subject: [PATCH] =?UTF-8?q?refactor(snackgame):=20=EA=B2=8C=EC=9E=84=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9DAPI=EC=9D=98=20=EC=9D=91=EB=8B=B5=EC=9D=84=20?= =?UTF-8?q?=ED=86=B5=ED=95=A9=ED=95=9C=EB=8B=A4=20(#181)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 경우에 따라 분리됐던 응답 고정 * refactor(game.snackgame): 스낵게임 보드를 항상 응답한다 --------- Co-authored-by: 0chil <0@chll.it> --- .../biz/controller/SnackgameBizController.kt | 11 +++++------ .../game/snackgame/biz/service/SnackgameBizService.kt | 6 ++---- .../snackgame/core/controller/SnackgameController.kt | 10 ++++------ .../game/snackgame/core/service/SnackgameService.kt | 6 ++---- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/snackgame/server/game/snackgame/biz/controller/SnackgameBizController.kt b/src/main/java/com/snackgame/server/game/snackgame/biz/controller/SnackgameBizController.kt index 71c6181..2acbccd 100644 --- a/src/main/java/com/snackgame/server/game/snackgame/biz/controller/SnackgameBizController.kt +++ b/src/main/java/com/snackgame/server/game/snackgame/biz/controller/SnackgameBizController.kt @@ -64,13 +64,12 @@ class SnackgameBizController( @Authenticated member: Member, @PathVariable sessionId: Long, @RequestBody streaksRequest: StreaksRequest - ): ResponseEntity { + ): ResponseEntity { val game = snackgameBizService.removeStreaks(member.id, sessionId, streaksRequest) - return game.let { - ResponseEntity - .status(HttpStatus.CREATED) - .body(it) - } ?: ResponseEntity.ok().build() + + return ResponseEntity + .status(HttpStatus.OK) + .body(game) } @Operation( diff --git a/src/main/java/com/snackgame/server/game/snackgame/biz/service/SnackgameBizService.kt b/src/main/java/com/snackgame/server/game/snackgame/biz/service/SnackgameBizService.kt index 308bb33..2cc1db2 100644 --- a/src/main/java/com/snackgame/server/game/snackgame/biz/service/SnackgameBizService.kt +++ b/src/main/java/com/snackgame/server/game/snackgame/biz/service/SnackgameBizService.kt @@ -38,15 +38,13 @@ class SnackgameBizService( } @Transactional - fun removeStreaks(memberId: Long, sessionId: Long, streaks: StreaksRequest): SnackgameResponse? { + fun removeStreaks(memberId: Long, sessionId: Long, streaksRequest: StreaksRequest): SnackgameResponse { val game = snackGameBizRepository.getBy(memberId, sessionId) - val previous = game.board - streaks.toStreaks() + streaksRequest.toStreaks() .forEach { game.remove(it) } return SnackgameResponse.of(game) - .takeIf { game.board != previous } } @Transactional diff --git a/src/main/java/com/snackgame/server/game/snackgame/core/controller/SnackgameController.kt b/src/main/java/com/snackgame/server/game/snackgame/core/controller/SnackgameController.kt index 3d01ac3..df49190 100644 --- a/src/main/java/com/snackgame/server/game/snackgame/core/controller/SnackgameController.kt +++ b/src/main/java/com/snackgame/server/game/snackgame/core/controller/SnackgameController.kt @@ -63,13 +63,11 @@ class SnackgameController( @Authenticated member: Member, @PathVariable sessionId: Long, @RequestBody streaksRequest: StreaksRequest - ): ResponseEntity { + ): ResponseEntity { val game = snackgameService.removeStreaks(member.id, sessionId, streaksRequest) - return game.let { - ResponseEntity - .status(HttpStatus.CREATED) - .body(it) - } ?: ResponseEntity.ok().build() + return ResponseEntity + .status(HttpStatus.OK) + .body(game) } @Operation( diff --git a/src/main/java/com/snackgame/server/game/snackgame/core/service/SnackgameService.kt b/src/main/java/com/snackgame/server/game/snackgame/core/service/SnackgameService.kt index 3cab1e5..bacc1a9 100644 --- a/src/main/java/com/snackgame/server/game/snackgame/core/service/SnackgameService.kt +++ b/src/main/java/com/snackgame/server/game/snackgame/core/service/SnackgameService.kt @@ -38,15 +38,13 @@ class SnackgameService( } @Transactional - fun removeStreaks(memberId: Long, sessionId: Long, streaks: StreaksRequest): SnackgameResponse? { + fun removeStreaks(memberId: Long, sessionId: Long, streaksRequest: StreaksRequest): SnackgameResponse { val game = snackGameRepository.getBy(memberId, sessionId) - val previous = game.board - streaks.toStreaks() + streaksRequest.toStreaks() .forEach { game.remove(it) } return SnackgameResponse.of(game) - .takeIf { game.board != previous } } @Transactional