Skip to content

Commit

Permalink
为过滤动态做准备,支持中奖数的录入
Browse files Browse the repository at this point in the history
数据库那里就不需要了吧。。。
  • Loading branch information
yjqiang committed Mar 31, 2019
1 parent 4246f55 commit cf465c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dyn/bili_data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class DynRaffleStatus:
prize_cmt_1st = attr.ib(validator=attr.validators.instance_of(str)) # 奖品描述这里必须str,下同,且不提供type转换
prize_cmt_2nd = attr.ib(default='', validator=attr.validators.instance_of(str))
prize_cmt_3rd = attr.ib(default='', validator=attr.validators.instance_of(str))
prize_num_1st = attr.ib(default=-1, validator=attr.validators.instance_of(int))
prize_num_2nd = attr.ib(default=-1, validator=attr.validators.instance_of(int))
prize_num_3rd = attr.ib(default=-1, validator=attr.validators.instance_of(int))

# 命名模仿attrs的astuple,非数据库数据转化为数据库数据直接使用,无需在sqlite内再次转换类型
def as_sql_values(self):
Expand Down
10 changes: 9 additions & 1 deletion tasks/dyn_raffle_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ async def check_and_fetch_raffle(user, doc_id, handle_status=-1, feed_limit=Fals
first_prize_cmt = data['first_prize_cmt']
second_prize_cmt = data.get('second_prize_cmt', '')
third_prize_cmt = data.get('third_prize_cmt', '')

first_prize = data['first_prize']
second_prize = data.get('second_prize', 0)
third_prize = data.get('third_prize', 0)

# 需要邮寄???????存疑
# post = data['need_post']
dyn_raffle_status = DynRaffleStatus(
Expand All @@ -169,7 +174,10 @@ async def check_and_fetch_raffle(user, doc_id, handle_status=-1, feed_limit=Fals
handle_status=handle_status,
prize_cmt_1st=first_prize_cmt,
prize_cmt_2nd=second_prize_cmt,
prize_cmt_3rd=third_prize_cmt
prize_cmt_3rd=third_prize_cmt,
prize_num_1st=first_prize,
prize_num_2nd=second_prize,
prize_num_3rd=third_prize
)
print('获取到的抽奖信息为', dyn_raffle_status)
return 0, dyn_raffle_status
Expand Down

0 comments on commit cf465c6

Please sign in to comment.