Skip to content

Commit 33c4051

Browse files
committed
Add shop search by purchaseType
1 parent 3afb12f commit 33c4051

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

app/core/search.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
ITEM_BG_TYPE_REVERSE,
3131
ITEM_TYPE_REVERSE,
3232
PAY_TYPE_NAME_REVERSE,
33+
PURCHASE_TYPE_NAME_REVERSE,
3334
QUEST_FLAG_REVERSE,
3435
QUEST_TYPE_REVERSE,
3536
SHOP_TYPE_NAME_REVERSE,
@@ -499,12 +500,17 @@ async def search_shop(
499500
pay_type_ints = {
500501
PAY_TYPE_NAME_REVERSE[pay_type] for pay_type in search_param.payType
501502
}
503+
purchase_type_ints = {
504+
PURCHASE_TYPE_NAME_REVERSE[purchase_type]
505+
for purchase_type in search_param.purchaseType
506+
}
502507

503508
matches = await get_shop_search(
504509
conn,
505510
event_ids=search_param.eventId,
506511
shop_type_ints=shop_type_ints,
507512
pay_type_ints=pay_type_ints,
513+
purchase_type_ints=purchase_type_ints,
508514
)
509515

510516
if search_param.name:

app/db/helpers/event.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ async def get_shop_search(
7171
event_ids: Iterable[int] | None = None,
7272
shop_type_ints: Iterable[int] | None = None,
7373
pay_type_ints: Iterable[int] | None = None,
74+
purchase_type_ints: Iterable[int] | None = None,
7475
) -> list[MstShop]:
7576
from_clause: Join | Table = mstShop
7677
where_clause: list[_ColumnExpressionArgument[bool]] = [true()]
@@ -81,6 +82,8 @@ async def get_shop_search(
8182
where_clause.append(mstShop.c.shopType.in_(shop_type_ints))
8283
if pay_type_ints:
8384
where_clause.append(mstShop.c.payType.in_(pay_type_ints))
85+
if purchase_type_ints:
86+
where_clause.append(mstShop.c.purchaseType.in_(purchase_type_ints))
8487

8588
shop_search_stmt = (
8689
select(mstShop).distinct().select_from(from_clause).where(and_(*where_clause))

app/schemas/enums.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
NiceFuncType,
4646
NiceGender,
4747
NicePayType,
48+
NicePurchaseType,
4849
NiceQuestFlag,
4950
NiceQuestType,
5051
NiceShopType,
@@ -573,6 +574,10 @@ class EventRewardSceneType(IntEnum):
573574

574575
PAY_TYPE_NAME_REVERSE: dict[NicePayType, int] = {v: k for k, v in PAY_TYPE_NAME.items()}
575576

577+
PURCHASE_TYPE_NAME_REVERSE: dict[NicePurchaseType, int] = {
578+
v: k for k, v in PURCHASE_TYPE_NAME.items()
579+
}
580+
576581

577582
### EventPointActivity.objectType ###
578583

app/schemas/search.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
NiceGender,
2626
NiceItemType,
2727
NicePayType,
28+
NicePurchaseType,
2829
NiceQuestFlag,
2930
NiceQuestType,
3031
NiceShopType,
@@ -522,6 +523,7 @@ class ShopSearchQueryParams:
522523
eventId: list[int] = Query([])
523524
type: list[NiceShopType] = Query([])
524525
payType: list[NicePayType] = Query([])
526+
purchaseType: list[NicePurchaseType] = Query([])
525527

526528
def hasSearchParams(self) -> bool:
527529
return any(
@@ -530,6 +532,7 @@ def hasSearchParams(self) -> bool:
530532
self.eventId,
531533
self.type,
532534
self.payType,
535+
self.purchaseType,
533536
]
534537
)
535538

0 commit comments

Comments
 (0)