1414
1515from common .auth import TokenAuth , has_permissions
1616from common .constants .permission_constants import RoleConstants , Permission , Group , Operate
17+ from common .log .log import log
1718from common .response import result
1819from function_lib .serializers .function_lib_serializer import FunctionLibSerializer
1920from function_lib .swagger_api .function_lib_api import FunctionLibApi
@@ -29,6 +30,7 @@ class FunctionLibView(APIView):
2930 tags = [_ ('Function' )],
3031 manual_parameters = FunctionLibApi .Query .get_request_params_api ())
3132 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
33+ @log (menu = _ ('Function' ), operate = _ ("Get function list" ))
3234 def get (self , request : Request ):
3335 return result .success (
3436 FunctionLibSerializer .Query (
@@ -42,6 +44,7 @@ def get(self, request: Request):
4244 request_body = FunctionLibApi .Create .get_request_body_api (),
4345 tags = [_ ('Function' )])
4446 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
47+ @log (menu = _ ('Function' ), operate = _ ("Create function" ))
4548 def post (self , request : Request ):
4649 return result .success (FunctionLibSerializer .Create (data = {'user_id' : request .user .id }).insert (request .data ))
4750
@@ -54,6 +57,7 @@ class Debug(APIView):
5457 request_body = FunctionLibApi .Debug .get_request_body_api (),
5558 tags = [_ ('Function' )])
5659 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
60+ @log (menu = _ ('Function' ), operate = _ ("Debug function" ))
5761 def post (self , request : Request ):
5862 return result .success (
5963 FunctionLibSerializer .Debug (data = {'user_id' : request .user .id }).debug (
@@ -68,6 +72,7 @@ class Operate(APIView):
6872 request_body = FunctionLibApi .Edit .get_request_body_api (),
6973 tags = [_ ('Function' )])
7074 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
75+ @log (menu = _ ('Function' ), operate = _ ("Update function" ))
7176 def put (self , request : Request , function_lib_id : str ):
7277 return result .success (
7378 FunctionLibSerializer .Operate (data = {'user_id' : request .user .id , 'id' : function_lib_id }).edit (
@@ -78,6 +83,7 @@ def put(self, request: Request, function_lib_id: str):
7883 operation_id = _ ('Delete function' ),
7984 tags = [_ ('Function' )])
8085 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
86+ @log (menu = _ ('Function' ), operate = _ ("Delete function" ))
8187 def delete (self , request : Request , function_lib_id : str ):
8288 return result .success (
8389 FunctionLibSerializer .Operate (data = {'user_id' : request .user .id , 'id' : function_lib_id }).delete ())
@@ -87,6 +93,7 @@ def delete(self, request: Request, function_lib_id: str):
8793 operation_id = _ ('Get function details' ),
8894 tags = [_ ('Function' )])
8995 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
96+ @log (menu = _ ('Function' ), operate = _ ("Get function details" ))
9097 def get (self , request : Request , function_lib_id : str ):
9198 return result .success (
9299 FunctionLibSerializer .Operate (data = {'user_id' : request .user .id , 'id' : function_lib_id }).one ())
@@ -102,6 +109,7 @@ class Page(APIView):
102109 responses = result .get_page_api_response (FunctionLibApi .get_response_body_api ()),
103110 tags = [_ ('Function' )])
104111 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
112+ @log (menu = _ ('Function' ), operate = _ ("Get function list by pagination" ))
105113 def get (self , request : Request , current_page : int , page_size : int ):
106114 return result .success (
107115 FunctionLibSerializer .Query (
@@ -121,6 +129,7 @@ class Import(APIView):
121129 tags = [_ ("function" )]
122130 )
123131 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
132+ @log (menu = _ ('Function' ), operate = _ ("Import function" ))
124133 def post (self , request : Request ):
125134 return result .success (FunctionLibSerializer .Import (
126135 data = {'user_id' : request .user .id , 'file' : request .FILES .get ('file' )}).import_ ())
@@ -134,6 +143,7 @@ class Export(APIView):
134143 tags = [_ ("function" )]
135144 )
136145 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
146+ @log (menu = _ ('Function' ), operate = _ ("Export function" ))
137147 def get (self , request : Request , id : str ):
138148 return FunctionLibSerializer .Operate (
139149 data = {'id' : id , 'user_id' : request .user .id }).export ()
0 commit comments