Merge remote-tracking branch 'origin/conding' into conding
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from fastapi import APIRouter,Depends
|
from fastapi import APIRouter,Depends
|
||||||
from dao.statistics_dao import select_all,select_age,select_score,select_avg_score,select_salary,select_days
|
from dao.statistics_dao import *
|
||||||
from schema.student_schema import StudentResponse
|
from schema.student_schema import StudentResponse
|
||||||
from schema.statistics_schema import AllStuResponse,AvgDayResponse,AcgScoreResponse
|
from schema.statistics_schema import *
|
||||||
from util.database import get_db
|
from util.database import get_db
|
||||||
|
|
||||||
StatisticsAPI = APIRouter()
|
StatisticsAPI = APIRouter()
|
||||||
@@ -35,3 +35,9 @@ def get_scores(db=Depends(get_db)):
|
|||||||
def get_days(db=Depends(get_db)):
|
def get_days(db=Depends(get_db)):
|
||||||
l = select_days(db)
|
l = select_days(db)
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
|
||||||
|
@StatisticsAPI.get('/emp',response_model=AllEmpResponse,tags=['统计分析模块'],summary='统计每个学生的就业时长')
|
||||||
|
def get_emp(db=Depends(get_db)):
|
||||||
|
l= select_days2(db)
|
||||||
|
return l
|
||||||
@@ -91,3 +91,21 @@ def select_days(db):
|
|||||||
except Exception:
|
except Exception:
|
||||||
raise HTTPException(status_code=500, detail="查询异常")
|
raise HTTPException(status_code=500, detail="查询异常")
|
||||||
|
|
||||||
|
#统计每个学⽣的就业时⻓
|
||||||
|
def select_days2(db):
|
||||||
|
try:
|
||||||
|
l2 =db.query(
|
||||||
|
Employment_info.stu_id
|
||||||
|
,Employment_info.employment_opening_date
|
||||||
|
,Employment_info.offer_issuance_date
|
||||||
|
,func.datediff(
|
||||||
|
Employment_info.offer_issuance_date
|
||||||
|
,Employment_info.employment_opening_date
|
||||||
|
)
|
||||||
|
.label("employment_duration_day")
|
||||||
|
).filter(
|
||||||
|
Employment_info.delete_status == 0
|
||||||
|
).all()
|
||||||
|
return l2
|
||||||
|
except Exception:
|
||||||
|
raise HTTPException(status_code=500, detail="查询异常")
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel,Field
|
||||||
|
from datetime import date
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
class AllStuResponse(BaseModel):
|
class AllStuResponse(BaseModel):
|
||||||
class_id: int
|
class_id: int
|
||||||
@@ -13,3 +15,17 @@ class AvgDayResponse(BaseModel):
|
|||||||
class_id: int
|
class_id: int
|
||||||
avg_days: str | None
|
avg_days: str | None
|
||||||
|
|
||||||
|
class EmpRequest(BaseModel):
|
||||||
|
stu_id: int
|
||||||
|
|
||||||
|
class EmpItem(BaseModel):
|
||||||
|
stu_id: int
|
||||||
|
employment_opening_date:date | None
|
||||||
|
offer_issuance_date:date | None
|
||||||
|
employment_duration_day: int | None
|
||||||
|
|
||||||
|
class AllEmpResponse(BaseModel):
|
||||||
|
code: int
|
||||||
|
msg: str
|
||||||
|
data: List[EmpItem]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user