mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-04 21:47:28 +08:00
Code refactoring
- Code refactoring - Fix a bug that the other player will not become the host of the room at once, when the player disconnect in link play. > Maybe add many unknown bugs. XD > The song database `arcsong.db` will not used in the future. You can use a tool in `tool` folder to import old data.
This commit is contained in:
38
latest version/server/present.py
Normal file
38
latest version/server/present.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from core.error import ArcError
|
||||
from core.present import UserPresent, UserPresentList
|
||||
from core.sql import Connect
|
||||
from core.user import UserOnline
|
||||
from flask import Blueprint, request
|
||||
|
||||
from .auth import auth_required
|
||||
from .func import error_return, success_return
|
||||
|
||||
bp = Blueprint('present', __name__, url_prefix='/present')
|
||||
|
||||
|
||||
@bp.route('/me', methods=['GET']) # 用户奖励信息
|
||||
@auth_required(request)
|
||||
def present_info(user_id):
|
||||
with Connect() as c:
|
||||
try:
|
||||
x = UserPresentList(c, UserOnline(c, user_id))
|
||||
x.select_user_presents()
|
||||
|
||||
return success_return(x.to_dict())
|
||||
except ArcError as e:
|
||||
return error_return(e)
|
||||
return error_return()
|
||||
|
||||
|
||||
@bp.route('/me/claim/<present_id>', methods=['POST']) # 礼物确认
|
||||
@auth_required(request)
|
||||
def claim_present(user_id, present_id):
|
||||
with Connect() as c:
|
||||
try:
|
||||
x = UserPresent(c, UserOnline(c, user_id))
|
||||
x.claim_user_present(present_id)
|
||||
|
||||
return success_return()
|
||||
except ArcError as e:
|
||||
return error_return(e)
|
||||
return error_return()
|
||||
Reference in New Issue
Block a user