-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from neuefische/4-add-post-restaurant
4 add post restaurant
- Loading branch information
Showing
26 changed files
with
530 additions
and
35 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
28 changes: 28 additions & 0 deletions
28
backend/src/main/java/com/neuefische/team2/backend/exceptions/GlobalExceptionHandler.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,28 @@ | ||
package com.neuefische.team2.backend.exceptions; | ||
|
||
import com.neuefische.team2.backend.exceptions.domain.ExceptionResponse; | ||
import com.neuefische.team2.backend.exceptions.domain.ExceptionResponseMessage; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.MethodArgumentNotValidException; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
import java.util.List; | ||
|
||
|
||
@RestControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler(MethodArgumentNotValidException.class) | ||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
public ExceptionResponse handleMethodArgumentNotValidException(MethodArgumentNotValidException exception) { | ||
|
||
List<ExceptionResponseMessage> errors = exception.getFieldErrors() | ||
.stream() | ||
.map(error -> new ExceptionResponseMessage(error.getField(), error.getDefaultMessage())) | ||
.toList(); | ||
|
||
return new ExceptionResponse(errors); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
backend/src/main/java/com/neuefische/team2/backend/exceptions/domain/ExceptionResponse.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,8 @@ | ||
package com.neuefische.team2.backend.exceptions.domain; | ||
|
||
import java.util.List; | ||
|
||
public record ExceptionResponse( | ||
List<ExceptionResponseMessage> errors | ||
) { | ||
} |
7 changes: 7 additions & 0 deletions
7
...rc/main/java/com/neuefische/team2/backend/exceptions/domain/ExceptionResponseMessage.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,7 @@ | ||
package com.neuefische.team2.backend.exceptions.domain; | ||
|
||
public record ExceptionResponseMessage( | ||
String field, | ||
String message | ||
) { | ||
} |
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
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/com/neuefische/team2/backend/restaurant/domain/NewRestaurantDTO.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.neuefische.team2.backend.restaurant.domain; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record NewRestaurantDTO( | ||
@NotBlank(message="Title must not be empty") | ||
String title, | ||
@NotBlank(message="City must not be empty") | ||
String city | ||
) { | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Oops, something went wrong.