# -*- coding: utf-8 -*-
"""
@File: models.py
@Date: 2020-09-14
@author: A2TEC
@section MODIFYINFO 수정정보
- 수정자/수정일   : 수정내역
- 2022-01-14/hsj100@a2tec.co.kr : refactoring
@brief: data models
"""

from datetime import datetime
from enum import Enum
from typing import List

from pydantic import TypeAdapter
from pydantic import Field, ConfigDict
from pydantic.main import BaseModel
from pydantic.networks import EmailStr, IPvAnyAddress
from typing import Optional

from main_rest.app.common.consts import (
    SW_TITLE,
    SW_VERSION,
    MAIL_REG_TITLE,
    MAIL_REG_CONTENTS,
    SMTP_HOST,
    SMTP_PORT,
    ADMIN_INIT_ACCOUNT_INFO,
    DEFAULT_USER_ACCOUNT_PW
)
from main_rest.app.utils.date_utils import D


class SWInfo(BaseModel):
    """
    ### 서비스 정보
    """
    name: str = Field(SW_TITLE, description='SW 이름', example=SW_VERSION)
    version: str = Field(SW_VERSION, description='SW 버전', example=SW_VERSION)
    date: str = Field(D.date_str(), description='현재날짜', example='%Y.%m.%dT%H:%M:%S')
    data1: str = Field(None, description='TestData1', example=None)
    data2: str = Field(None, description='TestData2', example=None)
    data3: str = Field(None, description='TestData3', example=None)
    data4: str = Field(None, description='TestData4', example=None)
    
    data5: str = Field(None, description='TestData1', example=None)
    data6: str = Field(None, description='TestData2', example=None)
    data7: str = Field(None, description='TestData3', example=None)
    data8: str = Field(None, description='TestData4', example=None)


class CustomEnum(Enum):
    @classmethod
    def get_elements_str(cls, is_key=True):
        if is_key:
            result_str = cls.__members__.keys()
        else:
            result_str = cls.__members__.values()
        return '[' + ', '.join(result_str) + ']'


class SexType(str, CustomEnum):
    male: str = 'male'
    female: str = 'female'


class AccountType(str, CustomEnum):
    email: str = 'email'
    # facebook: str = 'facebook'
    # google: str = 'google'
    # kakao: str = 'kakao'


class UserStatusType(str, CustomEnum):
    active: str = 'active'
    deleted: str = 'deleted'
    blocked: str = 'blocked'


class UserLoginType(str, CustomEnum):
    login: str = 'login'
    logout: str = 'logout'


class MemberType(str, CustomEnum):
    personal: str = 'personal'
    company: str = 'company'


class UserType(str, CustomEnum):
    admin: str = 'admin'
    user: str = 'user'


class UserLogMessageType(str, CustomEnum):
    info: str = 'info'
    error: str = 'error'


class Token(BaseModel):
    Authorization: str = Field(None, description='인증키', example='Bearer [token]')


class EmailRecipients(BaseModel):
    name: str
    email: str


class SendEmail(BaseModel):
    email_to: List[EmailRecipients] = None


class KakaoMsgBody(BaseModel):
    msg: str | None = None


class MessageOk(BaseModel):
    message: str = Field(default='OK')


class UserToken(BaseModel):
    id: int
    account: str | None = None
    name: str | None = None
    phone_number: str | None = None
    profile_img: str | None = None
    account_type: str | None = None

    # model_config = ConfigDict(from_attributes=True)


class AddApiKey(BaseModel):
    user_memo: str | None = None

    model_config = ConfigDict(from_attributes=True)


class GetApiKeyList(AddApiKey):
    id: int = None
    access_key: str | None = None
    created_at: datetime = None


class GetApiKeys(GetApiKeyList):
    secret_key: str | None = None


class CreateAPIWhiteLists(BaseModel):
    ip_addr: str | None = None


class GetAPIWhiteLists(CreateAPIWhiteLists):
    id: int

    model_config = ConfigDict(from_attributes=True)


class ResponseBase(BaseModel):
    """
    ### [Response] API End-Point

    **정상처리**\n
    - result: true\n
    - error: null\n

    **오류발생**\n
    - result: false\n
    - error: 오류내용\n
    """
    result: bool = Field(True, description='처리상태(성공: true, 실패: false)', example=True)
    error: str | None = Field(None, description='오류내용(성공: null, 실패: 오류내용)', example=None)

    @staticmethod
    def set_error(error):
        ResponseBase.result = False
        ResponseBase.error = str(error)

        return ResponseBase
    
    @staticmethod
    def set_message():
        ResponseBase.result = True
        ResponseBase.error = None
        return ResponseBase
    
    model_config = ConfigDict(from_attributes=True)
    

