-
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 #7 from lotteon2/dev-user-service
Dev user service
- Loading branch information
Showing
14 changed files
with
133 additions
and
52 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
src/main/java/com/bit/lotte/flower/user/common/exception/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,68 @@ | ||
package com.bit.lotte.flower.user.common.exception; | ||
|
||
import com.bit.lotte.flower.user.social.exception.SocialUserDomainException; | ||
import com.bit.lotte.flower.user.store.exception.StoreUserDomainException; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.FieldError; | ||
import org.springframework.web.bind.MethodArgumentNotValidException; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@RestControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler(MethodArgumentNotValidException.class) | ||
public ResponseEntity<Map<String, List<String>>> handleValidationErrors( | ||
MethodArgumentNotValidException ex) { | ||
List<String> errors = ex.getBindingResult().getFieldErrors() | ||
.stream().map(FieldError::getDefaultMessage).collect(Collectors.toList()); | ||
return new ResponseEntity<>(getErrorsMap(errors), new HttpHeaders(), HttpStatus.BAD_REQUEST); | ||
} | ||
|
||
private Map<String, List<String>> getErrorsMap(List<String> errors) { | ||
Map<String, List<String>> errorResponse = new HashMap<>(); | ||
errorResponse.put("errors", errors); | ||
return errorResponse; | ||
} | ||
|
||
|
||
|
||
@ExceptionHandler(SocialUserDomainException.class) | ||
public ResponseEntity<Map<String, List<String>>> emailCodeException( | ||
SocialUserDomainException ex) { | ||
List<String> errors = Collections.singletonList(ex.getMessage()); | ||
return new ResponseEntity<>(getErrorsMap(errors), new HttpHeaders(), HttpStatus.BAD_REQUEST); | ||
} | ||
@ExceptionHandler(StoreUserDomainException.class) | ||
public ResponseEntity<Map<String, List<String>>> storeManagerException( | ||
StoreUserDomainException ex) { | ||
List<String> errors = Collections.singletonList(ex.getMessage()); | ||
return new ResponseEntity<>(getErrorsMap(errors), new HttpHeaders(), HttpStatus.BAD_REQUEST); | ||
} | ||
|
||
|
||
|
||
@ExceptionHandler(Exception.class) | ||
public final ResponseEntity<Map<String, List<String>>> handleGeneralExceptions(Exception ex) { | ||
List<String> errors = Collections.singletonList(ex.getMessage()); | ||
return new ResponseEntity<>(getErrorsMap(errors), new HttpHeaders(), | ||
HttpStatus.INTERNAL_SERVER_ERROR); | ||
} | ||
|
||
@ExceptionHandler(RuntimeException.class) | ||
public final ResponseEntity<Map<String, List<String>>> handleRuntimeExceptions( | ||
RuntimeException ex) { | ||
List<String> errors = Collections.singletonList(ex.getMessage()); | ||
return new ResponseEntity<>(getErrorsMap(errors), new HttpHeaders(), | ||
HttpStatus.INTERNAL_SERVER_ERROR); | ||
} | ||
|
||
|
||
} |
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
12 changes: 7 additions & 5 deletions
12
...com/bit/lotte/flower/user/store/http/feign/InitStoreManagerStatusPendingFeignRequest.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,10 +1,12 @@ | ||
package com.bit.lotte.flower.user.store.http.feign; | ||
|
||
import com.bit.lotte.flower.user.common.valueobject.BaseId; | ||
import com.bit.lotte.flower.user.store.http.feign.dto.UpdateStoreManagerPendingStausDto; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
|
||
@FeignClient(name = "init-storemanager-status",value = "${service.auth.domain}") | ||
public interface InitStoreManagerStatusPendingFeignRequest<ID extends BaseId> { | ||
public void publish(@RequestHeader ID userId); | ||
@FeignClient(name = "init-storemanager-status",url = "${service.auth.domain}") | ||
public interface InitStoreManagerStatusPendingFeignRequest { | ||
@PatchMapping("/admin/store-manager") | ||
public void publish(@RequestBody UpdateStoreManagerPendingStausDto dto); | ||
} |
19 changes: 19 additions & 0 deletions
19
...ava/com/bit/lotte/flower/user/store/http/feign/dto/UpdateStoreManagerPendingStausDto.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,19 @@ | ||
package com.bit.lotte.flower.user.store.http.feign.dto; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public class UpdateStoreManagerPendingStausDto { | ||
|
||
@NotNull | ||
private final String status = "ROLE_STORE_MANAGER_PENDING"; | ||
@NotNull | ||
private Long storeManagerId; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,26 @@ | ||
|
||
server: | ||
port: 8600 | ||
|
||
spring: | ||
config: | ||
activate: | ||
on-profile: local | ||
datasource: | ||
url: jdbc:mysql://localhost:3306/bb-user-service?serverTimezone=Asia/Seoul | ||
url: jdbc:mysql://localhost:3306/develop?serverTimezone=Asia/Seoul&useUnicode=true&characterEncoding=utf8 | ||
username: root | ||
password: k1651227 | ||
password: 123456 | ||
driver-class-name: com.mysql.cj.jdbc.Driver | ||
jpa: | ||
hibernate: | ||
ddl-auto: update | ||
show-sql: true | ||
|
||
feign: | ||
client: | ||
default: | ||
url: http://localhost:8082 | ||
config: | ||
default: | ||
connectTimeout: 5000 | ||
readTimeout: 5000 | ||
loggerLevel: basic | ||
|
||
service: | ||
coupon: | ||
domain : ${service.coupon.domain} | ||
domain : http://localhost:9999 | ||
likes: | ||
domain : ${servive.likes.domain} | ||
domain : http://localhost:8888 | ||
auth: | ||
domain : http://localhost:9000 |
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ spring: | |
jpa: | ||
show-sql: true | ||
hibernate: | ||
ddl-auto: update | ||
ddl-auto: none | ||
|
||
feign: | ||
client: | ||
|
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