from datetime import datetime
from enum import IntEnum
from typing import Optional

from pydantic import BaseModel
from sqlalchemy import Column, String, Enum as SQLAlchemyEnum, Integer, BigInteger, DateTime, Text, Float, Boolean
from app.models.base_model import Base

class AppType(IntEnum):
    BASIC = 0
    RAGFLOW = 1
    BISHENG = 2



class AppRegisterModel(Base):
    __tablename__ = "app_register"
    id = Column(String(36), primary_key=True)
    name = Column(String(255))
    status = Column(Integer, nullable=False, default=1)
    created_at = Column(DateTime, default=datetime.now())
    updated_at = Column(DateTime, default=datetime.now(), onupdate=datetime.now())


    # to_dict 方法
    def to_dict(self):
        return {
            'id': self.id,
            'name': self.name,
            'status': self.status
        }


class DfTokenModel(Base):
    __tablename__ = "df_api_token"
    id = Column(String(36), primary_key=True)
    token = Column(String(36))
    created_at = Column(DateTime, default=datetime.now())
    updated_at = Column(DateTime, default=datetime.now(), onupdate=datetime.now())


    # to_dict 方法
    def to_dict(self):
        return {
            'id': self.id,
            'token': self.token,
            'created_at': self.created_at.strftime('%Y-%m-%d %H:%M:%S'),
            # 'updated_at': self.updated_at.strftime('%Y-%m-%d %H:%M:%S')
        }


class DfToken(BaseModel):
    image: Optional[str] = ""
    clean: Optional[str] = ""
    report: Optional[str] = ""
    doc: Optional[str] = ""
    title: Optional[str] = ""
    paper: Optional[str] = ""
    equipment: Optional[str] = ""


class AppRegister(BaseModel):
    rg: Optional[int] = 0
    bs: Optional[int] = 0
    df: Optional[int] = 0