class PagingReq(BaseModel):
    """
    ### [Request] 페이징 정보
    """
    start_page: int = Field(None, description='시작 페이지 번호(base: 1)', example=1)
    page_contents_num: int = Field(None, description='페이지 내용 개수', example=2)

    model_config = ConfigDict(from_attributes=True)


class PagingRes(BaseModel):
    """
    ### [Response] 페이징 정보
    """
    total_page_num: int = Field(None, description='전체 페이지 개수', example=100)
    total_contents_num: int = Field(None, description='전체 내용 개수', example=100)
    start_page: int = Field(None, description='시작 페이지 번호(base: 1)', example=1)
    search_contents_num: int = Field(None, description='검색된 내용 개수', example=100)

    model_config = ConfigDict(from_attributes=True)


class TokenRes(ResponseBase):
    """
    ### [Response] 토큰 정보
    """
    Authorization: str = Field(None, description='인증키', example='Bearer [token]')

    model_config = ConfigDict(from_attributes=True)


class UserLogInfo(BaseModel):
    """
    ### 사용자 로그 정보
    """
    id: int = Field(None, description='Table Index', example='1')
    created_at: datetime = Field(None, description='생성날짜', example='2022-01-01T12:34:56')
    updated_at: datetime = Field(None, description='수정날짜', example='2022-01-01T12:34:56')

    account: str = Field(None, description='계정', example='user1@test.com')
    mac: str = Field(None, description='MAC(네트워크 인터페이스 식별자)', example='11:22:33:44:55:66')
    type: str = Field(None, description='로그 타입' + UserLogMessageType.get_elements_str(), example=UserLogMessageType.info)
    api: str = Field(None, description='API 이름', example='/api/auth/login')
    message: str = Field(None, description='로그 내용', example='ok')

    model_config = ConfigDict(from_attributes=True)


class UserInfo(BaseModel):
    """
    ### 유저 정보
    """
    id: int = Field(None, description='Table Index', example='1')
    created_at: datetime = Field(None, description='생성날짜', example='2022-01-01T12:34:56')
    updated_at: datetime = Field(None, description='수정날짜', example='2022-01-01T12:34:56')

    status: UserStatusType = Field(None, description='계정상태' + UserStatusType.get_elements_str(), example=UserStatusType.active)
    user_type: UserType = Field(None, description='유저 타입' + UserType.get_elements_str(), example=UserType.user)
    account_type: AccountType = Field(None, description='계정종류' + AccountType.get_elements_str(), example=AccountType.email)
    account: str = Field(None, description='계정', example='user1@test.com')
    email: str = Field(None, description='전자메일', example='user1@test.com')
    name: str = Field(None, description='이름', example='user1')
    sex: str = Field(None, description='성별' + SexType.get_elements_str(), example=SexType.male)
    rrn: str = Field(None, description='주민등록번호', example='123456-1234567')
    address: str = Field(None, description='주소', example='대구1')
    phone_number: str = Field(None, description='연락처', example='010-1234-1234')
    picture: str = Field(None, description='프로필사진', example='profile1.png')
    marketing_agree: bool = Field(False, description='마케팅동의 여부', example=False)
    # extra
    login: UserLoginType = Field(None, description='로그인 상태' + UserLoginType.get_elements_str(), example=UserLoginType.logout)  # TODO(hsj100): LOGIN_STATUS
    member_type: MemberType = Field(None, description='회원 타입' + MemberType.get_elements_str(), example=MemberType.personal)

    model_config = ConfigDict(from_attributes=True)


