|
@@ -1,6 +1,6 @@
|
|
|
from flask import request
|
|
|
from flask_login import current_user # type: ignore
|
|
|
-from flask_restful import Resource, marshal_with, reqparse # type: ignore
|
|
|
+from flask_restful import Resource, marshal_with, reqparse, marshal # type: ignore
|
|
|
from werkzeug.exceptions import Forbidden
|
|
|
|
|
|
from controllers.console import api
|
|
@@ -51,6 +51,19 @@ class TagListApi(Resource):
|
|
|
|
|
|
return response, 200
|
|
|
|
|
|
+class TagPageListApi(Resource):
|
|
|
+
|
|
|
+ @setup_required
|
|
|
+ @login_required
|
|
|
+ @account_initialization_required
|
|
|
+ def get(self):
|
|
|
+ page = request.args.get("page", default=1, type=int)
|
|
|
+ limit = request.args.get("limit", default=20, type=int)
|
|
|
+ tag_type = request.args.get("tag_type", type=str, default="")
|
|
|
+ tags, total = TagService.get_page_tags(page, limit, tag_type, current_user.current_tenant_id)
|
|
|
+ data = marshal(tags, tag_fields)
|
|
|
+ response = {"data": data, "has_more": len(tags) == limit, "limit": limit, "total": total, "page": page}
|
|
|
+ return response, 200
|
|
|
|
|
|
class TagUpdateDeleteApi(Resource):
|
|
|
@setup_required
|
|
@@ -136,6 +149,7 @@ class TagBindingDeleteApi(Resource):
|
|
|
|
|
|
|
|
|
api.add_resource(TagListApi, "/tags")
|
|
|
+api.add_resource(TagPageListApi, "/tags/page")
|
|
|
api.add_resource(TagUpdateDeleteApi, "/tags/<uuid:tag_id>")
|
|
|
api.add_resource(TagBindingCreateApi, "/tag-bindings/create")
|
|
|
api.add_resource(TagBindingDeleteApi, "/tag-bindings/remove")
|