Skip to content

Commit

Permalink
Merge pull request #188 from softeerbootcamp4th/docs/#187-Lottery-swa…
Browse files Browse the repository at this point in the history
…gger

docs/#187-Lottery-swagger
  • Loading branch information
k000927 authored Aug 20, 2024
2 parents 66d336c + c64d4fa commit 84eca76
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
Expand All @@ -23,6 +24,7 @@

import java.util.List;

@Tag(name = "관리자 API", description = "관리자 관련 API 목록입니다.")
@RestController
@RequestMapping("/admin")
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import JGS.CasperEvent.domain.event.service.redisService.RedisService;
import JGS.CasperEvent.domain.event.service.eventService.LotteryEventService;
import JGS.CasperEvent.global.entity.BaseUser;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -22,6 +26,7 @@
import java.security.NoSuchAlgorithmException;
import java.util.List;

@Tag(name = "추첨 이벤트 API", description = "추첨 이벤트 (Lottery Event) 관련 API 목록입니다.")
@RestController
@RequestMapping("/event/lottery")
public class LotteryEventController {
Expand All @@ -35,15 +40,25 @@ public LotteryEventController(LotteryEventService lotteryEventService, RedisServ
this.redisService = redisService;
}

// 추첨 이벤트 조회 API
@Operation(summary = "추첨 이벤트 조회", description = "현재 진행 중인 추첨 이벤트의 정보를 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Lottery event retrieval successful"),
@ApiResponse(responseCode = "404", description = "No lottery event found in the database"),
@ApiResponse(responseCode = "409", description = "More than one lottery event exists in the database")
})
@GetMapping
public ResponseEntity<LotteryEventResponseDto> getLotteryEvent(){
public ResponseEntity<LotteryEventResponseDto> getLotteryEvent() {
return ResponseEntity
.status(HttpStatus.OK)
.body(lotteryEventService.getLotteryEvent());
}

// 캐스퍼 봇 생성 API
@Operation(summary = "캐스퍼 봇 생성", description = "새로운 캐스퍼 봇을 생성합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Casper bot creation successful"),
@ApiResponse(responseCode = "404", description = "No lottery event found in the database"),
@ApiResponse(responseCode = "409", description = "More than one lottery event exists in the database")
})
@PostMapping("/casperBot")
public ResponseEntity<CasperBotResponseDto> postCasperBot(
HttpServletRequest request,
Expand All @@ -54,7 +69,11 @@ public ResponseEntity<CasperBotResponseDto> postCasperBot(
.body(lotteryEventService.postCasperBot(user, postCasperBot));
}

// 응모 여부 조회 API
@Operation(summary = "응모 여부 조회", description = "현재 사용자의 응모 여부를 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Application status retrieval successful"),
@ApiResponse(responseCode = "404", description = "User has not applied")
})
@GetMapping("/applied")
public ResponseEntity<LotteryParticipantResponseDto> GetLotteryParticipant(HttpServletRequest request) throws UserPrincipalNotFoundException {
BaseUser user = (BaseUser) request.getAttribute("user");
Expand All @@ -63,7 +82,10 @@ public ResponseEntity<LotteryParticipantResponseDto> GetLotteryParticipant(HttpS
.body(lotteryEventService.getLotteryParticipant(user));
}

// 최근 100개 캐스퍼 봇 조회
@Operation(summary = "최근 100개 캐스퍼 봇 조회", description = "최근에 생성된 100개의 캐스퍼 봇을 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Recent Casper bots retrieval successful")
})
@GetMapping("/caspers")
public ResponseEntity<List<CasperBotResponseDto>> getCasperBots() {
return ResponseEntity.status(HttpStatus.OK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ void setUp() throws Exception {
.sticker(0)
.name("name")
.expectation("expectation")
.referralId("QEszP1K8IqcapUHAVwikXA==").build();
.referralId("QEszP1K8IqcapUHAVwikXA==")
.build();

casperBot = new CasperBot(casperBotRequest, "010-0000-0000");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public void getRushEventResultTest() throws Exception {
.andExpect(jsonPath("$.rightOption").value(1000))
.andExpect(jsonPath("$.rank").value(1))
.andExpect(jsonPath("$.totalParticipants").value(1000))
.andExpect(jsonPath("$.winner").value(true))
.andExpect(jsonPath("$.isWinner").value(true))
.andDo(print());
}

Expand Down

0 comments on commit 84eca76

Please sign in to comment.