批量获取接口

This commit is contained in:
2021-12-20 12:58:44 +08:00
parent c6500a9422
commit 9adb8f078b

24
hole.py
View File

@@ -163,6 +163,30 @@ def get_one():
} }
@app.route('/_api/v1/getmulti')
def get_multi():
username = get_current_username()
pids = request.args.getlist('pids')
pids = pids[:500] or [0]
posts = Post.query.filter(
Post.id.in_(pids)
).filter_by(
deleted=False
).order_by(
Post.id.desc()
).all()
data = [map_post(post, username) for post in posts]
return {
'code': 0,
'data': data
}
@app.route('/_api/v1/search') @app.route('/_api/v1/search')
def search(): def search():
username = get_current_username() username = get_current_username()