Commit 2189dcad authored by lvshibao's avatar lvshibao

添加获取req信息的装饰器

parent 71615ec5
......@@ -14,6 +14,7 @@ import logging
from pypinyin import Style, pinyin
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from inspect_report.utils.account import get_account_info
logger = logging.getLogger(__name__)
......@@ -233,6 +234,7 @@ class TasksApi(viewsets.ViewSet):
data_sort[i]['ratio'] = '{0}%'.format(int(data_sort[i]['ratio'] * 100))
return Response({'code': 0, 'msg': 'success', 'count': total_count, 'data': data_sort})
@get_account_info
@action(['post'], detail=False)
def static(self, req: Request):
"""
......
import logging
import requests
from rest_framework.request import Request
logger = logging.getLogger(__name__)
def get_account_info(func):
def wrapper(req: Request, *args, **kw):
# info = requests.get('http://172.17.1.74:8248/getUserInfo', headers={
# 'Cookie': 'aiforce=a038baa0-9a23-45f6-8042-a01a2309f1a8; JSESSIONID=fef7de70-7157-4b62-abf3-6fe9d2357350; csrfToken=wFVUJX9rT2jyDderTzHKUjaq; EGG_SESS=pRumla5Jc0N4k1qJnqyfP0SIlONA60YZCFEMh2sO_ywQrldAhhiX4Y2exluQfYfm'})
# print(info.json())
logger.info('req中的data为: ', req.DATA)
logger.info('req中的query_params为: ', req.query_params)
logger.info('req中的query_params为: ', req.parsers())
return func(Request, *args, **kw)
return wrapper
# get_account_info()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment