from typing import Any, Dict, Optional


def success_response(
    data: Any = None,
    message: Optional[str] = None,
    code: int = 200
) -> Dict[str, Any]:
    """
    标准成功响应格式
    """
    response = {
        "success": True,
        "code": code
    }
    
    if data is not None:
        response["data"] = data
    
    if message:
        response["message"] = message
    
    return response


def error_response(
    message: str,
    code: int = 400,
    data: Any = None
) -> Dict[str, Any]:
    """
    标准错误响应格式
    """
    response = {
        "success": False,
        "code": code,
        "message": message
    }
    
    if data is not None:
        response["data"] = data
    
    return response