class SendMailReq(BaseModel):
    """
    ### [Request] 메일 전송
    """
    smtp_host: str = Field(None, description='SMTP 서버 주소', example=SMTP_HOST)
    smtp_port: int = Field(None, description='SMTP 서버 포트', example=SMTP_PORT)
    title: str = Field(None, description='제목', example=MAIL_REG_TITLE)
    recipient: str = Field(None, description='수신자', example='user1@test.com')
    cc_list: list = Field(None, description='참조 리스트', example='["user2@test.com", "user3@test.com"]')
    # recipient: str = Field(None, description='수신자', example='hsj100@a2tec.co.kr')
    # cc_list: list = Field(None, description='참조 리스트', example=None)
    contents_plain: str = Field(None, description='내용', example=MAIL_REG_CONTENTS.format('user1@test.com', 10))
    contents_html: str = Field(None, description='내용', example='<p>내 고양이는 <strong>아주 고약해.</p></strong>')

    model_config = ConfigDict(from_attributes=True)


class UserInfoRes(ResponseBase):
    """
    ### [Response] 유저 정보
    """
    data: UserInfo = None

    model_config = ConfigDict(from_attributes=True)


class UserLoginReq(BaseModel):
    """
    ### 유저 로그인 정보
    """
    account: str = Field(description='계정', example='user1@test.com')
    pw: str = Field(None, description='비밀번호 [관리자 필수]', example='1234')
    # SW-LICENSE
    sw: str = Field(None, description='라이선스 SW 이름 [유저 필수]', example='저작도구')
    mac: str = Field(None, description='MAC [유저 필수]', example='11:22:33:44:55:01')


class UserRegisterReq(BaseModel):
    """
    ### [Request] 유저 등록
    """
    status: Optional[str] = Field(UserStatusType.active, description='계정상태' + UserStatusType.get_elements_str(), example=UserStatusType.active)
    user_type: Optional[UserType] = Field(UserType.user, description='유저 타입' + UserType.get_elements_str(), example=UserType.user)
    account: str = Field(description='계정', example='test@test.com')
    pw: Optional[str] = Field(DEFAULT_USER_ACCOUNT_PW, description='비밀번호', example='1234')
    email: Optional[str] = Field(None, description='전자메일', example='test@test.com')
    name: str = Field(description='이름', example='test')
    sex: Optional[SexType] = Field(SexType.male, description='성별' + SexType.get_elements_str(), example=SexType.male)
    rrn: Optional[str] = Field(None, description='주민등록번호', example='19910101-1234567')
    address: Optional[str] = Field(None, description='주소', example='대구광역시 동구 동촌로 351, 4층 (용계동, 에이스빌딩)')
    phone_number: Optional[str] = Field(None, description='휴대전화', example='010-1234-1234')
    picture: Optional[str] = Field(None, description='사진', example='profile1.png')
    marketing_agree: Optional[bool] = Field(False, description='마케팅동의 여부', example=False)
    # extra
    member_type: Optional[MemberType] = Field(MemberType.personal, description='회원 타입' + MemberType.get_elements_str(), example=MemberType.personal)
    # relationship:license
    license_sw: str = Field(description='라이선스 SW 이름', example='저작도구')
    license_start: datetime = Field(description='라이선스 시작날짜', example='2022-02-10T15:00:00')
    license_end: datetime = Field(description='라이선스 시작날짜', example='2023-02-10T15:00:00')
    license_num: Optional[int] = Field(1, description='계약된 라이선스 개수', example=1)
    license_manager_name: Optional[str] = Field(ADMIN_INIT_ACCOUNT_INFO.name, description='담당자 이름', example=ADMIN_INIT_ACCOUNT_INFO.name)
    license_manager_phone: Optional[str] = Field(ADMIN_INIT_ACCOUNT_INFO.phone_number, description='담당자 연락처', example=ADMIN_INIT_ACCOUNT_INFO.phone_number)

    model_config = ConfigDict(from_attributes=True)


