-
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.
Merge pull request #4 from opcruz/dev
add signup services and some validations
- Loading branch information
Showing
22 changed files
with
217 additions
and
29 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
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
27 changes: 27 additions & 0 deletions
27
src/main/java/com/demo/sqlite/controllers/ValidationExceptionHandler.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,27 @@ | ||
package com.demo.sqlite.controllers; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.FieldError; | ||
import org.springframework.web.bind.MethodArgumentNotValidException; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@ControllerAdvice | ||
public class ValidationExceptionHandler { | ||
|
||
@ExceptionHandler(MethodArgumentNotValidException.class) | ||
public ResponseEntity<Map<String, String>> handleValidationExceptions( | ||
MethodArgumentNotValidException ex) { | ||
Map<String, String> errors = new HashMap<>(); | ||
ex.getBindingResult().getAllErrors().forEach((error) -> { | ||
String fieldName = ((FieldError) error).getField(); | ||
String errorMessage = error.getDefaultMessage(); | ||
errors.put(fieldName, errorMessage); | ||
}); | ||
return ResponseEntity.badRequest().body(errors); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/demo/sqlite/dtos/ClientSignupRequestDTO.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,39 @@ | ||
package com.demo.sqlite.dtos; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.Data; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@Data | ||
@Schema(description = "Signup Client Request DTO") | ||
public class ClientSignupRequestDTO { | ||
@Schema(example = "Carlos") | ||
@NotBlank(message = "Field 'name' is required") | ||
private String name; | ||
@Schema(example = "Cruz") | ||
@NotBlank(message = "Field 'surnames' is required") | ||
private String surnames; | ||
@Schema(example = "Av. Principal 123") | ||
@NotBlank(message = "Field 'direction' is required") | ||
private String direction; | ||
@Schema(example = "Jalisco") | ||
@NotBlank(message = "Field 'state' is required") | ||
private String state; | ||
@Schema(example = "45000") | ||
@NotBlank(message = "Field 'postal_code' is required") | ||
private String postal_code; | ||
@Schema(example = "3300000000") | ||
@NotBlank(message = "Field 'phone' is required") | ||
private String phone; | ||
@Schema(example = "carlos@example.com") | ||
@NotBlank(message = "Field 'email' is required") | ||
@Email(message = "Field 'email' must be a valid email address") | ||
private String email; | ||
@Schema(example = "ok") | ||
@NotBlank(message = "Field 'password' is required") | ||
private String password; | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/demo/sqlite/dtos/EmployeeSignupRequestDTO.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,27 @@ | ||
package com.demo.sqlite.dtos; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.Data; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@Data | ||
@Schema(description = "Signup Client Request DTO") | ||
public class EmployeeSignupRequestDTO { | ||
@Schema(example = "Felipe") | ||
@NotBlank(message = "Field 'name' is required") | ||
private String name; | ||
@Schema(example = "Contreras") | ||
@NotBlank(message = "Field 'surnames' is required") | ||
private String surnames; | ||
@Schema(example = "felipe@example.com") | ||
@NotBlank(message = "Field 'email' is required") | ||
@Email(message = "Field 'email' must be a valid email address") | ||
private String email; | ||
@Schema(example = "ok") | ||
@NotBlank(message = "Field 'password' is required") | ||
private String password; | ||
|
||
} |
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
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
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
Oops, something went wrong.