from datetime import datetime from context.common import common_db from sqlalchemy import Column, Integer, String, DateTime, func from sqlalchemy.orm import Mapped, mapped_column, relationship class FormFile(common_db.Base): __tablename__ = 'form_file' md: Mapped[str] = mapped_column(String(255), primary_key=True, comment='文件md') file_name: Mapped[str] = mapped_column(String(255), comment='文件名称') mime_type: Mapped[str] = mapped_column(String(255), comment='文件mime_type') user_id: Mapped[str] = mapped_column(String(255), comment='上传的用户id') common_type: Mapped[str] = mapped_column(String(255), comment='大分类的文件类型') create_time: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), comment='上传时间') file_url: Mapped[str] = mapped_column(String(500), comment='文件链接') # company_user:Mapped['CompanyUser'] = relationship(back_populates="form_file") def to_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}