class UserSearchReq(BaseModel):
    """
    ### [Request] 유저 검색 (기본)
    """
    # basic
    id: Optional[int] = Field(None, description='등록번호', example='1')
    id__in: Optional[list] = Field(None, description='등록번호 리스트', example=[1,])
    created_at: Optional[str] = Field(None, description='생성날짜', example='2022-01-01T12:34:56')
    created_at__gt: Optional[str] = Field(None, description='생성날짜(주어진 날짜 이후)', example='2022-02-10T15:00:00')
    created_at__gte: Optional[str] = Field(None, description='생성날짜(주어진 날짜 포함 이후)', example='2022-02-10T15:00:00')
    created_at__lt: Optional[str] = Field(None, description='생성날짜(주어진 날짜 이전)', example='2022-02-10T15:00:00')
    created_at__lte: Optional[str] = Field(None, description='생성날짜(주어진 날짜 포함 이전)', example='2022-02-10T15:00:00')
    updated_at: Optional[str] = Field(None, description='수정날짜', example='2022-01-01T12:34:56')
    updated_at__gt: Optional[str] = Field(None, description='생성날짜(주어진 날짜 이후)', example='2022-02-10T15:00:00')
    updated_at__gte: Optional[str] = Field(None, description='생성날짜(주어진 날짜 포함 이후)', example='2022-02-10T15:00:00')
    updated_at__lt: Optional[str] = Field(None, description='생성날짜(주어진 날짜 이전)', example='2022-02-10T15:00:00')
    updated_at__lte: Optional[str] = Field(None, description='생성날짜(주어진 날짜 포함 이전)', example='2022-02-10T15:00:00')

    status: Optional[UserStatusType] = Field(None, description='계정상태' + UserStatusType.get_elements_str(), example=UserStatusType.active)
    user_type: Optional[UserType] = Field(None, description='유저 타입' + UserType.get_elements_str(), example=UserType.user)
    account_type: Optional[AccountType] = Field(None, description='계정종류' + AccountType.get_elements_str(), example=AccountType.email)
    account: Optional[str] = Field(None, description='계정', example='user1@test.com')
    account__like: Optional[str] = Field(None, description='계정 부분검색', example='%user%')
    email: Optional[str] = Field(None, description='전자메일', example='user1@test.com')
    email__like: Optional[str] = Field(None, description='전자메일 부분검색', example='%user%')
    name: Optional[str] = Field(None, description='이름', example='test')
    name__like: Optional[str] = Field(None, description='이름 부분검색', example='%user%')
    sex: Optional[SexType] = Field(None, description='성별' + SexType.get_elements_str(), example=SexType.male)
    rrn: Optional[str] = Field(None, description='주민등록번호', example='123456-1234567')
    address: Optional[str] = Field(None, description='주소', example='대구1')
    address__like: Optional[str] = Field(None, description='주소 부분검색', example='%대구%')
    phone_number: Optional[str] = Field(None, description='연락처', example='010-1234-1234')
    picture: Optional[str] = Field(None, description='프로필사진', example='profile1.png')
    marketing_agree: Optional[bool] = Field(None, description='마케팅동의 여부', example=False)
    # extra
    login: Optional[UserLoginType] = Field(None, description='로그인 상태' + UserLoginType.get_elements_str(), example=UserLoginType.logout)  # TODO(hsj100): LOGIN_STATUS
    member_type: Optional[MemberType] = Field(None, description='회원 타입' + MemberType.get_elements_str(), example=MemberType.personal)

    model_config = ConfigDict(from_attributes=True)


class UserSearchRes(ResponseBase):
    """
    ### [Response] 유저 검색
    """
    data: List[UserInfo] = []

    model_config = ConfigDict(from_attributes=True)


class UserSearchPagingReq(BaseModel):
    """
    ### [Request] 유저 페이징 검색
    """
    # paging
    paging: Optional[PagingReq] = None
    search: Optional[UserSearchReq] = None


class UserSearchPagingRes(ResponseBase):
    """
    ### [Response] 유저 페이징 검색
    """
    paging: PagingRes = None
    data: List[UserInfo] = []

    model_config = ConfigDict(from_attributes=True)


class UserUpdateReq(BaseModel):
    """
    ### [Request] 유저 변경
    """
    status: Optional[UserStatusType] = Field(None, description='계정상태' + UserStatusType.get_elements_str(), example=UserStatusType.active)
    user_type: Optional[UserType] = Field(None, description='유저 타입' + UserType.get_elements_str(), example=UserType.user)
    account_type: Optional[AccountType] = Field(None, description='계정종류' + AccountType.get_elements_str(), example=AccountType.email)
    account: Optional[str] = Field(None, description='계정', example='user1@test.com')
    email: Optional[str] = Field(None, description='전자메일', example='user1@test.com')
    name: Optional[str] = Field(None, description='이름', example='test')
    sex: Optional[SexType] = Field(None, description='성별' + SexType.get_elements_str(), example=SexType.male)
    rrn: Optional[str] = Field(None, description='주민등록번호', example='123456-1234567')
    address: Optional[str] = Field(None, description='주소', example='대구1')
    phone_number: Optional[str] = Field(None, description='연락처', example='010-1234-1234')
    picture: Optional[str] = Field(None, description='프로필사진', example='profile1.png')
    marketing_agree: Optional[bool] = Field(False, description='마케팅동의 여부', example=False)
    # extra
    login: Optional[UserLoginType] = Field(None, description='로그인 상태' + UserLoginType.get_elements_str(), example=UserLoginType.logout)  # TODO(hsj100): LOGIN_STATUS
    # uuid: Optional[str] = Field(None, description='UUID', example='12345678-1234-5678-1234-567800000001')
    member_type: Optional[MemberType] = Field(None, description='회원 타입' + MemberType.get_elements_str(), example=MemberType.personal)

    model_config = ConfigDict(from_attributes=True)


