mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: 函数库删除接口 (#987)
This commit is contained in:
parent
0d59ab2be9
commit
b596b691ec
|
|
@ -174,6 +174,12 @@ class FunctionLibSerializer(serializers.Serializer):
|
|||
if not QuerySet(FunctionLib).filter(id=self.data.get('id'), user_id=self.data.get('user_id')).exists():
|
||||
raise AppApiException(500, '函数不存在')
|
||||
|
||||
def delete(self, with_valid=True):
|
||||
if with_valid:
|
||||
self.is_valid(raise_exception=True)
|
||||
QuerySet(FunctionLib).filter(id=self.data.get('id')).delete()
|
||||
return True
|
||||
|
||||
def edit(self, instance, with_valid=True):
|
||||
if with_valid:
|
||||
self.is_valid(raise_exception=True)
|
||||
|
|
|
|||
|
|
@ -71,6 +71,15 @@ class FunctionLibView(APIView):
|
|||
FunctionLibSerializer.Operate(data={'user_id': request.user.id, 'id': function_lib_id}).edit(
|
||||
request.data))
|
||||
|
||||
@action(methods=['DELETE'], detail=False)
|
||||
@swagger_auto_schema(operation_summary="删除函数",
|
||||
operation_id="删除函数",
|
||||
tags=['函数库'])
|
||||
@has_permissions(RoleConstants.ADMIN, RoleConstants.USER)
|
||||
def delete(self, request: Request, function_lib_id: str):
|
||||
return result.success(
|
||||
FunctionLibSerializer.Operate(data={'user_id': request.user.id, 'id': function_lib_id}).delete())
|
||||
|
||||
class Page(APIView):
|
||||
authentication_classes = [TokenAuth]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue