-
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.
Browse files
Browse the repository at this point in the history
…notation refactor: request dto에서 validation을 진행할 수 있도록 변경
- Loading branch information
Showing
25 changed files
with
102 additions
and
95 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
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
3 changes: 3 additions & 0 deletions
3
src/main/java/sopt/org/hmh/domain/app/dto/request/AppRemoveRequest.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,6 +1,9 @@ | ||
package sopt.org.hmh.domain.app.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record AppRemoveRequest( | ||
@NotNull(message = "앱 코드는 null일 수 없습니다.") | ||
String appCode | ||
) { | ||
} |
3 changes: 2 additions & 1 deletion
3
src/main/java/sopt/org/hmh/domain/app/dto/request/ChallengeAppArrayRequest.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,8 +1,9 @@ | ||
package sopt.org.hmh.domain.app.dto.request; | ||
|
||
import jakarta.validation.Valid; | ||
import java.util.List; | ||
|
||
public record ChallengeAppArrayRequest( | ||
List<ChallengeAppRequest> apps | ||
List<@Valid ChallengeAppRequest> apps | ||
) { | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/sopt/org/hmh/domain/app/dto/request/ChallengeAppRequest.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,7 +1,19 @@ | ||
package sopt.org.hmh.domain.app.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import sopt.org.hmh.domain.app.domain.AppConstants; | ||
import sopt.org.hmh.domain.app.domain.exception.AppError; | ||
import sopt.org.hmh.domain.app.domain.exception.AppException; | ||
|
||
public record ChallengeAppRequest( | ||
@NotNull(message = "앱 코드는 null일 수 없습니다.") | ||
String appCode, | ||
@NotNull(message = "앱 시간은 null일 수 없습니다.") | ||
Long goalTime | ||
) { | ||
public ChallengeAppRequest { | ||
if (goalTime > AppConstants.MAXIMUM_APP_TIME || goalTime < AppConstants.MINIMUM_APP_TIME) { | ||
throw new AppException(AppError.INVALID_GOAL_TIME); | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/sopt/org/hmh/domain/app/dto/request/HistoryAppRequest.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,7 +1,11 @@ | ||
package sopt.org.hmh.domain.app.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record HistoryAppRequest( | ||
@NotNull(message = "앱 코드는 null일 수 없습니다.") | ||
String appCode, | ||
@NotNull(message = "앱 사용시간은 null일 수 없습니다.") | ||
Long usageTime | ||
) { | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/main/java/sopt/org/hmh/domain/auth/dto/request/SocialSignUpRequest.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,15 +1,23 @@ | ||
package sopt.org.hmh.domain.auth.dto.request; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotNull; | ||
import sopt.org.hmh.domain.challenge.dto.request.ChallengeRequest; | ||
import sopt.org.hmh.domain.challenge.dto.request.ChallengeSignUpRequest; | ||
import sopt.org.hmh.global.auth.social.SocialPlatform; | ||
|
||
public record SocialSignUpRequest( | ||
@NotNull(message = "소셜 플랫폼은 null일 수 없습니다.") | ||
SocialPlatform socialPlatform, | ||
String name, | ||
@JsonProperty(value = "onboarding") | ||
OnboardingRequest onboardingRequest, | ||
@Valid | ||
@JsonProperty(value = "challenge") | ||
ChallengeSignUpRequest challengeSignUpRequest | ||
) { | ||
public ChallengeRequest toChallengeRequest() { | ||
return new ChallengeRequest(challengeSignUpRequest.period(), challengeSignUpRequest.goalTime()); | ||
} | ||
} |
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
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
18 changes: 0 additions & 18 deletions
18
src/main/java/sopt/org/hmh/domain/challenge/domain/ChallengeDay.java
This file was deleted.
Oops, something went wrong.
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
10 changes: 10 additions & 0 deletions
10
src/main/java/sopt/org/hmh/domain/challenge/dto/request/ChallengeDateRequest.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,10 @@ | ||
package sopt.org.hmh.domain.challenge.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import java.time.LocalDate; | ||
|
||
public record ChallengeDateRequest( | ||
@NotNull(message = "챌린지 날짜는 null일 수 없습니다.") | ||
LocalDate challengeDate | ||
) { | ||
} |
21 changes: 20 additions & 1 deletion
21
src/main/java/sopt/org/hmh/domain/challenge/dto/request/ChallengeRequest.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,7 +1,26 @@ | ||
package sopt.org.hmh.domain.challenge.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import sopt.org.hmh.domain.app.domain.AppConstants; | ||
import sopt.org.hmh.domain.app.domain.exception.AppError; | ||
import sopt.org.hmh.domain.app.domain.exception.AppException; | ||
import sopt.org.hmh.domain.challenge.domain.ChallengeConstants; | ||
import sopt.org.hmh.domain.challenge.domain.exception.ChallengeError; | ||
import sopt.org.hmh.domain.challenge.domain.exception.ChallengeException; | ||
|
||
public record ChallengeRequest( | ||
@NotNull(message = "챌린지 기간은 null일 수 없습니다.") | ||
Integer period, | ||
@NotNull(message = "챌린지 목표시간은 null일 수 없습니다.") | ||
Long goalTime | ||
) { | ||
} | ||
|
||
public ChallengeRequest { | ||
if (!ChallengeConstants.AVAILABLE_CHALLENGE_PERIODS.contains(period)) { | ||
throw new ChallengeException(ChallengeError.INVALID_PERIOD_NUMERIC); | ||
} | ||
if (goalTime > ChallengeConstants.MAXIMUM_GOAL_TIME || goalTime < ChallengeConstants.MINIMUM_GOAL_TIME) { | ||
throw new ChallengeException(ChallengeError.INVALID_GOAL_TIME); | ||
} | ||
} | ||
} |
14 changes: 13 additions & 1 deletion
14
src/main/java/sopt/org/hmh/domain/challenge/dto/request/ChallengeSignUpRequest.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,12 +1,24 @@ | ||
package sopt.org.hmh.domain.challenge.dto.request; | ||
|
||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotNull; | ||
import sopt.org.hmh.domain.app.dto.request.ChallengeAppRequest; | ||
|
||
import java.util.List; | ||
import sopt.org.hmh.domain.challenge.domain.ChallengeConstants; | ||
import sopt.org.hmh.domain.challenge.domain.exception.ChallengeError; | ||
import sopt.org.hmh.domain.challenge.domain.exception.ChallengeException; | ||
|
||
public record ChallengeSignUpRequest( | ||
@NotNull(message = "챌린지 기간은 null일 수 없습니다.") | ||
Integer period, | ||
@NotNull(message = "챌린지 목표시간은 null일 수 없습니다.") | ||
Long goalTime, | ||
List<ChallengeAppRequest> apps | ||
List<@Valid ChallengeAppRequest> apps | ||
) { | ||
public ChallengeSignUpRequest { | ||
if (goalTime > ChallengeConstants.MAXIMUM_GOAL_TIME || goalTime < ChallengeConstants.MINIMUM_GOAL_TIME) { | ||
throw new ChallengeException(ChallengeError.INVALID_GOAL_TIME); | ||
} | ||
} | ||
} |
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.