views.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from django.shortcuts import render
  2. # Create your views here.
  3. from rest_framework import status
  4. from rest_framework.authentication import SessionAuthentication
  5. from rest_framework.permissions import IsAuthenticated
  6. from rest_framework.response import Response
  7. from rest_framework.views import APIView
  8. from rest_framework_jwt.authentication import JSONWebTokenAuthentication
  9. from utils.executeQuery import executeQuery
  10. # 查询员工信息
  11. class Salm(APIView):
  12. # 1,设置局部认证
  13. authentication_classes = (JSONWebTokenAuthentication, SessionAuthentication,)
  14. # authentication_classes = [SessionAuthentication, BasicAuthentication]
  15. # 2,设置局部权限
  16. permission_classes = (IsAuthenticated,)
  17. def get(self,request):
  18. sql = """select sal_no as value,cast(sal_no as varchar(20)) + '--' + name as label from salm"""
  19. result = executeQuery(sql)
  20. # print(result)
  21. return Response(result,status=status.HTTP_200_OK)
  22. # 查询制程信息
  23. class ZcNo(APIView):
  24. # 1,设置局部认证
  25. authentication_classes = (JSONWebTokenAuthentication, SessionAuthentication,)
  26. # authentication_classes = [SessionAuthentication, BasicAuthentication]
  27. # 2,设置局部权限
  28. permission_classes = (IsAuthenticated,)
  29. def get(self,request):
  30. sql = """select zc_no as value,cast(zc_no as varchar(20)) + '--' + name as label from zc_no"""
  31. result = executeQuery(sql)
  32. # print(result)
  33. return Response(result,status=status.HTTP_200_OK)