3333
3434function_executor = FunctionExecutor (CONFIG .get ('SANDBOX' ))
3535
36+
3637class FlibInstance :
3738 def __init__ (self , function_lib : dict , version : str ):
3839 self .function_lib = function_lib
3940 self .version = version
4041
42+
4143def encryption (message : str ):
4244 """
4345 加密敏感字段数据 加密方式是 如果密码是 1234567890 那么给前端则是 123******890
@@ -68,7 +70,8 @@ def encryption(message: str):
6870class FunctionLibModelSerializer (serializers .ModelSerializer ):
6971 class Meta :
7072 model = FunctionLib
71- fields = ['id' , 'name' , 'icon' , 'desc' , 'code' , 'input_field_list' ,'init_field_list' , 'init_params' , 'permission_type' , 'is_active' , 'user_id' , 'template_id' ,
73+ fields = ['id' , 'name' , 'icon' , 'desc' , 'code' , 'input_field_list' , 'init_field_list' , 'init_params' ,
74+ 'permission_type' , 'is_active' , 'user_id' , 'template_id' ,
7275 'create_time' , 'update_time' ]
7376
7477
@@ -148,7 +151,6 @@ class Query(serializers.Serializer):
148151 select_user_id = serializers .CharField (required = False , allow_null = True , allow_blank = True )
149152 function_type = serializers .CharField (required = False , allow_null = True , allow_blank = True )
150153
151-
152154 def get_query_set (self ):
153155 query_set = QuerySet (FunctionLib ).filter (
154156 (Q (user_id = self .data .get ('user_id' )) | Q (permission_type = 'PUBLIC' )))
@@ -269,7 +271,7 @@ class Operate(serializers.Serializer):
269271
270272 def is_valid (self , * , raise_exception = False ):
271273 super ().is_valid (raise_exception = True )
272- if not QuerySet (FunctionLib ).filter (id = self .data .get ('id' )).exists ():
274+ if not QuerySet (FunctionLib ).filter (user_id = self . data . get ( 'user_id' ), id = self .data .get ('id' )).exists ():
273275 raise AppApiException (500 , _ ('Function does not exist' ))
274276
275277 def delete (self , with_valid = True ):
@@ -285,7 +287,8 @@ def edit(self, instance, with_valid=True):
285287 if with_valid :
286288 self .is_valid (raise_exception = True )
287289 EditFunctionLib (data = instance ).is_valid (raise_exception = True )
288- edit_field_list = ['name' , 'desc' , 'code' , 'icon' , 'input_field_list' , 'init_field_list' , 'init_params' , 'permission_type' , 'is_active' ]
290+ edit_field_list = ['name' , 'desc' , 'code' , 'icon' , 'input_field_list' , 'init_field_list' , 'init_params' ,
291+ 'permission_type' , 'is_active' ]
289292 edit_dict = {field : instance .get (field ) for field in edit_field_list if (
290293 field in instance and instance .get (field ) is not None )}
291294
@@ -317,7 +320,8 @@ def one(self, with_valid=True):
317320 if function_lib .init_params :
318321 function_lib .init_params = json .loads (rsa_long_decrypt (function_lib .init_params ))
319322 if function_lib .init_field_list :
320- password_fields = [i ["field" ] for i in function_lib .init_field_list if i .get ("input_type" ) == "PasswordInput" ]
323+ password_fields = [i ["field" ] for i in function_lib .init_field_list if
324+ i .get ("input_type" ) == "PasswordInput" ]
321325 if function_lib .init_params :
322326 for k in function_lib .init_params :
323327 if k in password_fields and function_lib .init_params [k ]:
0 commit comments