-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task 16 : Define BaseDomainModel, AlreadyException, NotFoundException…
…, EmailAlreadyExistsException and RateLimitExceededException
- Loading branch information
1 parent
fa1ad62
commit 1daf71f
Showing
5 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/java/com/springboot/ratelimiter/common/exception/AlreadyException.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,18 @@ | ||
package com.springboot.ratelimiter.common.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import java.io.Serial; | ||
|
||
public abstract class AlreadyException extends RuntimeException { | ||
|
||
@Serial | ||
private static final long serialVersionUID = 6091550422939917669L; | ||
|
||
public static final HttpStatus STATUS = HttpStatus.CONFLICT; | ||
|
||
protected AlreadyException(String message) { | ||
super(message); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/springboot/ratelimiter/common/exception/NotFoundException.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,18 @@ | ||
package com.springboot.ratelimiter.common.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import java.io.Serial; | ||
|
||
public abstract class NotFoundException extends RuntimeException { | ||
|
||
@Serial | ||
private static final long serialVersionUID = 4846183318086338894L; | ||
|
||
public static final HttpStatus STATUS = HttpStatus.NOT_FOUND; | ||
|
||
protected NotFoundException(String message) { | ||
super(message); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
...ava/com/springboot/ratelimiter/common/exception/ratelimit/RateLimitExceededException.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,11 @@ | ||
package com.springboot.ratelimiter.common.exception.ratelimit; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
@ResponseStatus(HttpStatus.TOO_MANY_REQUESTS) | ||
public class RateLimitExceededException extends RuntimeException { | ||
public RateLimitExceededException(String message) { | ||
super(message); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...in/java/com/springboot/ratelimiter/common/exception/user/EmailAlreadyExistsException.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,26 @@ | ||
package com.springboot.ratelimiter.common.exception.user; | ||
|
||
import com.springboot.ratelimiter.common.exception.AlreadyException; | ||
|
||
import java.io.Serial; | ||
|
||
public class EmailAlreadyExistsException extends AlreadyException { | ||
|
||
@Serial | ||
private static final long serialVersionUID = -6856741036475854853L; | ||
|
||
private static final String DEFAULT_MESSAGE = | ||
"The specified email already exists"; | ||
|
||
private static final String MESSAGE_TEMPLATE = | ||
"Email already exists: "; | ||
|
||
public EmailAlreadyExistsException(String email) { | ||
super(MESSAGE_TEMPLATE.concat(email)); | ||
} | ||
|
||
public EmailAlreadyExistsException() { | ||
super(DEFAULT_MESSAGE); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/springboot/ratelimiter/common/model/BaseDomainModel.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,23 @@ | ||
package com.springboot.ratelimiter.common.model; | ||
|
||
import jakarta.persistence.MappedSuperclass; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@Setter | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@MappedSuperclass | ||
public abstract class BaseDomainModel { | ||
|
||
protected LocalDateTime createdAt; | ||
protected LocalDateTime updatedAt; | ||
|
||
} |