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 (
@@ -43,6 +45,7 @@ def get(self, request: Request):
4345 request_body = FunctionLibApi .Create .get_request_body_api (),
4446 tags = [_ ('Function' )])
4547 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
48+ @log (menu = _ ('Function' ), operate = _ ("Create function" ))
4649 def post (self , request : Request ):
4750 return result .success (FunctionLibSerializer .Create (data = {'user_id' : request .user .id }).insert (request .data ))
4851
@@ -55,6 +58,7 @@ class Debug(APIView):
5558 request_body = FunctionLibApi .Debug .get_request_body_api (),
5659 tags = [_ ('Function' )])
5760 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
61+ @log (menu = _ ('Function' ), operate = _ ("Debug function" ))
5862 def post (self , request : Request ):
5963 return result .success (
6064 FunctionLibSerializer .Debug (data = {'user_id' : request .user .id }).debug (
@@ -69,6 +73,7 @@ class Operate(APIView):
6973 request_body = FunctionLibApi .Edit .get_request_body_api (),
7074 tags = [_ ('Function' )])
7175 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
76+ @log (menu = _ ('Function' ), operate = _ ("Update function" ))
7277 def put (self , request : Request , function_lib_id : str ):
7378 return result .success (
7479 FunctionLibSerializer .Operate (data = {'user_id' : request .user .id , 'id' : function_lib_id }).edit (
@@ -79,6 +84,7 @@ def put(self, request: Request, function_lib_id: str):
7984 operation_id = _ ('Delete function' ),
8085 tags = [_ ('Function' )])
8186 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
87+ @log (menu = _ ('Function' ), operate = _ ("Delete function" ))
8288 def delete (self , request : Request , function_lib_id : str ):
8389 return result .success (
8490 FunctionLibSerializer .Operate (data = {'user_id' : request .user .id , 'id' : function_lib_id }).delete ())
@@ -88,6 +94,7 @@ def delete(self, request: Request, function_lib_id: str):
8894 operation_id = _ ('Get function details' ),
8995 tags = [_ ('Function' )])
9096 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
97+ @log (menu = _ ('Function' ), operate = _ ("Get function details" ))
9198 def get (self , request : Request , function_lib_id : str ):
9299 return result .success (
93100 FunctionLibSerializer .Operate (data = {'user_id' : request .user .id , 'id' : function_lib_id }).one ())
@@ -103,6 +110,7 @@ class Page(APIView):
103110 responses = result .get_page_api_response (FunctionLibApi .get_response_body_api ()),
104111 tags = [_ ('Function' )])
105112 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
113+ @log (menu = _ ('Function' ), operate = _ ("Get function list by pagination" ))
106114 def get (self , request : Request , current_page : int , page_size : int ):
107115 return result .success (
108116 FunctionLibSerializer .Query (
@@ -123,6 +131,7 @@ class Import(APIView):
123131 tags = [_ ("function" )]
124132 )
125133 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
134+ @log (menu = _ ('Function' ), operate = _ ("Import function" ))
126135 def post (self , request : Request ):
127136 return result .success (FunctionLibSerializer .Import (
128137 data = {'user_id' : request .user .id , 'file' : request .FILES .get ('file' )}).import_ ())
@@ -136,6 +145,7 @@ class Export(APIView):
136145 tags = [_ ("function" )]
137146 )
138147 @has_permissions (RoleConstants .ADMIN , RoleConstants .USER )
148+ @log (menu = _ ('Function' ), operate = _ ("Export function" ))
139149 def get (self , request : Request , id : str ):
140150 return FunctionLibSerializer .Operate (
141151 data = {'id' : id , 'user_id' : request .user .id }).export ()
0 commit comments