Skip to content

Commit

Permalink
Merge branch 'dev' into feat/register-notification-devices
Browse files Browse the repository at this point in the history
  • Loading branch information
0chil committed Oct 17, 2024
2 parents 94fb9ea + a81ae45 commit bc11a71
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ class SnackgameBizController(
@Authenticated member: Member,
@PathVariable sessionId: Long,
@RequestBody streaksRequest: StreaksRequest
): ResponseEntity<SnackgameResponse?> {
): ResponseEntity<SnackgameResponse> {
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ class SnackgameController(
@Authenticated member: Member,
@PathVariable sessionId: Long,
@RequestBody streaksRequest: StreaksRequest
): ResponseEntity<SnackgameResponse?> {
): ResponseEntity<SnackgameResponse> {
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bc11a71

Please sign in to comment.