Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

[Bugfix] 스페이스가 끝난 경우 투표 목록을 가져오지 않도록 설정 #184

Merged
merged 2 commits into from
Jan 24, 2024
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
4 changes: 4 additions & 0 deletions app/src/main/java/fc/be/app/domain/space/entity/Space.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,8 @@ public String getSpaceTitle() {
return String.format("%s 외 %d명의 여행", joinedMemberList.get(0).getMember().getNickname(), joinedMemberList.size() - 1);
}

public boolean isClosed(LocalDate localDate) {
return this.endDate.isBefore(localDate);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface VoteController {
)
@PostMapping
ApiResponse<String> createNewVote(
@Valid VoteCreateApiRequest request,
@Valid @RequestBody VoteCreateApiRequest request,
@AuthenticationPrincipal UserPrincipal userPrincipal
);

Expand All @@ -46,7 +46,7 @@ ApiResponse<String> createNewVote(
@PostMapping("/{voteId}/candidates")
ApiResponse<VoteDetailResponse> addCandidate(
@PathVariable Long voteId,
CandidateAddApiRequest request,
@Valid @RequestBody CandidateAddApiRequest request,
@AuthenticationPrincipal UserPrincipal userPrincipal
);

Expand Down Expand Up @@ -162,4 +162,16 @@ ApiResponse<Void> resetVote(
@PathVariable Long voteId,
@AuthenticationPrincipal UserPrincipal userPrincipal
);


@Operation(
operationId = "show vote not voting",
summary = "아직 참여하지 않은 투표 목록을 보여준다.",
description = "본인이 속한 스페이스 내 아직 참여하지 않은 투표 목록을 보여주는 API 입니다.",
security = {
@SecurityRequirement(name = "ACCESS_TOKEN", scopes = {"write:votes"})
}
)
@GetMapping("/notVoted")
ApiResponse<VotesResponse> notVotedList(@AuthenticationPrincipal UserPrincipal userPrincipal);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public VoteControllerImpl(

@PostMapping
public ApiResponse<String> createNewVote(
@Valid VoteCreateApiRequest request,
@Valid @RequestBody VoteCreateApiRequest request,
@AuthenticationPrincipal UserPrincipal userPrincipal
) {
return ApiResponse.created(VOTE_API_PREFIX + voteManageService.createVote(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.Comparator;
import java.util.List;

Expand Down Expand Up @@ -89,6 +90,7 @@ public VotesResponse findMemberVotes(Long memberId) {

return new VotesResponse(votesNotMemberVoted
.stream()
.filter(vote -> vote.getSpace().isClosed(LocalDate.now()))
.map(vote -> new VotesResponseElement(
vote.getId(),
vote.getTitle(),
Expand Down