"""
审计日志 API 客户端
"""

from httpx import AsyncClient


class AuditLogAPI:
    """审计日志 API 客户端"""
    
    def __init__(self, client: AsyncClient):
        self.client = client
    
    async def get_login_log_list(self):
        """获取登录日志列表"""
        return await self.client.get('/api/logs/login')
    
    async def get_login_log_by_id(self, log_id):
        """根据ID获取登录日志"""
        return await self.client.get(f'/api/logs/login/{log_id}')
    
    async def get_exception_log_list(self):
        """获取异常日志列表"""
        return await self.client.get('/api/logs/exception')
    
    async def get_exception_log_by_id(self, log_id):
        """根据ID获取异常日志"""
        return await self.client.get(f'/api/logs/exception/{log_id}')
    
    async def get_operation_log_list(self):
        """获取操作日志列表"""
        return await self.client.get('/api/logs/operation')
    
    async def get_operation_log_by_id(self, log_id):
        """根据ID获取操作日志"""
        return await self.client.get(f'/api/logs/operation/{log_id}')
    
    async def get_login_logs(self, page: int = 0, size: int = 10):
        """分页获取登录日志"""
        return await self.client.get(f'/api/logs/login/page?page={page}&size={size}')
    
    async def get_exception_logs(self, page: int = 0, size: int = 10):
        """分页获取异常日志"""
        return await self.client.get(f'/api/logs/exception/page?page={page}&size={size}')
    
    async def get_operation_logs(self, page: int = 0, size: int = 10, **kwargs):
        """分页获取操作日志，支持筛选参数"""
        params = {'page': page, 'size': size}
        params.update(kwargs)
        return await self.client.get('/api/logs/operation/page', params=params)
    
    async def create_login_log(self, data):
        """创建登录日志"""
        return await self.client.post('/api/logs/login', json=data)
    
    async def create_exception_log(self, data):
        """创建异常日志"""
        return await self.client.post('/api/logs/exception', json=data)
    
    async def create_operation_log(self, data):
        """创建操作日志"""
        return await self.client.post('/api/logs/operation', json=data)


class SysLogAPI(AuditLogAPI):
    """系统日志 API (别名)"""
    pass


class AuditAPI(AuditLogAPI):
    """审计 API (别名)"""
    pass
