-
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 GuilhermeDoSantoss/feature/cadastros_ender…
…ecos_telefone adicionado handler, swagger e dockerfile
- Loading branch information
Showing
8 changed files
with
98 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM openjdk:17-jdk-alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY build/libs/agendador-tarefas-0.0.1-SNAPSHOT.jar /app/agendador-tarefas.jar | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["java", "-jar", "/app/agendador-tarefas.jar"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version: '3.8' | ||
|
||
services: | ||
app: | ||
build: . | ||
ports: | ||
- "8080:8080" | ||
environment: | ||
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/db_usuario | ||
SPRING_DATASOURCE_USERNAME: postgres | ||
SPRING_DATASOURCE_PASSWORD: 082418 | ||
depends_on: | ||
- db | ||
|
||
db: | ||
image: postgres:latest | ||
environment: | ||
POSTGRES_DB: db_usuario | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: 1234 | ||
ports: | ||
- "5432:5432" |
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
29 changes: 29 additions & 0 deletions
29
src/main/java/com/guilherme/agendador_tarefas/controller/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,29 @@ | ||
package com.guilherme.agendador_tarefas.controller; | ||
|
||
import com.guilherme.agendador_tarefas.infrastructure.exceptions.ConflictException; | ||
import com.guilherme.agendador_tarefas.infrastructure.exceptions.ResourceNotFoundException; | ||
import com.guilherme.agendador_tarefas.infrastructure.exceptions.UnauthorizedException; | ||
import org.springframework.boot.context.config.ConfigDataException; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
@ControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler(ResourceNotFoundException.class) | ||
public ResponseEntity<String> handleResourceNotFoundException(ResourceNotFoundException ex){ | ||
return new ResponseEntity<>(ex.getMessage(), HttpStatus.NOT_FOUND); | ||
} | ||
|
||
@ExceptionHandler(ConfigDataException.class) | ||
public ResponseEntity<String> handleConflictException(ConflictException ex){ | ||
return new ResponseEntity<>(ex.getMessage(), HttpStatus.CONFLICT); | ||
} | ||
|
||
@ExceptionHandler(UnauthorizedException.class) | ||
public ResponseEntity<String> handleUnauthorizedException(UnauthorizedException ex){ | ||
return new ResponseEntity<>(ex.getMessage(), HttpStatus.UNAUTHORIZED); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
...java/com/guilherme/agendador_tarefas/infrastructure/exceptions/UnauthorizedException.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,15 @@ | ||
package com.guilherme.agendador_tarefas.infrastructure.exceptions; | ||
|
||
import javax.naming.AuthenticationException; | ||
|
||
public class UnauthorizedException extends AuthenticationException{ | ||
|
||
public UnauthorizedException(String mensagem){ | ||
super(mensagem); | ||
} | ||
|
||
public UnauthorizedException(String mensagem, Throwable throwable){ | ||
super(mensagem, throwable); | ||
} | ||
|
||
} |
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