-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
241 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 2 additions & 14 deletions
16
src/main/java/com/softeer/backend/fo_domain/draw/dto/main/DrawMainFullAttendResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,11 @@ | ||
package com.softeer.backend.fo_domain.draw.dto.main; | ||
|
||
import lombok.AllArgsConstructor; | ||
import com.softeer.backend.fo_domain.draw.dto.modal.WinModal; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Data | ||
@SuperBuilder | ||
public class DrawMainFullAttendResponseDto extends DrawMainResponseDto { | ||
private DrawMainFullAttendResponseDto.FullAttendModal fullAttendModal; | ||
|
||
@Data | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class FullAttendModal { | ||
private String title; // 제목 | ||
private String subtitle; // 부제목 | ||
private String image; // 이미지 URL (S3 URL) | ||
private String description; // 설명 | ||
} | ||
private WinModal fullAttendModal; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/softeer/backend/fo_domain/draw/dto/modal/WinModal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.softeer.backend.fo_domain.draw.dto.modal; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
@Builder | ||
public class WinModal { | ||
private String title; // 제목 | ||
private String subtitle; // 부제목 | ||
private String img; // 이미지 URL (S3 URL) | ||
private String description; // 설명 | ||
} |
16 changes: 2 additions & 14 deletions
16
...main/java/com/softeer/backend/fo_domain/draw/dto/participate/DrawWinModalResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,11 @@ | ||
package com.softeer.backend.fo_domain.draw.dto.participate; | ||
|
||
import lombok.AllArgsConstructor; | ||
import com.softeer.backend.fo_domain.draw.dto.modal.WinModal; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Data | ||
@SuperBuilder | ||
public class DrawWinModalResponseDto extends DrawModalResponseDto { | ||
private DrawWinModalResponseDto.WinModal winModal; | ||
|
||
@Data | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class WinModal { | ||
private String title; // 제목 | ||
private String subtitle; // 부제목 | ||
private String img; // 이미지 URL (S3 URL) | ||
private String description; // 설명 | ||
} | ||
private WinModal winModal; | ||
} |
16 changes: 2 additions & 14 deletions
16
...main/java/com/softeer/backend/fo_domain/draw/dto/result/DrawHistoryWinnerResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,11 @@ | ||
package com.softeer.backend.fo_domain.draw.dto.result; | ||
|
||
import lombok.AllArgsConstructor; | ||
import com.softeer.backend.fo_domain.draw.dto.modal.WinModal; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Data | ||
@SuperBuilder | ||
public class DrawHistoryWinnerResponseDto extends DrawHistoryResponseDto { | ||
private DrawHistoryWinnerResponseDto.WinModal winModal; | ||
|
||
@Data | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class WinModal { | ||
private String title; // 제목 | ||
private String subtitle; // 부제목 | ||
private String img; // 이미지 URL (S3 URL) | ||
private String description; // 설명 | ||
} | ||
private WinModal winModal; | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/com/softeer/backend/fo_domain/draw/interceptor/DrawTimeCheckInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.softeer.backend.fo_domain.draw.interceptor; | ||
|
||
import com.softeer.backend.fo_domain.draw.exception.DrawException; | ||
import com.softeer.backend.fo_domain.draw.service.DrawSettingManager; | ||
import com.softeer.backend.global.common.code.status.ErrorStatus; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.cors.CorsUtils; | ||
import org.springframework.web.servlet.HandlerInterceptor; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class DrawTimeCheckInterceptor implements HandlerInterceptor { | ||
private final DrawSettingManager drawSettingManager; | ||
|
||
@Override | ||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { | ||
if (CorsUtils.isPreFlightRequest(request)) | ||
return true; | ||
|
||
if (!isAvailableTime()) { | ||
throw new DrawException(ErrorStatus._BAD_REQUEST); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* 참가 가능한 시간인지 확인 | ||
* @return 참가 가능하면 true, 불가능하면 false 반환 | ||
*/ | ||
private boolean isAvailableTime() { | ||
LocalDateTime now = LocalDateTime.now(); | ||
|
||
return compareDate(now) && compareTime(now); | ||
} | ||
|
||
/** | ||
* 날짜 비교 | ||
* @param now 현재시각 | ||
* @return 참가 가능한 날짜이면 true, 불가능하면 false 반환 | ||
*/ | ||
private boolean compareDate(LocalDateTime now) { | ||
LocalDateTime startDateTime = drawSettingManager.getStartDate().atStartOfDay(); | ||
LocalDateTime endDateTime = drawSettingManager.getEndDate().atStartOfDay(); | ||
|
||
return now.isAfter(startDateTime) && now.isBefore(endDateTime); | ||
} | ||
|
||
/** | ||
* 시간 비교 | ||
* @param now 현재 시각 | ||
* @return 참가 가능한 시간이면 true, 불가능하면 false 반환 | ||
*/ | ||
private boolean compareTime(LocalDateTime now) { | ||
LocalDate nowDate = now.toLocalDate(); | ||
LocalDateTime startTimeAsDateTime = LocalDateTime.of(nowDate, drawSettingManager.getStartTime()); | ||
LocalDateTime endTimeAsDateTime = LocalDateTime.of(nowDate, drawSettingManager.getEndTime()); | ||
|
||
return (now.isAfter(startTimeAsDateTime) && now.isBefore(endTimeAsDateTime)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.