Files
fastAPI/app/models/finished_goods.py
Misaka_Company e203008866 feat: add ORM models for finished goods tables
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-11 11:02:24 +08:00

58 lines
2.0 KiB
Python

from datetime import datetime
from sqlalchemy import BigInteger, DateTime, Index, Numeric, String, func
from sqlalchemy.orm import Mapped, mapped_column
from app.core.database import Base
SCHEMA = "CargoTrace"
class FinishedGoodsLocation(Base):
__tablename__ = "finished_goods_location"
__table_args__ = (
Index("uk_zongpai_no", "zongpai_no", unique=True),
Index("idx_fgl_location_code", "location_code"),
{"schema": SCHEMA},
)
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
zongpai_no: Mapped[str] = mapped_column(String(64), nullable=False)
location_code: Mapped[str] = mapped_column(String(64), nullable=False)
created_at: Mapped[datetime] = mapped_column(
DateTime, nullable=False, server_default=func.getdate()
)
class FinishedGoodsBox(Base):
__tablename__ = "finished_goods_box"
__table_args__ = (
Index("uk_paichan_box", "paichan_no", "box_no", unique=True),
Index("idx_fgb_paichan_no", "paichan_no"),
{"schema": SCHEMA},
)
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
paichan_no: Mapped[str] = mapped_column(String(64), nullable=False)
box_no: Mapped[int] = mapped_column(nullable=False)
created_at: Mapped[datetime] = mapped_column(
DateTime, nullable=False, server_default=func.getdate()
)
class FinishedGoodsBoxItem(Base):
__tablename__ = "finished_goods_box_item"
__table_args__ = (
Index("idx_fgbi_box_id", "box_id"),
Index("idx_fgbi_zongpai_no", "zongpai_no"),
{"schema": SCHEMA},
)
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
box_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
zongpai_no: Mapped[str] = mapped_column(String(64), nullable=False)
quantity: Mapped[float | None] = mapped_column(Numeric(18, 3), nullable=True)
created_at: Mapped[datetime] = mapped_column(
DateTime, nullable=False, server_default=func.getdate()
)