代码格式化
This commit is contained in:
parent
2a9c70eee5
commit
821d6cf2db
|
@ -1 +0,0 @@
|
||||||
from rest_framework import serializers
|
|
|
@ -56,7 +56,7 @@ class EmployeeCreateUpdateSerializer(EmployeeBaseSerializer):
|
||||||
if instance.belong_dept:
|
if instance.belong_dept:
|
||||||
try:
|
try:
|
||||||
departmentId = instance.belong_dept.third_info['dh_id']
|
departmentId = instance.belong_dept.third_info['dh_id']
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
json_data = {
|
json_data = {
|
||||||
"service": "ehs",
|
"service": "ehs",
|
||||||
|
@ -116,7 +116,7 @@ class EmployeeCreateUpdateSerializer(EmployeeBaseSerializer):
|
||||||
if instance.belong_dept:
|
if instance.belong_dept:
|
||||||
try:
|
try:
|
||||||
departmentId = instance.belong_dept.third_info['dh_id']
|
departmentId = instance.belong_dept.third_info['dh_id']
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
if dhClient:
|
if dhClient:
|
||||||
third_info = instance.third_info
|
third_info = instance.third_info
|
||||||
|
|
|
@ -122,7 +122,7 @@ class LogDetailView(APIView):
|
||||||
with open(os.path.join(settings.LOG_PATH, name)) as f:
|
with open(os.path.join(settings.LOG_PATH, name)) as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
return Response(data)
|
return Response(data)
|
||||||
except:
|
except Exception:
|
||||||
raise NotFound(**LOG_NOT_FONED)
|
raise NotFound(**LOG_NOT_FONED)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,6 @@ class DahuaTestView(MyLoggingMixin, APIView):
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
# file_path_rela = '/media/default/avatar.png'
|
|
||||||
# _, res = dhClient.request(**dhapis['person_img_upload'], file_path_rela=file_path_rela)
|
|
||||||
_, res = dhClient.request(
|
_, res = dhClient.request(
|
||||||
url='/evo-apigw/evo-brm/1.0.0/person/subsystem/{}'.format(2059335),
|
url='/evo-apigw/evo-brm/1.0.0/person/subsystem/{}'.format(2059335),
|
||||||
method='get')
|
method='get')
|
||||||
|
@ -79,9 +77,8 @@ class XxCommonViewSet(CreateModelMixin, CustomGenericViewSet):
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
vdata = serializer.validated_data
|
vdata = serializer.validated_data
|
||||||
if vdata.get('code', ''):
|
if vdata.get('code', ''):
|
||||||
try:
|
dhapi = dhapis.get(vdata['code'], None)
|
||||||
dhapi = dhapis[vdata['code']]
|
if dhapi is None:
|
||||||
except:
|
|
||||||
raise ParseError(**TAPI_CODE_WRONG)
|
raise ParseError(**TAPI_CODE_WRONG)
|
||||||
vdata['url'] = dhapi['url']
|
vdata['url'] = dhapi['url']
|
||||||
vdata['method'] = dhapi['method']
|
vdata['method'] = dhapi['method']
|
||||||
|
@ -92,7 +89,8 @@ class XxCommonViewSet(CreateModelMixin, CustomGenericViewSet):
|
||||||
json=vdata.get('json', {}))
|
json=vdata.get('json', {}))
|
||||||
return Response(res)
|
return Response(res)
|
||||||
|
|
||||||
@action(methods=['get'], detail=False, permission_classes=[IsAuthenticated])
|
@action(methods=['get'], detail=False,
|
||||||
|
permission_classes=[IsAuthenticated])
|
||||||
def codes(self, request, pk=None):
|
def codes(self, request, pk=None):
|
||||||
"""获取请求短标识
|
"""获取请求短标识
|
||||||
|
|
||||||
|
@ -113,9 +111,8 @@ class DhCommonViewSet(CreateModelMixin, CustomGenericViewSet):
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
vdata = serializer.validated_data
|
vdata = serializer.validated_data
|
||||||
if vdata.get('code', ''):
|
if vdata.get('code', ''):
|
||||||
try:
|
xxapi = xxapis.get(vdata['code'], None)
|
||||||
xxapi = xxapis[vdata['code']]
|
if xxapi is None:
|
||||||
except:
|
|
||||||
raise ParseError(**TAPI_CODE_WRONG)
|
raise ParseError(**TAPI_CODE_WRONG)
|
||||||
vdata['url'] = xxapi['url']
|
vdata['url'] = xxapi['url']
|
||||||
vdata['method'] = xxapi['method']
|
vdata['method'] = xxapi['method']
|
||||||
|
@ -126,7 +123,8 @@ class DhCommonViewSet(CreateModelMixin, CustomGenericViewSet):
|
||||||
json=vdata.get('json', {}))
|
json=vdata.get('json', {}))
|
||||||
return Response(res)
|
return Response(res)
|
||||||
|
|
||||||
@action(methods=['get'], detail=False, permission_classes=[IsAuthenticated])
|
@action(methods=['get'], detail=False,
|
||||||
|
permission_classes=[IsAuthenticated])
|
||||||
def codes(self, request, pk=None):
|
def codes(self, request, pk=None):
|
||||||
"""获取请求短标识
|
"""获取请求短标识
|
||||||
|
|
||||||
|
@ -134,7 +132,8 @@ class DhCommonViewSet(CreateModelMixin, CustomGenericViewSet):
|
||||||
"""
|
"""
|
||||||
return Response(dhapis)
|
return Response(dhapis)
|
||||||
|
|
||||||
@action(methods=['post'], detail=False, permission_classes=[IsAdminUser],
|
@action(methods=['post'], detail=False,
|
||||||
|
permission_classes=[IsAdminUser],
|
||||||
serializer_class=serializers.Serializer)
|
serializer_class=serializers.Serializer)
|
||||||
def subscribe(self, request, pk=None):
|
def subscribe(self, request, pk=None):
|
||||||
"""事件订阅
|
"""事件订阅
|
||||||
|
@ -170,14 +169,16 @@ class DhCommonViewSet(CreateModelMixin, CustomGenericViewSet):
|
||||||
dhClient.request(**dhapis['mq_subscribe'], json=json_data)
|
dhClient.request(**dhapis['mq_subscribe'], json=json_data)
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
@action(methods=['delete'], detail=False, permission_classes=[IsAdminUser],
|
@action(methods=['delete'], detail=False,
|
||||||
|
permission_classes=[IsAdminUser],
|
||||||
serializer_class=serializers.Serializer)
|
serializer_class=serializers.Serializer)
|
||||||
def unsubscribe(self, request, pk=None):
|
def unsubscribe(self, request, pk=None):
|
||||||
"""取消事件订阅
|
"""取消事件订阅
|
||||||
|
|
||||||
取消事件订阅
|
取消事件订阅
|
||||||
"""
|
"""
|
||||||
dhClient.request(**dhapis['mq_unsubscribe'], params={'name': '127.0.0.1_8000'})
|
dhClient.request(**dhapis['mq_unsubscribe'],
|
||||||
|
params={'name': '127.0.0.1_8000'})
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
@action(methods=['post'], detail=False,
|
@action(methods=['post'], detail=False,
|
||||||
|
|
|
@ -27,7 +27,7 @@ def get_request_data(request):
|
||||||
body = request.body
|
body = request.body
|
||||||
if body:
|
if body:
|
||||||
data = json.loads(body)
|
data = json.loads(body)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
if not isinstance(data, dict):
|
if not isinstance(data, dict):
|
||||||
data = {'data': data}
|
data = {'data': data}
|
||||||
|
@ -103,6 +103,6 @@ def get_verbose_name(queryset=None, view=None, model=None):
|
||||||
return getattr(model, '_meta').verbose_name
|
return getattr(model, '_meta').verbose_name
|
||||||
else:
|
else:
|
||||||
model = queryset.model._meta.verbose_name
|
model = queryset.model._meta.verbose_name
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return model if model else ""
|
return model if model else ""
|
||||||
|
|
|
@ -46,5 +46,5 @@ class SignatureViewSet(CustomCreateModelMixin, CustomGenericViewSet):
|
||||||
new_path = ext[0] + '.png'
|
new_path = ext[0] + '.png'
|
||||||
cv2.imwrite(new_path, image)
|
cv2.imwrite(new_path, image)
|
||||||
return Response({'path': new_path.replace(BASE_DIR, '')})
|
return Response({'path': new_path.replace(BASE_DIR, '')})
|
||||||
except:
|
except Exception:
|
||||||
raise ParseError(**SIGN_MAKE_FAIL)
|
raise ParseError(**SIGN_MAKE_FAIL)
|
||||||
|
|
|
@ -32,7 +32,7 @@ class WfService(object):
|
||||||
try:
|
try:
|
||||||
wf_state_obj = State.objects.get(workflow=workflow, type=State.STATE_TYPE_START, is_deleted=False)
|
wf_state_obj = State.objects.get(workflow=workflow, type=State.STATE_TYPE_START, is_deleted=False)
|
||||||
return wf_state_obj
|
return wf_state_obj
|
||||||
except:
|
except Exception:
|
||||||
raise APIException('工作流状态配置错误')
|
raise APIException('工作流状态配置错误')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -43,7 +43,7 @@ class WfService(object):
|
||||||
try:
|
try:
|
||||||
wf_state_obj = State.objects.get(workflow=workflow, type=State.STATE_TYPE_END, is_deleted=False)
|
wf_state_obj = State.objects.get(workflow=workflow, type=State.STATE_TYPE_END, is_deleted=False)
|
||||||
return wf_state_obj
|
return wf_state_obj
|
||||||
except:
|
except Exception:
|
||||||
raise APIException('工作流状态配置错误')
|
raise APIException('工作流状态配置错误')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue