from django.shortcuts import render # Create your views here. from rest_framework import status from rest_framework.authentication import SessionAuthentication from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView from rest_framework_jwt.authentication import JSONWebTokenAuthentication from utils.executeQuery import executeQuery # 查询员工信息 class Salm(APIView): # 1,设置局部认证 authentication_classes = (JSONWebTokenAuthentication, SessionAuthentication,) # authentication_classes = [SessionAuthentication, BasicAuthentication] # 2,设置局部权限 permission_classes = (IsAuthenticated,) def get(self,request): sql = """select sal_no as value,cast(sal_no as varchar(20)) + '--' + name as label from salm""" result = executeQuery(sql) # print(result) return Response(result,status=status.HTTP_200_OK) # 查询制程信息 class ZcNo(APIView): # 1,设置局部认证 authentication_classes = (JSONWebTokenAuthentication, SessionAuthentication,) # authentication_classes = [SessionAuthentication, BasicAuthentication] # 2,设置局部权限 permission_classes = (IsAuthenticated,) def get(self,request): sql = """select zc_no as value,cast(zc_no as varchar(20)) + '--' + name as label from zc_no""" result = executeQuery(sql) # print(result) return Response(result,status=status.HTTP_200_OK)