from core.logger import DBLogger
from data.schemas.public.short_url import ShortUrl

logger = DBLogger(__name__)

from core.database.abc.db_model_dao_abc import DbModelDaoABC


class ShortUrlDao(DbModelDaoABC[ShortUrl]):
    def __init__(self):
        DbModelDaoABC.__init__(self, __name__, ShortUrl, "public.short_urls")
        self.attribute(ShortUrl.short_url, str)
        self.attribute(ShortUrl.target_url, str)
        self.attribute(ShortUrl.description, str)
        self.attribute(ShortUrl.group_id, int)
        self.reference("group", "id", ShortUrl.group_id, "public.groups")
        self.attribute(ShortUrl.domain_id, int)
        self.reference("domain", "id", ShortUrl.domain_id, "public.domains")
        self.attribute(ShortUrl.loading_screen, bool)


shortUrlDao = ShortUrlDao()
