Files
shanxia2.0/backend/app/models/pl_vehicle_fuel_card.py
T

30 lines
1.6 KiB
Python

"""车牌与油卡绑定台账。"""
from datetime import datetime
from sqlalchemy import Column, Computed, DateTime, Integer, SmallInteger, String, UniqueConstraint
from app.core.database import Base
class PlVehicleFuelCard(Base):
__tablename__ = "pl_vehicle_fuel_card"
__table_args__ = (
UniqueConstraint("tenant_no", "license_plate", "active_marker", name="uk_fuel_card_plate"),
UniqueConstraint("tenant_no", "card_no", "active_marker", name="uk_fuel_card_number"),
)
id = Column(String(64), primary_key=True, comment="主键UUID")
license_plate = Column(String(20), nullable=False, comment="车牌号")
card_no = Column(String(64), nullable=False, comment="油卡卡号")
tenant_no = Column(String(64), nullable=False, comment="租户编号")
order_num = Column(Integer, nullable=True, comment="排序号")
remark = Column(String(512), nullable=True, comment="备注")
create_by = Column(String(64), nullable=True, comment="创建人")
create_dept_id = Column(String(64), nullable=False, default="", comment="创建部门")
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
update_by = Column(String(64), nullable=True, comment="更新人")
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
# MySQL 5.7 没有部分唯一索引;NULL 允许保留多次软删除的历史记录。
active_marker = Column(Integer, Computed("CASE WHEN del_flag = 0 THEN 1 ELSE NULL END", persisted=True))