refactor(model): rename Postcard.country -> country_to for clear semantics - country_from: origin country (where postcard was sent from) - country_to: destination country (where postcard was sent to) - Profile.country remains as user's home country - Updated all routes, schemas, templates, and API endpoints

This commit is contained in:
2026-07-07 13:43:39 +08:00
parent 806c9ba8a0
commit ad6f2b2ff2
10 changed files with 47 additions and 45 deletions

View File

@@ -103,8 +103,8 @@ class PostcardCreate(BaseModel):
card_number: str
status: str
recipient_name: str | None = None
country: str | None = None
country_from: str | None = None
country_to: str | None = None
send_time: str | None = None
arrival_time: str | None = None
sender_name: str | None = None
@@ -115,8 +115,8 @@ class PostcardUpdate(BaseModel):
card_number: str | None = None
status: str | None = None
recipient_name: str | None = None
country: str | None = None
country_from: str | None = None
country_to: str | None = None
send_time: str | None = None
arrival_time: str | None = None
sender_name: str | None = None
@@ -129,8 +129,8 @@ class PostcardOut(BaseModel):
card_number: str
status: str
recipient_name: str | None
country: str | None
country_from: str | None
country_to: str | None
send_time: datetime | None
arrival_time: datetime | None
sender_name: str | None
@@ -294,8 +294,8 @@ def create_postcard(
card_number=cn,
status=body.status,
recipient_name=body.recipient_name,
country=body.country.strip().upper() if body.country else None,
country_from=body.country_from.strip().upper() if body.country_from else None,
country_to=body.country_to.strip().upper() if body.country_to else None,
send_time=_parse_date(body.send_time),
arrival_time=_parse_date(body.arrival_time),
sender_name=body.sender_name,
@@ -340,8 +340,8 @@ def update_postcard(
if dup:
raise HTTPException(status_code=409, detail="Card number already exists")
pc.card_number = cn
if body.country is not None:
pc.country = body.country.strip().upper() if body.country else None
if body.country_to is not None:
pc.country_to = body.country_to.strip().upper() if body.country_to else None
if body.country_from is not None:
pc.country_from = body.country_from.strip().upper() if body.country_from else None
for field in ("send_time", "arrival_time", "receive_time"):