Skip to content

Commit

Permalink
Merge pull request #123 from SWEET-DEVELOPERS/feature/#122-gift
Browse files Browse the repository at this point in the history
[feat] #122 tournament 종료 API 구현
  • Loading branch information
hysong4u authored Feb 29, 2024
2 parents f5b7930 + f862889 commit 46ea69c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ public ResponseEntity<SuccessResponse<?>> getRanking(@PathVariable Long roomId)
return SuccessResponse.ok(ranking);
}

@PostMapping("/tournament-end/{roomId}")
public ResponseEntity<SuccessResponse<?>> endTournament(@UserId Long userId, @PathVariable Long roomId) {
giftService.endTournament(roomId);
return SuccessResponse.created(null);
}




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,12 @@ public String getGifteeName(Long roomId) {
return gifteeName;
}

public void endTournament(Long roomId) {
Room room = findRoomByIdOrThrow(roomId);
TournamentDuration tournamentDuration = room.getTournamentDuration();
LocalDateTime newStartDate = LocalDateTime.now().minusHours(tournamentDuration.getHours());
room.setTournamentStartDate(newStartDate);

}

}
3 changes: 3 additions & 0 deletions src/main/java/org/sopt/sweet/domain/room/entity/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,7 @@ public void setImageUrl(String imageUrl) {
public void setGifteeName(String gifteeName) {
this.gifteeName = gifteeName;
}

public void setTournamentStartDate(LocalDateTime tournamentStartDate) { this.tournamentStartDate = tournamentStartDate;
}
}

0 comments on commit 46ea69c

Please sign in to comment.