导出优化,上传端代码

This commit is contained in:
2025-11-08 10:36:24 +08:00
parent 5ee83477e3
commit 7633e22d99
7 changed files with 865 additions and 55 deletions

59
app/core/exceptions.py Normal file
View File

@@ -0,0 +1,59 @@
"""
自定义业务异常类
用于区分业务逻辑错误和系统错误
"""
from .response_code import ResponseCode, ResponseMessage
class BusinessException(Exception):
"""业务异常基类"""
def __init__(self, message: str, code: int = None):
self.message = message
self.code = code or ResponseCode.INTERNAL_ERROR
super().__init__(self.message)
class DataNotFoundException(BusinessException):
"""数据不存在异常"""
def __init__(self, message: str = None):
super().__init__(
message or ResponseMessage.DATA_NOT_FOUND,
ResponseCode.DATA_NOT_FOUND
)
class AccountNotFoundException(BusinessException):
"""账号不存在异常"""
def __init__(self, message: str = None):
super().__init__(
message or ResponseMessage.ACCOUNT_NOT_FOUND,
ResponseCode.ACCOUNT_NOT_FOUND
)
class DataExistsException(BusinessException):
"""数据已存在异常"""
def __init__(self, message: str = None):
super().__init__(
message or ResponseMessage.DATA_EXISTS,
ResponseCode.DATA_EXISTS
)
class ValidationException(BusinessException):
"""数据验证异常"""
def __init__(self, message: str = None):
super().__init__(
message or ResponseMessage.BAD_REQUEST,
ResponseCode.VALIDATION_ERROR
)
class ExportException(BusinessException):
"""导出异常"""
def __init__(self, message: str = None):
super().__init__(
message or ResponseMessage.EXPORT_FAILED,
ResponseCode.EXPORT_FAILED
)