Skip to content

Commit

Permalink
[fix] 토너먼트 선물 0개일때 개설자 여부 반환
Browse files Browse the repository at this point in the history
  • Loading branch information
hysong4u committed Feb 16, 2024
1 parent b60fb94 commit 95a7d32
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import lombok.RequiredArgsConstructor;
import org.sopt.sweet.domain.gift.dto.request.CreateGiftRequestDto;
import org.sopt.sweet.domain.gift.dto.request.MyGiftsRequestDto;
import org.sopt.sweet.domain.gift.dto.request.TournamentScoreRequestDto;
import org.sopt.sweet.domain.gift.dto.response.*;
import org.sopt.sweet.domain.gift.service.GiftService;
import org.sopt.sweet.domain.member.service.MemberService;
import org.sopt.sweet.global.common.SuccessResponse;
import org.sopt.sweet.global.config.auth.UserId;
import org.springframework.http.ResponseEntity;
Expand All @@ -21,6 +21,7 @@
public class GiftController implements GiftApi {

private final GiftService giftService;
private final MemberService memberService;

@PostMapping
public ResponseEntity<SuccessResponse<?>> createNewGift(@UserId Long userId, @RequestBody CreateGiftRequestDto createGiftRequestDto) {
Expand All @@ -43,7 +44,12 @@ public ResponseEntity<SuccessResponse<?>> deleteMyGift(@UserId Long userId, @Pat

@GetMapping("/tournament/{roomId}")
public ResponseEntity<SuccessResponse<?>> getTournamentGiftList(@UserId Long userId, @PathVariable Long roomId) {
Boolean isOwner = memberService.isOwner(userId, roomId);
List<TournamentListsResponseDto> tournamentGiftList = giftService.getTournamentGiftList(userId, roomId);

if (tournamentGiftList.isEmpty()) {
return SuccessResponse.ok(new OwnerResponseDto(isOwner));
}
return SuccessResponse.ok(tournamentGiftList);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.sopt.sweet.domain.gift.dto.response;

public record OwnerResponseDto(
Boolean isOwner
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ public List<TournamentListsResponseDto> getTournamentGiftList(Long memberId, Lon
return mapGiftsToTournamentLists(gifts);
}



private List<TournamentListsResponseDto> mapGiftsToTournamentLists(List<Gift> gifts) {
return gifts.stream()
.map(gift -> TournamentListsResponseDto.of(gift.getId(), gift.getImageUrl(), gift.getName(), gift.getCost(), gift.getUrl()))
Expand Down

0 comments on commit 95a7d32

Please sign in to comment.