Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Deploy to Amazon Linux EC2 (compose-prod)
on:
push:
branches: [ main ] # main 브랜치 푸시 시 배포
pull_request:
branches: [ main ]
workflow_dispatch: {}

jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import likelion.mlb.backendProject.domain.draft.dto.DraftResponse;
import likelion.mlb.backendProject.domain.draft.service.DraftService;

import likelion.mlb.backendProject.global.security.dto.CustomUserDetails;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

Expand Down Expand Up @@ -63,8 +65,10 @@ public List<DraftResponse> getPlayersByParticipantId(@PathVariable("participantI
*/
@GetMapping("/{draftId}/participants")
@ResponseBody
public List<DraftParticipant> getParticipantsByDraftId(@PathVariable("draftId") UUID draftId) {
return draftService.getParticipantsByDraftId(draftId);
public List<DraftParticipant> getParticipantsByDraftId(@PathVariable("draftId") UUID draftId
, @AuthenticationPrincipal CustomUserDetails userDetails) {
String userEmail = userDetails.getUser().getEmail();
return draftService.getParticipantsByDraftId(draftId, userEmail);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ public class DraftParticipant {

private String userName; // 참여자명

private boolean userFlag = false; // 사용자 본인 여부

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ public List<DraftResponse> getPlayersByParticipantId(UUID participantId) {
return ParticipantPlayer.toDtoList(playerList);
}

public List<DraftParticipant> getParticipantsByDraftId(UUID draftId) {
public List<DraftParticipant> getParticipantsByDraftId(UUID draftId, String userEmail) {
Draft draft = draftRepository.findById(draftId)
.orElseThrow(() -> new IllegalStateException("Draft not found by draftId " + draftId));

return Participant.toDtoList(participantRepository.findByDraft(draft));
return Participant.toDtoList(participantRepository.findByDraft(draft), userEmail);
}

public List<DraftResponse> getAllPlayersByDraftId(UUID draftId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,52 @@
@AllArgsConstructor
public class Participant {

@Id
@Column(name = "id", nullable = false)
private UUID id;
@Id
@Column(name = "id", nullable = false)
private UUID id;

@Column(name = "user_number", nullable = false)
private short userNumber;
@Column(name = "user_number", nullable = false)
private short userNumber;

@Column(name = "is_dummy", nullable = false)
private boolean dummy;
@Column(name = "is_dummy", nullable = false)
private boolean dummy;

@Column(name = "score", nullable = false)
private Integer score = 0;
@Column(name = "score", nullable = false)
private Integer score = 0;

@Column(name = "rank")
private Integer rank;
@Column(name = "rank")
private Integer rank;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "draft_id", nullable = false)
private Draft draft;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "draft_id", nullable = false)
private Draft draft;

public void updateRank(int leaguePoint, int rank) {
public void updateRank(int leaguePoint, int rank) {
this.score = leaguePoint;
this.rank = rank;
}

}
/**
* Participant 엔티티 리스트 → DraftParticipant 리스트 변환
*/
public static List<DraftParticipant> toDtoList(List<Participant> participants, String userEmail) {

/**
* Participant 엔티티 리스트 → DraftParticipant 리스트 변환
*/
public static List<DraftParticipant> toDtoList(List<Participant> participants) {
return participants.stream().map(p -> DraftParticipant.builder()

return participants.stream().map(p -> DraftParticipant.builder()
.participantId(p.getId())
.participantUserNumber(p.getUserNumber())
.participantDummy(p.isDummy())

.participantId(p.getId())
.participantUserNumber(p.getUserNumber())
.participantDummy(p.isDummy())
.userEmail(p.getUser() != null ? p.getUser().getEmail() : null)
.userName(p.getUser() != null ? p.getUser().getName() : null)

.userEmail(p.getUser() != null ? p.getUser().getEmail() : null)
.userName(p.getUser() != null ? p.getUser().getName() : null)
.userFlag(p.getUser() != null && p.getUser().getEmail().equals(userEmail) ? true : false)
.build()
).collect(Collectors.toList());
}

.build()
).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ public class ElementTypeDto {
// 선수 포지션 한글명
private String krName = "";

// 베스트 일레븐에서 해당 포지션을 뽑아야 하는 최소 수
private Integer squadMinPlay;

// 베스트 일레븐에서 해당 포지션을 뽑아야 하는 최대 수
private Integer squadMaxPlay;

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public static List<ElementTypeDto> toDtoList(List<ElementType> elementTypes) {
.fplId(e.getFplId()) // fpl의 각 포지션별 id
.pluralName(e.getPluralName()) //ex) Goalkeepers, Defenders, fpl에서 받아오는 영어 이름
.krName(e.getKrName()) // 선수 포지션 한글명
.squadMinPlay(e.getSquadMinPlay()) // 베스트 일레븐에서 해당 포지션을 뽑아야 하는 최소 수
.squadMaxPlay(e.getSquadMaxPlay()) // 베스트 일레븐에서 해당 포지션을 뽑아야 하는 최대 수
.build()
).collect(Collectors.toList());
}
Expand Down