三方设备接口

This commit is contained in:
caoqianming 2022-05-09 15:19:58 +08:00
parent c7318fe8ee
commit f3631e70ee
2 changed files with 7 additions and 49 deletions

View File

@ -1,7 +1,7 @@
from django.urls import path, include
from rest_framework import routers
from apps.third.views import DahuaTestView, DhCommonViewSet, SpTestView, XxCommonViewSet, XxTestView
from apps.third.views_d import VChannelViewSet
from apps.third.views_d import TDeviceViewSet
API_BASE_URL = 'api/third/'
HTML_BASE_URL = 'third/'
@ -9,7 +9,7 @@ HTML_BASE_URL = 'third/'
router = routers.DefaultRouter()
router.register('xunxi', XxCommonViewSet, basename='api_xunxi')
router.register('dahua', DhCommonViewSet, basename='api_dahua')
router.register('vchannel', VChannelViewSet, basename='vchannel')
router.register('tdevice', TDeviceViewSet, basename='tdevice')
urlpatterns = [
path(API_BASE_URL, include(router.urls)),
path(API_BASE_URL + 'dahua/test/', DahuaTestView.as_view()),

View File

@ -2,68 +2,26 @@ from apps.third.models import TDevice
from apps.third.serializers import BindAreaSerializer, LabelLocationSerializer
from apps.utils.viewsets import CustomGenericViewSet
from rest_framework.mixins import ListModelMixin
from apps.third.clients import xxClient, dhClient
from apps.third.clients import xxClient, dhClient, spClient
from apps.third.tapis import xxapis, dhapis
from rest_framework.response import Response
from rest_framework.serializers import Serializer
from rest_framework.decorators import action
from apps.am.models import Area
# class BlgViewSet(ListModelMixin, CustomGenericViewSet):
# """
# 定位基站接口
# """
# perms_map = {'get': '*'} # 权限标识
# serializer_class = Serializer
# def list(self, request, *args, **kwargs):
# """
# 定位基站列表
# 定位基站列表
# """
# data = request.data
# _, res = xxClient.request(**xxapis['blg_list'], json=data)
# return Response(res)
# class IbeaconViewSet(CustomGenericViewSet):
# """
# 信标接口
# """
# perms_map = {'get': '*'} # 权限标识
# serializer_class = Serializer
# def list(self, request, *args, **kwargs):
# """
# 信标列表
# 定位基站列表
# """
# data = request.data
# _, res = xxClient.request(**xxapis['blg_list'], json=data)
# return Response(res)
class DChannelViewSet(CustomGenericViewSet):
"""
闸机接口
"""
pass
class VChannelViewSet(CustomGenericViewSet):
class TDeviceViewSet(CustomGenericViewSet):
"""
视频接口
"""
@action(methods=['post'], detail=False, perms_map={'post': '*'},
serializer_class=Serializer)
def page(self, request):
def vchannel(self, request):
request.data.update({'channelTypeList': ["1"]})
_, res = dhClient.request(**dhapis['channel_list'], json=request.data)
return Response(res)
@action(methods=['post'], detail=False, perms_map={'post': 'dchannel:label_location'},
@action(methods=['post'], detail=False, perms_map={'post': 'tdevice:label_location'},
serializer_class=LabelLocationSerializer)
def label_location(self, request):
"""
@ -88,7 +46,7 @@ class VChannelViewSet(CustomGenericViewSet):
td.save()
return Response()
@action(methods=['post'], detail=False, perms_map={'post': 'dchannel:bind_area'},
@action(methods=['post'], detail=False, perms_map={'post': 'tdevice:bind_area'},
serializer_class=BindAreaSerializer)
def bind_area(self, request):
"""