123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- 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 .models import Bar
- from utils.executeQuery import executeQuery
- from .utils import display
- # 查询员工信息
- 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):
- # 获取用户等级
- is_superuser = request.user.is_superuser
- # 获取登录用户
- users = request.user
- print(users)
- sql = """select zc_no as value,cast(zc_no as varchar(20)) + '--' + name as label from zc_no"""
- if is_superuser==False:
- sql = """select zc_no as value,cast(zc_no as varchar(20)) + '--' + name as label from zc_no where yg_no like '%%{0}%%'""".format(users)
- result = executeQuery(sql)
- # print(result)
- return Response(result,status=status.HTTP_200_OK)
- # 查询菜单栏
- class Bars(APIView):
- # 1,设置局部认证
- authentication_classes = (JSONWebTokenAuthentication, SessionAuthentication,)
- # authentication_classes = [SessionAuthentication, BasicAuthentication]
- # 2,设置局部权限
- permission_classes = (IsAuthenticated,)
- def get(self,request):
- bar_list = Bar.objects.filter(partment_id=None)
- bar = display(bar_list)
- data = {
- 'bar':bar
- }
- return Response(data,status=status.HTTP_200_OK)
|