ResDTO = 화면에 내보낼 정보
(code/message/data)
요청이 성공적으로 완료되었습니다. (GET)
요청이 성공적이었으며 그 결과 새로운 리소스가 생성되었습니다.(POST)
이 응답은 잘못된 문법으로 인하여 서버가 요청을 이해할 수 없습니다.
비록 HTTP 표준에서는 "미승인(Unauthorized)"를 명확히 하고 있지만 의미상 이 응답은
"비인증"을 의미합니다.
로그인 안하고 로그인한 데이터를 요청했을 때 나타남
클라이언트는 콘텐츠에 접근할 권리를 가지고 있지 않습니다. 예를들어 그들은 미승인이어서
서버는 거절을 위한 적절한 응답을 보냅니다. 401과 다른점은 서버가 클라이언트가 누구인지 알고 있다.
어드민페이지에 일반유저가 들어온 경우
요청한 메소드는 서버에서 알고 있지만, 제거되었고 사용할 수 없습니다.
서버가 처리 방법을 모르는 상황이 발생했습니다.
HttpEntity
ResponseEntity
@Aspect
@Component
public class CommonAdvice {
// 경로를 맞춰줌으로써 그 내부에 조건에 부합하는게 작동했을 때 작동하도록
//pointcut(경로) 지정 방법
// @Before("execution(public * com.example.my..controller..*(..))")
// @Before("within(com.example.my..controller.*)")
// @Before("bean(*ControllerApi*)")
// public void tempAdvice() {
// log.warn("요청이들어왔습니다.");
// }
@Around("execution(* com.example.my.todo.repository..findByIdx(..))")
public Object checkFindByIdx(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
// proceedingJoinPoint.proceed() ->repository의 findByIdx 함수를 의미
Object result = proceedingJoinPoint.proceed(proceedingJoinPoint.getArgs());
if (result == null) {
throw new EntityNotFoundException("해당하는 데이터가 없습니다.");
}
return result;
}
}