feat(api): support service tree editing (#437)

This commit is contained in:
pycook
2024-03-26 10:58:11 +08:00
committed by GitHub
parent ad3f96431c
commit a7586aa140
3 changed files with 27 additions and 7 deletions

View File

@@ -97,7 +97,7 @@ class PreferenceTreeApiView(APIView):
class PreferenceRelationApiView(APIView):
url_prefix = "/preference/relation/view"
url_prefix = ("/preference/relation/view", "/preference/relation/view/<int:_id>")
def get(self):
views, id2type, name2id = PreferenceManager.get_relation_view()
@@ -110,14 +110,20 @@ class PreferenceRelationApiView(APIView):
@args_validate(PreferenceManager.pref_rel_cls)
def post(self):
name = request.values.get("name")
is_public = request.values.get("is_public") in current_app.config.get('BOOL_TRUE')
cr_ids = request.values.get("cr_ids")
views, id2type, name2id = PreferenceManager.create_or_update_relation_view(name, cr_ids)
option = request.values.get("option") or None
views, id2type, name2id = PreferenceManager.create_or_update_relation_view(name, cr_ids, is_public=is_public,
option=option)
return self.jsonify(views=views, id2type=id2type, name2id=name2id)
@role_required(RoleEnum.CONFIG)
def put(self):
return self.post()
@args_required("name")
def put(self, _id):
views, id2type, name2id = PreferenceManager.create_or_update_relation_view(_id=_id, **request.values)
return self.jsonify(views=views, id2type=id2type, name2id=name2id)
@role_required(RoleEnum.CONFIG)
@args_required("name")