NCP-3 add usercontent crud's,dto,exception and start restcontroller

This commit is contained in:
vladp
2025-11-26 13:03:20 +07:00
parent 11b74e046d
commit d9faa311a9
10 changed files with 159 additions and 3 deletions
@@ -8,6 +8,7 @@ import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import ru.soune.no_copy.exception.ContentNotFoundException;
import ru.soune.no_copy.exception.NotValidationPasswordException;
import ru.soune.no_copy.exception.UserAlreadyExistsException;
import ru.soune.no_copy.exception.UserNotFoundException;
@@ -53,6 +54,17 @@ public class GlobalExceptionHandler {
));
}
@ExceptionHandler(ContentNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public ResponseEntity<?> handleUserNotFoundException(ContentNotFoundException ex) {
return ResponseEntity.
badRequest()
.body(Map.of(
"success", false,
"message" ,ex.getMessage()
));
}
@ExceptionHandler(NotValidationPasswordException.class)
@ResponseStatus(HttpStatus.FORBIDDEN)
public ResponseEntity<?> handleNotValidationPasswordException(NotValidationPasswordException ex) {