mrz
This commit is contained in:
@@ -3,7 +3,7 @@ from util.database import get_db
|
|||||||
from schema.cla_schema import claRequest
|
from schema.cla_schema import claRequest
|
||||||
from dao.cla_dao import add_class_dao,get_class_dao,update_class_dao,delete_class_dao
|
from dao.cla_dao import add_class_dao,get_class_dao,update_class_dao,delete_class_dao
|
||||||
|
|
||||||
claAPI = APIRouter(prefix="/class", tags=["班级管理"])
|
claAPI = APIRouter(prefix="/class", tags=["班级管理模块"])
|
||||||
|
|
||||||
@claAPI.post("/", summary="新增班级信息")
|
@claAPI.post("/", summary="新增班级信息")
|
||||||
def add_class(data: claRequest, Session = Depends(get_db)):
|
def add_class(data: claRequest, Session = Depends(get_db)):
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from dao.grade_dao import *
|
|||||||
from schema.grade_schema import *
|
from schema.grade_schema import *
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Body
|
from fastapi import APIRouter, Depends, HTTPException, Body
|
||||||
|
|
||||||
gradeAPI = APIRouter(tags=['学生考核成绩'])
|
gradeAPI = APIRouter(tags=['学生考核成绩管理模块'])
|
||||||
|
|
||||||
@gradeAPI.get("/grade/{stu_id}",response_model=list[GradeResponse],summary="根据学生id查询成绩")
|
@gradeAPI.get("/grade/{stu_id}",response_model=list[GradeResponse],summary="根据学生id查询成绩")
|
||||||
def get_grade(stu_id: int,db=Depends(get_db)):
|
def get_grade(stu_id: int,db=Depends(get_db)):
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ def get_days(db=Depends(get_db)):
|
|||||||
l = select_avg_days(db)
|
l = select_avg_days(db)
|
||||||
return l
|
return l
|
||||||
|
|
||||||
@StatisticsAPI.get('/emp',response_model=AllEmpResponse,summary='统计每个学生的就业时长')
|
@StatisticsAPI.get('/emp',response_model=list[AllDayResponse],summary='统计每个学生的就业时长')
|
||||||
def get_emp(db=Depends(get_db)):
|
def get_emp(db=Depends(get_db)):
|
||||||
l= select_days(db)
|
l= select_days(db)
|
||||||
return l
|
return l
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from schema.student_schema import *
|
|||||||
from util.database import get_db
|
from util.database import get_db
|
||||||
|
|
||||||
|
|
||||||
StudentAPI = APIRouter(tags=['学⽣基本信息管理模块'])
|
StudentAPI = APIRouter(tags=['学生基本信息管理模块'])
|
||||||
|
|
||||||
@StudentAPI.get('/students',response_model=StudentPageResponse,summary='学生信息查询接口',description='查询学生信息')
|
@StudentAPI.get('/students',response_model=StudentPageResponse,summary='学生信息查询接口',description='查询学生信息')
|
||||||
def get_students(stu_id:int|None=None
|
def get_students(stu_id:int|None=None
|
||||||
|
|||||||
@@ -124,18 +124,11 @@ def select_avg_days(db):
|
|||||||
#统计每个学⽣的就业时⻓
|
#统计每个学⽣的就业时⻓
|
||||||
def select_days(db):
|
def select_days(db):
|
||||||
try:
|
try:
|
||||||
l2 =db.query(
|
l2 =db.query(Employment_info.stu_id
|
||||||
Employment_info.stu_id
|
,func.coalesce(func.datediff(Employment_info.offer_issuance_date
|
||||||
,Employment_info.employment_opening_date
|
,Employment_info.employment_opening_date),0)\
|
||||||
,Employment_info.offer_issuance_date
|
.label("diff_days")
|
||||||
,func.datediff(
|
).filter(Employment_info.delete_status == 0).all()
|
||||||
Employment_info.offer_issuance_date
|
|
||||||
,Employment_info.employment_opening_date
|
|
||||||
)
|
|
||||||
.label("employment_duration_day")
|
|
||||||
).filter(
|
|
||||||
Employment_info.delete_status == 0
|
|
||||||
).all()
|
|
||||||
return l2
|
return l2
|
||||||
except Exception:
|
except Exception:
|
||||||
raise HTTPException(status_code=500, detail="查询异常")
|
raise HTTPException(status_code=500, detail="查询异常")
|
||||||
+10
-1
@@ -5,7 +5,16 @@ from api.statistics_api import StatisticsAPI
|
|||||||
from api.teacher_api import teacher_api
|
from api.teacher_api import teacher_api
|
||||||
from api.grade_api import gradeAPI
|
from api.grade_api import gradeAPI
|
||||||
from api.cla_api import claAPI
|
from api.cla_api import claAPI
|
||||||
app = FastAPI(title='沃林学⽣管理系统')
|
|
||||||
|
tags_metadata = [
|
||||||
|
{"name": "教师基本信息管理模块"},
|
||||||
|
{"name": "班级管理模块"},
|
||||||
|
{"name": "学生基本信息管理模块"},
|
||||||
|
{"name": "学生考核成绩管理模块"},
|
||||||
|
{"name": "学生就业管理模块"},
|
||||||
|
{"name": "统计分析模块"},
|
||||||
|
]
|
||||||
|
app = FastAPI(title='沃林学⽣管理系统',openapi_tags=tags_metadata)
|
||||||
|
|
||||||
app.include_router(StudentAPI)
|
app.include_router(StudentAPI)
|
||||||
|
|
||||||
|
|||||||
@@ -65,14 +65,9 @@ class AvgDayResponse(BaseModel):
|
|||||||
class_id: int
|
class_id: int
|
||||||
avg_days: float | None
|
avg_days: float | None
|
||||||
|
|
||||||
class EmpItem(BaseModel):
|
class AllDayResponse(BaseModel):
|
||||||
|
code:int = 200
|
||||||
|
detail:str = 'ok'
|
||||||
stu_id: int
|
stu_id: int
|
||||||
employment_opening_date:date | None
|
diff_days: int | 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