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)
        from data.schemas.public.group_dao import groupDao

        self.reference("group", "id", ShortUrl.group_id, "public.groups", groupDao)
        self.attribute(ShortUrl.domain_id, int)
        from data.schemas.public.domain_dao import domainDao

        self.reference("domain", "id", ShortUrl.domain_id, "public.domains", domainDao)
        self.attribute(ShortUrl.loading_screen, bool)

        self.attribute(ShortUrl.user_space_id, int)
        self.reference("userspace", "id", ShortUrl.user_space_id, "public.user_spaces")


shortUrlDao = ShortUrlDao()