class UserUpdateMultiReq(BaseModel):
    """
    ### [Request] 유저 변경 (multi)
    """
    search_info: UserSearchReq = None
    update_info: UserUpdateReq = None

    model_config = ConfigDict(from_attributes=True)


class UserUpdatePWReq(BaseModel):
    """
    ### [Request] 유저 비밀번호 변경
    """
    account: str = Field(None, description='계정', example='user1@test.com')
    current_pw: str = Field(None, description='현재 비밀번호', example='1234')
    new_pw: str = Field(None, description='신규 비밀번호', example='5678')


class UserLogSearchReq(BaseModel):
    """
    ### [Request] 유저로그 검색
    """
    # basic
    id: Optional[int] = Field(None, description='등록번호', example='1')
    id__in: Optional[list] = Field(None, description='등록번호 리스트', example=[1,])
    created_at: Optional[str] = Field(None, description='생성날짜', example='2022-01-01T12:34:56')
    created_at__gt: Optional[str] = Field(None, description='생성날짜(주어진 날짜 이후)', example='2022-02-10T15:00:00')
    created_at__gte: Optional[str] = Field(None, description='생성날짜(주어진 날짜 포함 이후)', example='2022-02-10T15:00:00')
    created_at__lt: Optional[str] = Field(None, description='생성날짜(주어진 날짜 이전)', example='2022-02-10T15:00:00')
    created_at__lte: Optional[str] = Field(None, description='생성날짜(주어진 날짜 포함 이전)', example='2022-02-10T15:00:00')
    updated_at: Optional[str] = Field(None, description='수정날짜', example='2022-01-01T12:34:56')
    updated_at__gt: Optional[str] = Field(None, description='생성날짜(주어진 날짜 이후)', example='2022-02-10T15:00:00')
    updated_at__gte: Optional[str] = Field(None, description='생성날짜(주어진 날짜 포함 이후)', example='2022-02-10T15:00:00')
    updated_at__lt: Optional[str] = Field(None, description='생성날짜(주어진 날짜 이전)', example='2022-02-10T15:00:00')
    updated_at__lte: Optional[str] = Field(None, description='생성날짜(주어진 날짜 포함 이전)', example='2022-02-10T15:00:00')

    account: Optional[str] = Field(None, description='계정', example='user1@test.com')
    account__like: Optional[str] = Field(None, description='계정 부분검색', example='%user%')
    mac: Optional[str] = Field(None, description='MAC', example='11:22:33:44:55:01')
    mac__like: Optional[str] = Field(None, description='MAC 부분검색', example='%33%')
    type: Optional[UserLogMessageType] = Field(None, description='유저로그 메시지 타입' + UserLogMessageType.get_elements_str(), example=UserLogMessageType.error)
    api: Optional[str] = Field(None, description='API 이름', example='/api/auth/login')
    api__like: Optional[str] = Field(None, description='API 이름 부분검색', example='%login%')
    message: Optional[str] = Field(None, description='로그내용', example='invalid password')
    message__like: Optional[str] = Field(None, description='로그내용 부분검색', example='%invalid%')

    model_config = ConfigDict(from_attributes=True)


class UserLogDayInfo(BaseModel):
    """
        ### 유저로그 일별 접속 정보 (출석)
    """
    account: str = Field(None, description='계정', example='user1@test.com')
    mac: str = Field(None, description='MAC(네트워크 인터페이스 식별자)', example='11:22:33:44:55:66')
    updated_at: datetime = Field(None, description='수정날짜', example='2022-01-01T12:34:56')
    message: str = Field(None, description='로그 내용', example='ok')

    model_config = ConfigDict(from_attributes=True)


