Compare commits
1 Commits
feature/co
...
feature/ap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db199aef7f |
@@ -1,31 +0,0 @@
|
|||||||
package com.rest.api.advice;
|
|
||||||
|
|
||||||
import com.rest.api.advice.exception.CUserNotFoundException;
|
|
||||||
import com.rest.api.model.response.CommonResult;
|
|
||||||
import com.rest.api.service.ResponseService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@RestControllerAdvice
|
|
||||||
public class ExceptionAdvice {
|
|
||||||
|
|
||||||
private final ResponseService responseService;
|
|
||||||
|
|
||||||
// @ExceptionHandler(Exception.class)
|
|
||||||
// @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
||||||
// protected CommonResult defaultException(HttpServletRequest request, Exception e) {
|
|
||||||
// return responseService.getFailResult();
|
|
||||||
// }
|
|
||||||
|
|
||||||
@ExceptionHandler(CUserNotFoundException.class)
|
|
||||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
||||||
protected CommonResult userNotFoundException(HttpServletRequest request, CUserNotFoundException e) {
|
|
||||||
return responseService.getFailResult();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.rest.api.advice.exception;
|
|
||||||
|
|
||||||
public class CUserNotFoundException extends RuntimeException {
|
|
||||||
public CUserNotFoundException(String msg, Throwable t) {
|
|
||||||
super(msg, t);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CUserNotFoundException(String msg) {
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CUserNotFoundException() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.rest.api.controller.v1;
|
package com.rest.api.controller.v1;
|
||||||
|
|
||||||
import com.rest.api.advice.exception.CUserNotFoundException;
|
|
||||||
import com.rest.api.entity.User;
|
import com.rest.api.entity.User;
|
||||||
import com.rest.api.model.response.CommonResult;
|
import com.rest.api.model.response.CommonResult;
|
||||||
import com.rest.api.model.response.ListResult;
|
import com.rest.api.model.response.ListResult;
|
||||||
@@ -33,7 +32,7 @@ public class UserController {
|
|||||||
@GetMapping(value = "/user/{msrl}")
|
@GetMapping(value = "/user/{msrl}")
|
||||||
public SingleResult<User> findUserById(@ApiParam(value = "회원ID", required = true) @PathVariable long msrl) {
|
public SingleResult<User> findUserById(@ApiParam(value = "회원ID", required = true) @PathVariable long msrl) {
|
||||||
// 결과데이터가 단일건인경우 getBasicResult를 이용해서 결과를 출력한다.
|
// 결과데이터가 단일건인경우 getBasicResult를 이용해서 결과를 출력한다.
|
||||||
return responseService.getSingleResult(userJpaRepo.findById(msrl).orElseThrow(CUserNotFoundException::new));
|
return responseService.getSingleResult(userJpaRepo.findById(msrl).orElse(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "회원 입력", notes = "회원을 입력한다")
|
@ApiOperation(value = "회원 입력", notes = "회원을 입력한다")
|
||||||
@@ -70,4 +69,3 @@ public class UserController {
|
|||||||
return responseService.getSuccessResult();
|
return responseService.getSuccessResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,5 @@ spring:
|
|||||||
username: sa
|
username: sa
|
||||||
jpa:
|
jpa:
|
||||||
database-platform: org.hibernate.dialect.H2Dialect
|
database-platform: org.hibernate.dialect.H2Dialect
|
||||||
#properties.hibernate.hbm2ddl.auto: none
|
properties.hibernate.hbm2ddl.auto: update
|
||||||
showSql: true
|
showSql: true
|
||||||
messages:
|
|
||||||
basename: i18n/exception
|
|
||||||
encoding: UTF-8
|
|
||||||
Reference in New Issue
Block a user