|
|
|
|
|
""" |
|
@File : product_model.py |
|
@Time : 2024/08/30 |
|
@Project : https://github.com/PeterH0323/Streamer-Sales |
|
@Author : HinGwenWong |
|
@Version : 1.0 |
|
@Desc : 商品数据类型定义 |
|
""" |
|
|
|
from datetime import datetime |
|
from typing import List |
|
from pydantic import BaseModel |
|
from sqlmodel import Field, Relationship, SQLModel |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProductInfo(SQLModel, table=True): |
|
"""商品信息""" |
|
|
|
__tablename__ = "product_info" |
|
|
|
product_id: int | None = Field(default=None, primary_key=True, unique=True) |
|
product_name: str = Field(index=True, unique=True) |
|
product_class: str |
|
heighlights: str |
|
image_path: str |
|
instruction: str |
|
departure_place: str |
|
delivery_company: str |
|
selling_price: float |
|
amount: int |
|
upload_date: datetime = datetime.now() |
|
delete: bool = False |
|
|
|
user_id: int | None = Field(default=None, foreign_key="user_info.user_id") |
|
|
|
sales_info: list["SalesDocAndVideoInfo"] = Relationship(back_populates="product_info") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProductPageItem(BaseModel): |
|
product_list: List[ProductInfo] = [] |
|
currentPage: int = 0 |
|
pageSize: int = 0 |
|
totalSize: int = 0 |
|
|
|
|
|
class ProductQueryItem(BaseModel): |
|
instructionPath: str = "" |
|
|