class UserLogDaySearchReq(BaseModel):
    """
    ### [Request] 유저로그 일별 마지막 접속 검색
    """
    updated_at: Optional[str] = Field(None, description='수정날짜', example='2022-01-01T12:34:56')
    updated_at__gt: Optional[str] = Field(None, description='생성날짜(주어진 날짜 이후)', example='2022-02-10T15:00:00')
    updated_at__gte: Optional[str] = Field(None, description='생성날짜(주어진 날짜 포함 이후)', example='2022-02-10T15:00:00')
    updated_at__lt: Optional[str] = Field(None, description='생성날짜(주어진 날짜 이전)', example='2022-02-10T15:00:00')
    updated_at__lte: Optional[str] = Field(None, description='생성날짜(주어진 날짜 포함 이전)', example='2022-02-10T15:00:00')

    account: Optional[str] = Field(None, description='계정', example='user1@test.com')
    account__like: Optional[str] = Field(None, description='계정 부분검색', example='%user%')
    mac: Optional[str] = Field(None, description='MAC', example='11:22:33:44:55:01')
    mac__like: Optional[str] = Field(None, description='MAC 부분검색', example='%33%')

    model_config = ConfigDict(from_attributes=True)


class UserLogDaySearchPagingReq(BaseModel):
    """
    ### [Request] 유저로그 일별 마지막 접속 페이징 검색
    """
    # paging
    paging: Optional[PagingReq] = None
    search: Optional[UserLogDaySearchReq] = None


class UserLogDaySearchPagingRes(ResponseBase):
    """
    ### [Response] 유저로그 일별 마지막 접속 검색
    """
    paging: PagingRes = None
    data: List[UserLogDayInfo] = []

    model_config = ConfigDict(from_attributes=True)


class UserLogPagingReq(BaseModel):
    """
    ### [Request] 유저로그 페이징 검색
    """
    # paging
    paging: Optional[PagingReq] = None
    search: Optional[UserLogSearchReq] = None


class UserLogPagingRes(ResponseBase):
    """
    ### [Response] 유저로그 페이징 검색
    """
    paging: PagingRes = None
    data: List[UserLogInfo] = []

    model_config = ConfigDict(from_attributes=True)


class UserLogUpdateReq(BaseModel):
    """
    ### [Request] 유저로그 변경
    """
    account: Optional[str] = Field(None, description='계정', example='user1@test.com')
    mac: Optional[str] = Field(None, description='MAC', example='11:22:33:44:55:01')
    type: Optional[UserLogMessageType] = Field(None, description='유저로그 메시지 타입' + UserLogMessageType.get_elements_str(), example=UserLogMessageType.error)
    api: Optional[str] = Field(None, description='API 이름', example='/api/auth/login')
    message: Optional[str] = Field(None, description='로그내용', example='invalid password')

    model_config = ConfigDict(from_attributes=True)


class UserLogUpdateMultiReq(BaseModel):
    """
    ### [Request] 유저로그 변경 (multi)
    """
    search_info: UserLogSearchReq = None
    update_info: UserLogUpdateReq = None

    model_config = ConfigDict(from_attributes=True)

#===============================================================================
#===============================================================================
#===============================================================================
#===============================================================================

class IndexType:
    hnsw = "hnsw"
    l2 = "l2"


class VitIndexType:
    cos = "cos"
    l2 = "l2"


class VitModelType:
    b32 = "b32"
    b16 = "b16"
    l14 = "l14"
    l14_336 = "l14_336"


class ImageGenerateReq(BaseModel):
    """
    ### [Request] image generate request
    """
    prefix : Optional[str] = Field(default="하얀색 배경", description="접두사", example="하얀색 배경")
    prompt : str = Field(description='프롬프트', example='검은색 안경')    
    
class BingCookieSetReq(BaseModel):
    """
    ### [Request] bing cookie set
    """
    cookie : str = Field('',description='쿠키 데이터', example='')
    
    
class VectorImageSearchReq(BaseModel):
    """
    ### [Request] vector image search request
    """
    prompt : str = Field(description='프롬프트', example='검은색 안경')
    indexType : str = Field(IndexType.l2, description='인덱스 타입', example=IndexType.l2)
    searchNum : int = Field(4, description='검색결과 이미지 갯수', example=4)
    

