from django.shortcuts import render
from . import models
from django.db.models import Min,Avg,Max,Sum,Count
from django.core.paginator import Paginator




# Create your views here.

def index(request):
    # add = models.Qcwytable(key='00003',title='Test Company')
    # add.save();


    #[:10]表示切片，获取到10个人
    job = models.Qcwytable.objects.all()
    limit = 5
    panginator = Paginator(job, limit)
    page_number = request.GET.get('page',1)
    print(request)
    print(page_number)
    loaded = panginator.page(page_number)

    #统计职位总数/平均/最高/最低工资
    sumjob = job.aggregate(jobSum=Sum('num'))
    print(sumjob['jobSum'])
    avgsalary = job.aggregate(avgSal=Avg('salary'))
    print(avgsalary['avgSal'])
    maxsalary = job.aggregate(maxSal=Max('salary'))
    print(maxsalary['maxSal'])
    minsalary = job.aggregate(minSal=Min('salary'))
    print(minsalary['minSal'])




    context = {
        'ArtiInfo':loaded,
        'JobInfo':{
            'avgsal':avgsalary['avgSal'],
            'maxsal':maxsalary['maxSal'],
            'minsal':minsalary['minSal'],
            'sum':sumjob['jobSum']
        }
    }

    #调配index界面
    return render(request,"semanticwb.html",context)

















































































































































































































































































































































































































































''