31 lines
1.6 KiB
Python
31 lines
1.6 KiB
Python
from sqlalchemy import Column, Integer, String, Boolean, DateTime
|
|
from sqlalchemy.sql import func
|
|
from ..core.database import Base
|
|
|
|
class Account(Base):
|
|
__tablename__ = "accounts"
|
|
|
|
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
|
username = Column(String(500), unique=True, index=True, nullable=False, comment="用户名")
|
|
password = Column(String(1000), nullable=False, comment="密码")
|
|
status = Column(Integer, default=1, comment="状态: 1-正常, 0-禁用")
|
|
today_updated = Column(Integer, default=0, comment="是否更新")
|
|
project_name = Column(String(1000), comment="项目名称")
|
|
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
|
|
update_time = Column(String(1000), nullable=False, comment="更新时间跨度")
|
|
max_variation = Column(Integer, default=1, comment="变化量的绝对值,单位是毫米")
|
|
yh_id = Column(String(1000), comment="宇恒一号用户id")
|
|
cl_name = Column(String(100), nullable=True, comment="测量人员")
|
|
# device_name = Column(String(1000), comment="设备名称")
|
|
# device_port = Column(String(1000), comment="设备端口")
|
|
# device_ip = Column(String(1000), comment="设备局域网内ip地址")
|
|
|
|
|
|
# 模型转字典
|
|
def to_dict(self):
|
|
"""将模型实例转换为字典,支持 Pydantic 序列化"""
|
|
return {
|
|
column.name: getattr(self, column.name)
|
|
for column in self.__table__.columns
|
|
} |