refactor: 回忆改用独立存储与请求响应 DTO,服务按域拆包

This commit is contained in:
2026-11-20 09:38:16 +08:00
parent 5ff692b768
commit 4b65eb57b1
280 changed files with 8774 additions and 4364 deletions
@@ -15,51 +15,55 @@ import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
@ExceptionHandler(com.guo.learningprogresstracker.exception.RecallBusinessException.class)
public CommonResult<com.guo.learningprogresstracker.dto.recall.RecallDtos.BusinessError> recallBusinessException(
com.guo.learningprogresstracker.exception.RecallBusinessException ex) {
return new CommonResult<>(400, ex.getMessage(), ex.getData());
}
@ExceptionHandler({ErrorParameterException.class})
public CommonResult errorParameterException(ErrorParameterException ex) {
public CommonResult<Void> errorParameterException(ErrorParameterException ex) {
log.warn("参数异常: {}", ex.getMessage(), ex);
return CommonResult.error(ex.getMessage());
}
@ExceptionHandler({NotFindEntitiesException.class})
public CommonResult notFindEntitiesException(NotFindEntitiesException ex) {
public CommonResult<Void> notFindEntitiesException(NotFindEntitiesException ex) {
log.warn("数据不存在: {}", ex.getMessage(), ex);
return CommonResult.error(ex.getMessage());
}
@ExceptionHandler({OperationFailedException.class})
public CommonResult operationFailedException(OperationFailedException ex) {
public CommonResult<Void> operationFailedException(OperationFailedException ex) {
log.warn("操作失败: {}", ex.getMessage(), ex);
return CommonResult.error(ex.getMessage());
}
@ExceptionHandler({AppException.class})
public CommonResult AppException(AppException ex) {
public CommonResult<Void> handleAppException(AppException ex) {
log.error("业务异常: {}", ex.getMessage(), ex);
return CommonResult.serverError(ex.getMessage());
}
@ExceptionHandler(MethodArgumentNotValidException.class)
public CommonResult MyMethodArgumentNotValidException(MethodArgumentNotValidException ex) {
public CommonResult<Void> handleArgumentNotValid(MethodArgumentNotValidException ex) {
BindingResult bindingResult = ex.getBindingResult();
return CommonResult.error(bindingResult.getFieldError().getDefaultMessage());
}
@ExceptionHandler(NotLoginException.class)
public CommonResult handleNotLogin(NotLoginException e, HttpServletRequest req, HttpServletResponse res) {
public CommonResult<Void> handleNotLogin(NotLoginException e, HttpServletRequest req, HttpServletResponse res) {
res.setStatus(HttpStatus.UNAUTHORIZED.value());
return new CommonResult<>(HttpStatus.UNAUTHORIZED.value(), "未登录,请重新登录", null);
}
@ExceptionHandler(Exception.class)
public CommonResult Exception(Exception ex) {
public CommonResult<Void> handleUnexpected(Exception ex) {
log.error("系统异常", ex);
return CommonResult.error("操作没有成功,请稍后再试");
return CommonResult.serverError("操作没有成功,请稍后再试");
}
}