feat: add ORM models for finished goods tables
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
57
app/models/finished_goods.py
Normal file
57
app/models/finished_goods.py
Normal file
@@ -0,0 +1,57 @@
|
||||
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()
|
||||
)
|
||||
Reference in New Issue
Block a user