diff --git a/app.py b/app.py index 0fedda1..d5dbfe7 100644 --- a/app.py +++ b/app.py @@ -7,6 +7,8 @@ from controller.api.bilirecorder_blueprint import blueprint as api_bilirecorder_ from controller.api.workflow_blueprint import blueprint as api_workflow_blueprint from controller.api.video_clip_blueprint import blueprint as api_video_clip_blueprint from controller.api.danmaku_clip_blueprint import blueprint as api_danmaku_clip_blueprint +from controller.api.posting_blueprint import blueprint as api_posting_blueprint +from controller.api.video_part_blueprint import blueprint as api_video_part_blueprint from model import db app = Flask(__name__) @@ -24,6 +26,8 @@ app.register_blueprint(api_bilirecorder_blueprint) app.register_blueprint(api_workflow_blueprint) app.register_blueprint(api_video_clip_blueprint) app.register_blueprint(api_danmaku_clip_blueprint) +app.register_blueprint(api_posting_blueprint) +app.register_blueprint(api_video_part_blueprint) with app.app_context(): # db.drop_all(app=app) db.create_all(app=app) diff --git a/controller/api/posting_blueprint.py b/controller/api/posting_blueprint.py new file mode 100644 index 0000000..6fb2ecf --- /dev/null +++ b/controller/api/posting_blueprint.py @@ -0,0 +1,19 @@ +from flask import Blueprint, jsonify +from model.Posting import Posting +from util.flask import not_found_json_response + +blueprint = Blueprint("api_posting", __name__, url_prefix="/api/posting") + + +@blueprint.get("/") +def get_all_posting(): + _posting = Posting.query.all() + return jsonify([_i.to_json() for _i in _posting]) + + +@blueprint.get("/") +def get_posting_detail(posting_id): + posting = Posting.query.get(posting_id) + if posting is None: + return not_found_json_response(id=posting_id) + return jsonify(posting.to_dict()) diff --git a/controller/api/video_part_blueprint.py b/controller/api/video_part_blueprint.py new file mode 100644 index 0000000..84395e9 --- /dev/null +++ b/controller/api/video_part_blueprint.py @@ -0,0 +1,18 @@ +from flask import Blueprint, jsonify +from model.VideoPart import VideoPart +from util.flask import not_found_json_response + +blueprint = Blueprint("api_video_part", __name__, url_prefix="/api/video_part") + +@blueprint.get("/") +def get_all_posting(): + _video_parts = VideoPart.query.all() + return jsonify([_i.to_json() for _i in _video_parts]) + + +@blueprint.get("/") +def get_posting_detail(video_part_id): + video_part = VideoPart.query.get(video_part_id) + if video_part is None: + return not_found_json_response(id=video_part_id) + return jsonify(video_part.to_dict())