30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
from sqlalchemy import Column, String, DateTime, Text, UUID, ForeignKey, Float, Integer
|
|
from sqlalchemy.orm import relationship
|
|
from apiApp.database import Base
|
|
import uuid
|
|
from datetime import datetime
|
|
|
|
|
|
class Audio(Base):
|
|
__tablename__ = "audio"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
filename = Column(Text, nullable=False)
|
|
index_date = Column(DateTime, default=datetime.utcnow)
|
|
file_path = Column(Text)
|
|
duration = Column(Float)
|
|
file_size = Column(Integer)
|
|
sourse = Column(Text, default="internal")
|
|
|
|
ai_conclusion = relationship("AiConclusion", back_populates="audio", cascade="all, delete-orphan")
|
|
|
|
def to_dict(self):
|
|
return {
|
|
"id": str(self.id),
|
|
"filename": self.filename,
|
|
"index_date": self.index_date.isoformat() if self.index_date else None,
|
|
"file_path": self.file_path,
|
|
"duration": self.duration,
|
|
"file_size": self.file_size,
|
|
"sourse": self.sourse
|
|
} |