Skip to content

Commit

Permalink
chore: 升级到 JKit v3.0.0b2
Browse files Browse the repository at this point in the history
  • Loading branch information
FHU-yezi committed Jan 31, 2025
1 parent b9b21de commit 9e03428
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 30 deletions.
2 changes: 1 addition & 1 deletion backend/api/v1/articles.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async def get_word_freq_handler(

article_info = await article.info
title = article_info.title
text = article_info.text_content
text = article_info.content_text

word_freq = dict(Counter(await splitter.split(text)).most_common(100))

Expand Down
16 changes: 8 additions & 8 deletions backend/api/v1/jpep/ftn_macket.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime
from typing import Annotated, Literal

from jkit.jpep.platform_settings import PlatformSettings
from jkit.jpep.rules import Rules
from litestar import Response, Router, get
from litestar.params import Parameter
from msgspec import Struct, field
Expand All @@ -23,7 +23,7 @@
"1d": "day",
}

PLATFORM_SETTINGS = PlatformSettings()
RULES = Rules()


class GetRulesResponse(Struct, **RESPONSE_STRUCT_CONFIG):
Expand All @@ -42,16 +42,16 @@ class GetRulesResponse(Struct, **RESPONSE_STRUCT_CONFIG):
},
)
async def get_rules_handler() -> Response:
settings = await PLATFORM_SETTINGS.get_data()
rules = await RULES.get_rules()

return success(
data=GetRulesResponse(
is_open=settings.opening,
is_open=rules.opening,
# TODO
buy_order_minimum_price=settings.ftn_sell_trade_minimum_price,
sell_order_minimum_price=settings.ftn_buy_trade_minimum_price,
FTN_order_fee=settings.ftn_trade_fee,
goods_order_fee=settings.goods_trade_fee,
buy_order_minimum_price=rules.ftn_buy_trade_minimum_price,
sell_order_minimum_price=rules.ftn_buy_trade_minimum_price,
FTN_order_fee=rules.ftn_trade_fee,
goods_order_fee=rules.goods_trade_fee,
)
)

Expand Down
21 changes: 17 additions & 4 deletions backend/api/v1/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from jkit.exceptions import ResourceUnavailableError
from jkit.identifier_check import is_user_slug
from jkit.identifier_convert import article_slug_to_url, user_slug_to_url
from jkit.user import MembershipEnum, User
from jkit.user import MembershipType, User
from litestar import Response, Router, get
from litestar.params import Parameter
from litestar.status_codes import HTTP_400_BAD_REQUEST
Expand All @@ -26,6 +26,19 @@
from models.jianshu.lottery_win_record import LotteryWinRecord
from models.jianshu.user import User as DbUser

MembershipTextType = Literal[
"铜牌", "银牌", "金牌", "白金", "(旧版)普通会员", "(旧版)尊享会员"
]

MEMBERSHIP_TYPE_TO_TEXT: dict[MembershipType, MembershipTextType] = {
"BRONZE": "铜牌",
"SILVER": "银牌",
"GOLD": "金牌",
"PLATINA": "白金",
"LEGACY_ORDINARY": "(旧版)普通会员",
"LEGACY_DISTINGUISHED": "(旧版)尊享会员",
}


class GetVipInfoResponse(Struct, **RESPONSE_STRUCT_CONFIG):
user_name: str
Expand Down Expand Up @@ -67,9 +80,9 @@ async def get_vip_info_handler(
user_name = user_info.name
membership_info = user_info.membership_info

is_vip = membership_info.type != MembershipEnum.NONE
type_ = membership_info.type.value.replace("会员", "")
expire_date = membership_info.expired_at
is_vip = membership_info.type != "NONE"
type_ = MEMBERSHIP_TYPE_TO_TEXT[membership_info.type]
expire_date = membership_info.expire_time

return success(
data=GetVipInfoResponse(
Expand Down
3 changes: 1 addition & 2 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ authors = [{ name = "FHU-yezi", email = "[email protected]" }]
requires-python = ">=3.9"
dependencies = [
"httptools>=0.6.0",
"httpx<0.28.0",
"jkit>=3.0.0a16",
"jkit>=3.0.0b2",
"psycopg[binary]>=3.2.0",
"sshared[config, postgres]>=0.18.0",
"sspeedup[api-litestar]>=0.25.0",
Expand Down
4 changes: 2 additions & 2 deletions backend/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ h2==4.1.0
hpack==4.0.0
httpcore==1.0.7
httptools==0.6.4
httpx==0.27.2
httpx==0.28.1
hyperframe==6.0.1
idna==3.10
importlib-metadata==8.5.0 ; python_full_version < '3.10'
jkit==3.0.0a16
jkit==3.0.0b2
litestar==2.13.0
litestar-htmx==0.4.0
markdown-it-py==3.0.0
Expand Down
4 changes: 2 additions & 2 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ h2==4.1.0
hpack==4.0.0
httpcore==1.0.7
httptools==0.6.4
httpx==0.27.2
httpx==0.28.1
hyperframe==6.0.1
idna==3.10
importlib-metadata==8.5.0 ; python_full_version < '3.10'
jkit==3.0.0a16
jkit==3.0.0b2
litestar==2.13.0
litestar-htmx==0.4.0
markdown-it-py==3.0.0
Expand Down
18 changes: 7 additions & 11 deletions backend/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9e03428

Please sign in to comment.