-
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.
Merge pull request #51 from ghdcksgml1/dev
Dev
- Loading branch information
Showing
32 changed files
with
753 additions
and
322 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
31 changes: 30 additions & 1 deletion
31
...th-api/src/main/java/com/heachi/auth/api/controller/auth/request/AuthRegisterRequest.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,4 +1,33 @@ | ||
package com.heachi.auth.api.controller.auth.request; | ||
|
||
import com.heachi.mysql.define.user.constant.UserRole; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotEmpty; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Pattern; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AuthRegisterRequest { | ||
} | ||
@NotEmpty | ||
private String email; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@NotNull | ||
private UserRole role; | ||
|
||
// 숫자 값이므로 null이 아니어야 하니까 @NotEmpty 대신 @NotNull 사용 -> 빈 문자열("") 허용 | ||
@NotNull | ||
@Pattern(regexp = "^\\d{11}$", | ||
message = "전화번호는 11자리의 숫자로 입력해야 합니다.") | ||
private String phoneNumber; | ||
} |
31 changes: 31 additions & 0 deletions
31
...pi/src/main/java/com/heachi/auth/api/controller/auth/response/UserSimpleInfoResponse.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,31 @@ | ||
package com.heachi.auth.api.controller.auth.response; | ||
|
||
import com.heachi.mysql.define.user.User; | ||
import com.heachi.mysql.define.user.constant.UserRole; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class UserSimpleInfoResponse { | ||
private UserRole role; | ||
private String name; | ||
private String email; | ||
private String profileImageUrl; | ||
|
||
@Builder | ||
private UserSimpleInfoResponse(UserRole role, String name, String email, String profileImageUrl) { | ||
this.role = role; | ||
this.name = name; | ||
this.email = email; | ||
this.profileImageUrl = profileImageUrl; | ||
} | ||
|
||
public static UserSimpleInfoResponse of(User user) { | ||
return UserSimpleInfoResponse.builder() | ||
.role(user.getRole()) | ||
.name(user.getName()) | ||
.email(user.getEmail()) | ||
.profileImageUrl(user.getProfileImageUrl()) | ||
.build(); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
...pi/src/main/java/com/heachi/auth/api/service/auth/request/AuthServiceRegisterRequest.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,5 +1,27 @@ | ||
package com.heachi.auth.api.service.auth.request; | ||
|
||
|
||
import com.heachi.auth.api.controller.auth.request.AuthRegisterRequest; | ||
import com.heachi.mysql.define.user.constant.UserRole; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AuthServiceRegisterRequest { | ||
private String email; | ||
private UserRole role; | ||
private String phoneNumber; | ||
|
||
public static AuthServiceRegisterRequest of(AuthRegisterRequest request) { | ||
return AuthServiceRegisterRequest.builder() | ||
.email(request.getEmail()) | ||
.role(request.getRole()) | ||
.phoneNumber(request.getPhoneNumber()) | ||
.build(); | ||
} | ||
} |
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
19 changes: 17 additions & 2 deletions
19
heachi-core/auth-api/src/main/java/com/heachi/auth/config/advice/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 |
---|---|---|
@@ -1,16 +1,31 @@ | ||
package com.heachi.auth.config.advice; | ||
|
||
import com.heachi.admin.common.response.JsonResult; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.context.support.DefaultMessageSourceResolvable; | ||
import org.springframework.validation.BindException; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
@RestControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler(BindException.class) | ||
public JsonResult bindException(BindException e) { | ||
return JsonResult.failOf( | ||
e.getBindingResult() | ||
.getFieldErrors() | ||
.stream() | ||
.map(fieldError -> fieldError.getField() + ": " + fieldError.getDefaultMessage()) | ||
.collect(Collectors.joining(", ")) | ||
); | ||
} | ||
|
||
@ExceptionHandler(Exception.class) | ||
public JsonResult<Exception> exception(Exception e) { | ||
return JsonResult.failOf(e.getMessage()); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.