-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from Lost-MSth/dev
Update to v2.10.0
- Loading branch information
Showing
50 changed files
with
1,323 additions
and
1,113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,42 @@ | ||
from core.error import ArcError, NoData | ||
from core.error import NoData | ||
from core.song import Song | ||
from core.sql import Connect, Query, Sql | ||
from flask import Blueprint, request | ||
|
||
from .api_auth import request_json_handle, role_required | ||
from .api_code import error_return, success_return | ||
from .api_auth import api_try, request_json_handle, role_required | ||
from .api_code import success_return | ||
from .constant import Constant | ||
|
||
bp = Blueprint('songs', __name__, url_prefix='/songs') | ||
|
||
|
||
@bp.route('/<string:song_id>', methods=['GET']) | ||
@role_required(request, ['select', 'select_song_info']) | ||
@api_try | ||
def songs_song_get(user, song_id): | ||
'''查询歌曲信息''' | ||
with Connect() as c: | ||
try: | ||
s = Song(c, song_id).select() | ||
return success_return(s.to_dict()) | ||
except ArcError as e: | ||
return error_return(e) | ||
return error_return() | ||
s = Song(c, song_id).select() | ||
return success_return(s.to_dict()) | ||
|
||
|
||
@bp.route('', methods=['GET']) | ||
@role_required(request, ['select', 'select_song_info']) | ||
@request_json_handle(request, optional_keys=Constant.QUERY_KEYS) | ||
@api_try | ||
def songs_get(data, user): | ||
'''查询全歌曲信息''' | ||
A = ['song_id', 'name'] | ||
B = ['song_id', 'name', 'rating_pst', | ||
'rating_prs', 'rating_ftr', 'rating_byn'] | ||
with Connect() as c: | ||
try: | ||
query = Query(A, A, B).from_data(data) | ||
x = Sql(c).select('chart', query=query) | ||
r = [] | ||
for i in x: | ||
r.append(Song(c).from_list(i)) | ||
|
||
if not r: | ||
raise NoData(api_error_code=-2) | ||
|
||
return success_return([x.to_dict() for x in r]) | ||
except ArcError as e: | ||
return error_return(e) | ||
return error_return() | ||
query = Query(A, A, B).from_data(data) | ||
x = Sql(c).select('chart', query=query) | ||
r = [] | ||
for i in x: | ||
r.append(Song(c).from_list(i)) | ||
|
||
if not r: | ||
raise NoData(api_error_code=-2) | ||
|
||
return success_return([x.to_dict() for x in r]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.