From d6fcf919b3cf31e9471b7ee1ae6a72498c3f4129 Mon Sep 17 00:00:00 2001 From: aaron <> Date: Mon, 24 Mar 2025 22:27:33 +0800 Subject: [PATCH] update --- app/models/merchant.py | 6 ++++++ app/sql/v1.1.sql | 7 ++++++- jobs.sqlite | Bin 24576 -> 24576 bytes 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/models/merchant.py b/app/models/merchant.py index 653df15..698e6ab 100644 --- a/app/models/merchant.py +++ b/app/models/merchant.py @@ -21,6 +21,7 @@ class MerchantDB(Base): id = Column(Integer, primary_key=True, autoincrement=True) user_id = Column(Integer, ForeignKey("users.userid"), nullable=False) # 归属用户 + community_id = Column(Integer, ForeignKey("communities.id"), nullable=False) # 所属小区 name = Column(String(100), nullable=False) business_hours = Column(String(100), nullable=False) # 营业时间,如 "09:00-22:00" address = Column(String(200), nullable=False) @@ -41,6 +42,7 @@ class MerchantDB(Base): class MerchantCreate(BaseModel): user_id: int + community_id: int # 所属小区ID name: str = Field(..., max_length=100) business_hours: str = Field(..., max_length=100) address: str = Field(..., max_length=200) @@ -55,6 +57,7 @@ class MerchantCreate(BaseModel): class MerchantApply(BaseModel): name: str = Field(..., max_length=100) + community_id: int = Field(..., ge=0) # 所属小区ID business_hours: str = Field(..., max_length=100) address: str = Field(..., max_length=200) longitude: float = Field(..., ge=-180, le=180, description="经度") @@ -70,6 +73,7 @@ class MerchantApply(BaseModel): class MerchantUpdate(BaseModel): user_id: Optional[int] = None + community_id: Optional[int] = None # 所属小区ID name: Optional[str] = Field(None, max_length=100) business_hours: Optional[str] = Field(None, max_length=100) address: Optional[str] = Field(None, max_length=200) @@ -85,6 +89,8 @@ class MerchantUpdate(BaseModel): class MerchantInfo(BaseModel): id: int user_id: int + community_id: int # 所属小区ID + community_name: Optional[str] = None # 用于关联查询显示小区名称 user_phone: Optional[str] = None user_nickname: Optional[str] = None online_pay_count: Optional[int] = 0 diff --git a/app/sql/v1.1.sql b/app/sql/v1.1.sql index f5b736e..e7c4eda 100644 --- a/app/sql/v1.1.sql +++ b/app/sql/v1.1.sql @@ -154,4 +154,9 @@ ALTER TABLE merchant_orders ADD COLUMN product_delivery_deadline_time DATETIME COMMENT '配送截止时间快照' AFTER product_delivery_date; ---====FINISH 3.23==== \ No newline at end of file +--====FINISH 3.23==== + +ALTER TABLE merchants +ADD COLUMN community_id INT COMMENT '所属小区' AFTER user_id, +ADD CONSTRAINT fk_merchant_community +FOREIGN KEY (community_id) REFERENCES communities(id) \ No newline at end of file diff --git a/jobs.sqlite b/jobs.sqlite index f30f845c4af30aaf1cbc1ca09a7ab25d3e7f6419..808b71e40228a2086e7bfe7133c06e6884c24ebd 100644 GIT binary patch delta 19 acmZoTz}Rqrae_3X=0q81M$L^03*rGn&jx}3 delta 19 acmZoTz}Rqrae_3X^h6nFM(K?S3*rGm{RU