ForcePilot/backend/package/yuxi/channel/application/service/binding_service.py

36 lines
1.2 KiB
Python
Raw Normal View History

from __future__ import annotations
from yuxi.channel.domain.model.binding.channel_binding import ChannelBinding
from yuxi.channel.domain.repository.binding_repository import BindingRepositoryPort
class BindingService:
def __init__(self, binding_repo: BindingRepositoryPort) -> None:
self._repo = binding_repo
async def create(
self,
*,
channel_type: str,
account_id: str,
group_id: str,
agent_config_id: int,
) -> ChannelBinding:
return await self._repo.create_binding(
channel_type=channel_type,
account_id=account_id,
group_id=group_id,
agent_config_id=agent_config_id,
)
async def delete(self, binding_id: int) -> bool:
return await self._repo.delete_binding(binding_id)
async def get(self, binding_id: int) -> ChannelBinding | None:
return await self._repo.get_binding(binding_id)
async def list(
self, *, channel_type: str | None = None, offset: int = 0, limit: int = 50
) -> tuple[list[ChannelBinding], int]:
return await self._repo.list_bindings(channel_type=channel_type, offset=offset, limit=limit)