"""
系统配置 API 客户端
"""

from httpx import AsyncClient


class ConfigAPI:
    """系统配置 API 客户端"""
    
    def __init__(self, client: AsyncClient):
        self.client = client
    
    async def get_config_list(self):
        """获取配置列表"""
        return await self.client.get('/api/config')
    
    async def get_config_by_id(self, config_id):
        """根据ID获取配置"""
        return await self.client.get(f'/api/config/{config_id}')
    
    async def get_config_by_key(self, config_key):
        """根据key获取配置"""
        return await self.client.get(f'/api/config/key/{config_key}')
    
    async def create(self, config_data):
        """创建配置"""
        return await self.client.post('/api/config', json=config_data)
    
    async def update(self, config_id, config_data):
        """更新配置"""
        return await self.client.put(f'/api/config/{config_id}', json=config_data)
    
    async def delete(self, config_id):
        """删除配置"""
        return await self.client.delete(f'/api/config/{config_id}')
    
    async def get_all(self):
        """获取所有配置"""
        return await self.client.get('/api/config')


class SysConfigAPI(ConfigAPI):
    """系统配置 API (别名)"""
    pass
