Skip to content

Commit 36dc6e5

Browse files
authored
Merge pull request #15 from DevKor-github/dev
feat: get /votes/share/{code} 추가
2 parents b500c49 + d5ce28b commit 36dc6e5

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/main/java/com/workingdead/meet/controller/VoteController.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public VoteController(VoteService voteService, ParticipantRepository participant
2626
}
2727

2828

29-
3029
@Operation(
3130
summary = "투표 목록 조회",
3231
description = "모든 투표 목록을 조회합니다. 각 투표의 기본 정보(id, name, code, adminUrl, shareUrl, startDate, endDate)를 반환합니다." +
@@ -44,6 +43,20 @@ public VoteController(VoteService voteService, ParticipantRepository participant
4443
@GetMapping("/{id}")
4544
public VoteDtos.VoteDetail get(@PathVariable Long id) { return voteService.get(id); }
4645

46+
@Operation(
47+
summary = "공유 코드로 투표 조회",
48+
description = "공유 URL의 코드를 통해 투표 정보를 조회합니다. 참여자가 투표에 접근할 때 사용됩니다."
49+
)
50+
@ApiResponses({
51+
@ApiResponse(responseCode = "200", description = "조회 성공",
52+
content = @Content(schema = @Schema(implementation = VoteDtos.VoteDetail.class))),
53+
@ApiResponse(responseCode = "404", description = "투표를 찾을 수 없음", content = @Content)
54+
})
55+
@GetMapping("/share/{code}")
56+
public ResponseEntity<VoteDtos.VoteDetail> getByShareCode(@PathVariable String code) {
57+
VoteDtos.VoteDetail vote = voteService.getByCode(code);
58+
return ResponseEntity.ok(vote);
59+
}
4760

4861
@Operation(
4962
summary = "새 투표 생성",

src/main/java/com/workingdead/meet/service/VoteService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ public VoteDtos.VoteDetail get(Long id) {
6565
return toDetail(v);
6666
}
6767

68+
public VoteDtos.VoteDetail getByCode(String code) {
69+
Vote v = voteRepo.findByCode(code)
70+
.orElseThrow(() -> new NoSuchElementException("vote not found with code: " + code));
71+
return toDetail(v);
72+
}
73+
6874

6975
public VoteDtos.VoteDetail update(Long id, VoteDtos.UpdateVoteReq req) {
7076
Vote v = voteRepo.findById(id).orElseThrow(() -> new NoSuchElementException("vote not found"));

0 commit comments

Comments
 (0)