Commit 1a6f7523 authored by lvshibao's avatar lvshibao

获取req信息

parent a0cde045
...@@ -235,6 +235,7 @@ class TasksApi(viewsets.ViewSet): ...@@ -235,6 +235,7 @@ class TasksApi(viewsets.ViewSet):
return Response({'code': 0, 'msg': 'success', 'count': total_count, 'data': data_sort}) return Response({'code': 0, 'msg': 'success', 'count': total_count, 'data': data_sort})
@action(['post'], detail=False) @action(['post'], detail=False)
@get_account_info
def static(self, req: Request): def static(self, req: Request):
""" """
获取违规项分析 获取违规项分析
......
import logging import logging
import requests import requests
from functools import wraps
from rest_framework.request import Request from rest_framework.request import Request
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def get_account_info(func): def get_account_info(func):
def wrapper(req: Request, *args, **kw): @wraps(func)
def account_info(req: Request, *args, **kw):
# info = requests.get('http://172.17.1.74:8248/getUserInfo', headers={ # 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'}) # 'Cookie': 'aiforce=a038baa0-9a23-45f6-8042-a01a2309f1a8; JSESSIONID=fef7de70-7157-4b62-abf3-6fe9d2357350; csrfToken=wFVUJX9rT2jyDderTzHKUjaq; EGG_SESS=pRumla5Jc0N4k1qJnqyfP0SIlONA60YZCFEMh2sO_ywQrldAhhiX4Y2exluQfYfm'})
# print(info.json()) # print(info.json())
...@@ -14,7 +18,7 @@ def get_account_info(func): ...@@ -14,7 +18,7 @@ def get_account_info(func):
logger.info('req中的query_params为: ', req.query_params) logger.info('req中的query_params为: ', req.query_params)
logger.info('req中的query_params为: ', req.parsers()) logger.info('req中的query_params为: ', req.parsers())
return func(Request, *args, **kw) return func(Request, *args, **kw)
return wrapper
return account_info
# get_account_info() # 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