Skip to content

Commit

Permalink
Merge pull request #212 from softeerbootcamp4th/refactor/#207-refactor
Browse files Browse the repository at this point in the history
Refactor/#207 refactor
  • Loading branch information
wjddn2165 authored Aug 21, 2024
2 parents b27f832 + b4bac0d commit fe7937e
Show file tree
Hide file tree
Showing 32 changed files with 298 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import JGS.CasperEvent.domain.event.dto.ResponseDto.TotalEventDateResponseDto;
import JGS.CasperEvent.domain.event.service.eventService.EventService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -19,6 +20,8 @@ public class EventController {
@GetMapping("/total")
public ResponseEntity<TotalEventDateResponseDto> getTotalEventDate() {
TotalEventDateResponseDto totalEventDateResponseDto = eventService.getTotalEventDate();
return ResponseEntity.ok(totalEventDateResponseDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(totalEventDateResponseDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public ResponseEntity<CasperBotResponseDto> postCasperBot(
@ApiResponse(responseCode = "404", description = "User has not applied")
})
@GetMapping("/applied")
public ResponseEntity<LotteryParticipantResponseDto> GetLotteryParticipant(HttpServletRequest request) {
public ResponseEntity<LotteryParticipantResponseDto> getLotteryParticipant(HttpServletRequest request) {
BaseUser user = (BaseUser) request.getAttribute("user");
return ResponseEntity
.status(HttpStatus.OK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand All @@ -26,15 +27,19 @@ public RushEventController(RushEventService rushEventService) {
@ApiResponse(responseCode = "200", description = "Successfully retrieved the list of rush events.")
@GetMapping
public ResponseEntity<RushEventListResponseDto> getRushEventListAndServerTime() {
return ResponseEntity.ok(rushEventService.getAllRushEvents());
return ResponseEntity
.status(HttpStatus.OK)
.body(rushEventService.getAllRushEvents());
}

@Operation(summary = "응모 여부 체크", description = "해당 유저가 오늘의 이벤트에 응모했는지 여부를 조회합니다.")
@ApiResponse(responseCode = "200", description = "Successfully checked user participation.")
@GetMapping("/applied")
public ResponseEntity<Boolean> checkUserParticipationInRushEvent(HttpServletRequest httpServletRequest) {
BaseUser user = (BaseUser) httpServletRequest.getAttribute("user");
return ResponseEntity.ok(rushEventService.isExists(user.getId()));
return ResponseEntity
.status(HttpStatus.OK)
.body(rushEventService.isExists(user.getId()));
}

@Operation(summary = "선착순 이벤트 응모", description = "해당 유저가 오늘의 이벤트에 응모합니다. optionId 값이 필요합니다. optionId 값이 1이면 왼쪽 선택지, 2이면 오른쪽 선택지에 응모합니다.")
Expand All @@ -48,7 +53,9 @@ public ResponseEntity<Void> applyRushEvent(HttpServletRequest httpServletRequest
BaseUser user = (BaseUser) httpServletRequest.getAttribute("user");
rushEventService.apply(user, optionId);

return ResponseEntity.noContent().build();
return ResponseEntity
.status(HttpStatus.NO_CONTENT)
.build();
}

@Operation(summary = "실시간 응모 비율 조회", description = "실시간으로 변경되는 응모 비율을 조회합니다.")
Expand All @@ -57,7 +64,9 @@ public ResponseEntity<Void> applyRushEvent(HttpServletRequest httpServletRequest
public ResponseEntity<RushEventRateResponseDto> rushEventRate(HttpServletRequest httpServletRequest) {
BaseUser user = (BaseUser) httpServletRequest.getAttribute("user");
RushEventRateResponseDto rushEventRateResponseDto = rushEventService.getRushEventRate(user);
return ResponseEntity.ok(rushEventRateResponseDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(rushEventRateResponseDto);
}

@Operation(summary = "선착순 이벤트 결과를 조회합니다.", description = "이벤트가 끝나고 나서 최종 결과를 조회합니다.")
Expand All @@ -66,23 +75,29 @@ public ResponseEntity<RushEventRateResponseDto> rushEventRate(HttpServletRequest
public ResponseEntity<RushEventResultResponseDto> rushEventResult(HttpServletRequest httpServletRequest) {
BaseUser user = (BaseUser) httpServletRequest.getAttribute("user");
RushEventResultResponseDto result = rushEventService.getRushEventResult(user);
return ResponseEntity.ok(result);
return ResponseEntity
.status(HttpStatus.OK)
.body(result);
}

@Operation(summary = "오늘의 이벤트를 초기화합니다.", description = "오늘의 이벤트를 전부 초기화하고, 응모 여부도 전부 초기화합니다.")
@ApiResponse(responseCode = "204", description = "Successfully set today's event in Redis.")
@GetMapping("/today/test")
public ResponseEntity<Void> setTodayEvent() {
rushEventService.setRushEvents();
return ResponseEntity.noContent().build();
return ResponseEntity
.status(HttpStatus.NO_CONTENT)
.build();
}

@Operation(summary = "오늘의 이벤트 옵션을 조회합니다.", description = "이벤트 참여자가 이벤트에 진입했을 때 보여질 옵션 선택지 정보를 조회합니다.")
@ApiResponse(responseCode = "200", description = "Successfully retrieved today's rush event options.")
@GetMapping("/today")
public ResponseEntity<MainRushEventOptionsResponseDto> getTodayEvent() {
MainRushEventOptionsResponseDto mainRushEventOptionsResponseDto = rushEventService.getTodayRushEventOptions();
return ResponseEntity.ok(mainRushEventOptionsResponseDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(mainRushEventOptionsResponseDto);
}

@Operation(summary = "옵션의 결과 Text를 조회합니다.", description = "유저가 응모를 했을 때 보여질 옵션의 상세 Text를 조회합니다.")
Expand All @@ -93,6 +108,8 @@ public ResponseEntity<MainRushEventOptionsResponseDto> getTodayEvent() {
@GetMapping("/options/{optionId}/result")
public ResponseEntity<ResultRushEventOptionResponseDto> getResultOption(@PathVariable("optionId") int optionId) {
ResultRushEventOptionResponseDto resultRushEventOptionResponseDto = rushEventService.getRushEventOptionResult(optionId);
return ResponseEntity.ok(resultRushEventOptionResponseDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(resultRushEventOptionResponseDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
public class AdminRequestDto {

@NotNull
@Schema(description = "관리자 아이디", example = "adminId", required = true)
@Schema(description = "관리자 아이디", example = "adminId")
private String adminId;

@NotNull
@Schema(description = "관리자 인증을 위한 비밀번호", example = "password", required = true)
@Schema(description = "관리자 인증을 위한 비밀번호", example = "password")
private String password;

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ public class CasperBotRequestDto {
@NotNull(message = "눈 모양 값은 필수 필드입니다.")
@Min(value = 0, message = "눈 모양 값이 부적절합니다.")
@Max(value = 7, message = "눈 모양 값이 부적절합니다.")
@Schema(description = "눈 모양 값", example = "1", required = true)
@Schema(description = "눈 모양 값", example = "1")
private Integer eyeShape;

@NotNull(message = "눈 위치 값은 필수 필드입니다.")
@Min(value = 0, message = "눈 위치 값이 부적절합니다.")
@Max(value = 2, message = "눈 위치 값이 부적절합니다.")
@Schema(description = "눈 위치 값", example = "1", required = true)
@Schema(description = "눈 위치 값", example = "1")
private Integer eyePosition;

@NotNull(message = "입 모양 값은 필수 필드입니다.")
@Min(value = 0, message = "입 모양 값이 부적절합니다.")
@Max(value = 4, message = "입 모양 값이 부적절합니다.")
@Schema(description = "입 모양 값", example = "2", required = true)
@Schema(description = "입 모양 값", example = "2")
private Integer mouthShape;

@NotNull(message = "색깔 값은 필수 필드입니다.")
@Min(value = 0, message = "색깔 값이 부적절합니다.")
@Max(value = 17, message = "색깔 값이 부적절합니다.")
@Schema(description = "색깔 값", example = "8", required = true)
@Schema(description = "색깔 값", example = "8")
private Integer color;

@NotNull(message = "스티커 값은 필수 필드입니다.")
@Min(value = 0, message = "스티커 값이 부적절합니다.")
@Max(value = 4, message = "스티커 값이 부적절합니다.")
@Schema(description = "스티커 값", example = "1", required = true)
@Schema(description = "스티커 값", example = "1")
private Integer sticker;

@NotNull(message = "이름은 필수 필드입니다.")
@Schema(description = "캐스퍼 봇의 이름", example = "MyCasperBot", required = true)
@Schema(description = "캐스퍼 봇의 이름", example = "MyCasperBot")
private String name;

@Schema(description = "기대평", example = "캐스퍼 정말 기대되요!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
public class LotteryEventRequestDto {

@NotNull(message = "이벤트 시작 날짜를 지정하세요.")
@Schema(description = "이벤트의 시작 날짜", example = "2024-09-01", required = true)
@Schema(description = "이벤트의 시작 날짜", example = "2024-09-01")
private LocalDate startDate;

@NotNull(message = "이벤트 시작 시간을 지정하세요.")
@Schema(description = "이벤트의 시작 시간", example = "14:00:00", required = true)
@Schema(description = "이벤트의 시작 시간", example = "14:00:00")
private LocalTime startTime;

@NotNull(message = "이벤트 종료 날짜를 지정하세요.")
@Schema(description = "이벤트의 종료 날짜", example = "2024-09-30", required = true)
@Schema(description = "이벤트의 종료 날짜", example = "2024-09-30")
private LocalDate endDate;

@NotNull(message = "이벤트 종료 시간을 지정하세요.")
@Schema(description = "이벤트의 종료 시간", example = "18:00:00", required = true)
@Schema(description = "이벤트의 종료 시간", example = "18:00:00")
private LocalTime endTime;

@NotNull(message = "당첨인원 수를 지정하세요.")
@Schema(description = "당첨 인원 수", example = "10", required = true)
@Schema(description = "당첨 인원 수", example = "10")
private int winnerCount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,4 @@

public record MainRushEventOptionsResponseDto(MainRushEventOptionResponseDto leftOption,
MainRushEventOptionResponseDto rightOption) {

public MainRushEventOptionsResponseDto(MainRushEventOptionResponseDto leftOption, MainRushEventOptionResponseDto rightOption) {
this.leftOption = leftOption;
this.rightOption = rightOption;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package JGS.CasperEvent.domain.event.entity.admin;

import JGS.CasperEvent.global.entity.BaseEntity;
import JGS.CasperEvent.global.entity.BaseUser;
import JGS.CasperEvent.global.enums.Role;
import jakarta.persistence.Entity;
import lombok.EqualsAndHashCode;
import lombok.Getter;

@Entity
@Getter
@EqualsAndHashCode(callSuper = false)
public class Admin extends BaseUser {
private String password;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CasperBotRepository extends JpaRepository<CasperBot, Long> {
@Query("SELECT c FROM CasperBot c WHERE c.phoneNumber = :phoneNumber AND c.isDeleted = false AND c.expectation <> ''")
Expand Down
Loading

0 comments on commit fe7937e

Please sign in to comment.