Files
dashboard/backend/models/model.py
T
2026-03-04 18:17:34 +08:00

38 lines
1.4 KiB
Python

from sqlalchemy import Column, Integer, String, DateTime, func
from database import Base
class Model(Base):
"""耳机型号模型"""
__tablename__ = "model"
__table_args__ = {"comment": "耳机型号"}
id = Column(Integer, primary_key=True, autoincrement=True, comment="型号 ID")
brand_name = Column(String(100), nullable=False, comment="品牌名称")
name = Column(String(100), nullable=False, comment="型号名称")
form = Column(String(100), nullable=True, comment="形式")
rig = Column(String(100), nullable=True, comment="阻抗")
source = Column(String(100), nullable=True, comment="来源")
eq_key = Column(String(255), nullable=True, comment="EQ 键")
create_at = Column(DateTime, nullable=False, default=func.now(), comment="创建时间")
__table_args__ = (
{"comment": "耳机型号"},
)
def __repr__(self):
return f"<Model(id={self.id}, brand_name='{self.brand_name}', name='{self.name}')>"
def to_dict(self):
"""Convert to dictionary"""
return {
"id": self.id,
"brand_name": self.brand_name,
"name": self.name,
"form": self.form,
"rig": self.rig,
"source": self.source,
"eq_key": self.eq_key,
"create_at": self.create_at.isoformat() if self.create_at else None
}