class VectorImageSearchVitReq(BaseModel):
    """
    ### [Request] vector image search vit
    """
    prompt : str = Field(description='프롬프트', example='검은색 안경')
    modelType : str = Field(VitModelType.l14, description='pretrained model 타입', example=VitModelType.l14)
    indexType : str = Field(VitIndexType.l2, description='인덱스 타입', example=VitIndexType.l2)
    searchNum : int = Field(4, description='검색결과 이미지 갯수', example=4)
    
    
class VectorImageSearchVitInputImgReq(BaseModel):
    """
    ### [Request] vector image search vit - input image
    """
    inputImage : str = Field(description='base64 이미지', example='')
    modelType : str = Field(VitModelType.l14, description='pretrained model 타입', example=VitModelType.l14)
    indexType : str = Field(VitIndexType.l2, description='인덱스 타입', example=VitIndexType.l2)
    searchNum : int = Field(4, description='검색결과 이미지 갯수', example=4)


class VectorImageSearchVitDataReq(VectorImageSearchVitReq):
    """
    ### [Request] vector image search vit data
    """
    querySend: bool = Field(True, description='쿼리 이미지 전송 여부', example=True)
    
    
class VectorImageSearchVitReportReq(BaseModel):
    """
    ### [Request] vector image search vit request
    """
    prompt : str = Field(description='프롬프트', example='검은색 안경')
    modelType : str = Field(VitModelType.l14, description='pretrained model 타입', example=VitModelType.l14)
    indexType : str = Field(VitIndexType.l2, description='인덱스 타입', example=VitIndexType.l2)
    
    
class VectorImageResult(BaseModel):
    image : str = Field("", description='이미지 데이터', example='')
    percents: float = Field(0.0, description='percents 값', example='')

#===============================================================================
#===============================================================================
#===============================================================================
#===============================================================================

class ImageGenerateRes(ResponseBase):
    """
    ### image generate response
    """
    imageLen : int = Field(0, description='실제 이미지 생성 갯수', example=1)
    
    @staticmethod
    def set_error(error,img_len=0):
        ImageGenerateRes.result = False
        ImageGenerateRes.error = str(error)
        ImageGenerateRes.imageLen = img_len
        
        return ImageGenerateRes
    
    @staticmethod
    def set_message(img_len):
        ImageGenerateRes.result = True
        ImageGenerateRes.error = None
        ImageGenerateRes.imageLen = img_len
        return ImageGenerateRes

class ImageGenerateDataRes(ResponseBase):
    """
    ### image generate Data response
    """
    imageData : str = Field('', description='이미지 데이터', example='')
    
    @staticmethod
    def set_error(error,img_data=''):
        ImageGenerateRes.result = False
        ImageGenerateRes.error = str(error)
        ImageGenerateRes.imageData = img_data
        
        return ImageGenerateRes
    
    @staticmethod
    def set_message(img_data):
        ImageGenerateRes.result = True
        ImageGenerateRes.error = None
        ImageGenerateRes.imageData = img_data
        return ImageGenerateRes
    
class BingCookieSetRes(ResponseBase):
    """
    ### bing cookie set response
    """
    currentCookie : str = Field('',description='현재 사용중인 쿠키 정보', example='')
    
    @staticmethod
    def set_error(error,current_cookie=''):
        BingCookieSetRes.result = False
        BingCookieSetRes.error = str(error)
        BingCookieSetRes.currentCookie = current_cookie
        
        return BingCookieSetRes
    
    @staticmethod
    def set_message(current_cookie):
        BingCookieSetRes.result = True
        BingCookieSetRes.error = None
        BingCookieSetRes.currentCookie = current_cookie
        return BingCookieSetRes
    

class VectorImageSerachDataRes(ResponseBase):
    """
    ### vector image data response
    """
    queryImage : str = Field("", description='쿼리 이미지', example="")
    vectorResult : List[VectorImageResult] = Field([], description='벡터 검색 결과', example=[])
    
    @staticmethod
    def set_error(error,vector_result=[],query_img=""):
        ImageGenerateRes.result = False
        ImageGenerateRes.error = str(error)
        ImageGenerateRes.vectorResult = vector_result
        ImageGenerateRes.queryImage = query_img
        
        return ImageGenerateRes
    
    @staticmethod
    def set_message(vector_result,query_img=""):
        ImageGenerateRes.result = True
        ImageGenerateRes.error = None
        ImageGenerateRes.vectorResult = vector_result
        ImageGenerateRes.queryImage = query_img
        
        return ImageGenerateRes