package com.talentcard.server.config; import com.talentcard.server.business.admin.AdminWorkbenchStatisticsController; import com.talentcard.server.common.ApiResponse; import com.talentcard.server.common.BusinessException; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; @Order(Ordered.HIGHEST_PRECEDENCE) @RestControllerAdvice(assignableTypes = AdminWorkbenchStatisticsController.class) public class AdminWorkbenchStatisticsExceptionHandler { @ExceptionHandler(BusinessException.class) public ResponseEntity> handleBusiness(BusinessException exception) { return error(exception.getMessage()); } @ExceptionHandler(Exception.class) public ResponseEntity> handleException(Exception exception) { return error("工作台统计查询失败"); } private ResponseEntity> error(String message) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(ApiResponse.failure(500, message == null || message.isBlank() ? "工作台统计查询失败" : message)); } }