Merge remote-tracking branch 'origin/conding' into conding
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from util.database import get_db
|
||||
from schema.cla_schema import claRequest
|
||||
from dao.cla_dao import add_class_dao,get_class_dao,update_class_dao,delete_class_dao,get_class_for_delete,hard_delete_class
|
||||
|
||||
claAPI = APIRouter(prefix="/class", tags=["班级管理"])
|
||||
|
||||
@claAPI.post("/class", summary="新增班级")
|
||||
def add_class(data: claRequest, Session = Depends(get_db)):
|
||||
return add_class_dao(data, Session)
|
||||
|
||||
@claAPI.get("/class/list", summary="查询班级")
|
||||
def list_class(Session = Depends(get_db)):
|
||||
return get_class_dao(Session)
|
||||
|
||||
@claAPI.put("/class/{class_id}", summary="更新班级信息")
|
||||
def update_class(class_id: int, data: claRequest, Session = Depends(get_db)):
|
||||
return update_class_dao(class_id, data, Session)
|
||||
|
||||
@claAPI.get("/class/{class_id}", summary="逻辑删除班级信息")
|
||||
def delete_class(class_id: int, Session = Depends(get_db)):
|
||||
return delete_class_dao(class_id, Session)
|
||||
|
||||
@claAPI.get("/class/delete/check/{class_id}", summary="硬删除前查询")
|
||||
def check_delete(class_id: int, Session = Depends(get_db)):
|
||||
return get_class_for_delete(class_id, Session)
|
||||
|
||||
@claAPI.delete("/class/delete/confirm/{class_id}", summary="删除班级信息")
|
||||
def confirm_delete(class_id: int, Session = Depends(get_db)):
|
||||
return hard_delete_class(class_id, Session)
|
||||
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
from fastapi import FastAPI,APIRouter,Depends,HTTPException
|
||||
from fastapi import APIRouter,Depends,HTTPException
|
||||
|
||||
from dao import employment_dao
|
||||
from dao.employment_dao import get_employment_dao
|
||||
from schema.employment_schema import EmlpoymentRequest,EmploymentResponse
|
||||
from schema.employment_schema import EmploymentRequest,EmploymentResponse
|
||||
from model.all_model import ClassManagement,Employment_info
|
||||
from util.database import get_db
|
||||
|
||||
app = FastAPI()
|
||||
@app.get('employment/students/{stu_id}',response_model=EmploymentResponse,summary='获取学生就业信息')
|
||||
emp_api = APIRouter()
|
||||
@emp_api.get('employment/students/{stu_id}',response_model=EmploymentResponse,summary='获取学生就业信息')
|
||||
def get_emp_info1(stu_id: int,db=Depends(get_db)):
|
||||
try:
|
||||
if stu_id:
|
||||
return employment_dao.get_employment_info()
|
||||
except:
|
||||
raise HTTPException(status_code=404, detail='就业信息不存在')
|
||||
raise HTTPException(status_code=404, detail='该学生就业信息不存在')
|
||||
|
||||
@app.get('employment/class/{class_id}',summary='获取班级学生就业信息')
|
||||
@emp_api.get('employment/class/{class_id}',summary='获取班级学生就业信息')
|
||||
def get_emp_info2(class_id: int,db=Depends(get_db)):
|
||||
try:
|
||||
if class_id:
|
||||
return employment_dao.get_employment_info()
|
||||
except:
|
||||
raise HTTPException(status_code=404, detail='就业信息不存在')
|
||||
|
||||
|
||||
|
||||
@app.post('employment/students/{stu_id}')
|
||||
def create_emp_info(stu_id: int,db=Depends(get_db)):
|
||||
raise HTTPException(status_code=404, detail='该班级就业信息不存在')
|
||||
|
||||
# @emp_api.post('employment/students/{stu_id}')
|
||||
# def create_emp_info(stu_id: int,db=Depends(get_db)):
|
||||
# try:
|
||||
# pass
|
||||
|
||||
@@ -1,21 +1,37 @@
|
||||
from fastapi import APIRouter,Depends
|
||||
from dao.statistics_dao import select_all,select_age,select_score
|
||||
from dao.statistics_dao import select_all,select_age,select_score,select_avg_score,select_salary,select_days
|
||||
from schema.student_schema import StudentResponse
|
||||
from schema.statistics_schema import AllStuResponse,AvgDayResponse,AcgScoreResponse
|
||||
from util.database import get_db
|
||||
|
||||
StatisticsAPI = APIRouter()
|
||||
|
||||
@StatisticsAPI.get("/age",response_model=list[StudentResponse],tags=['统计分析模块'],description='根据年龄查询学生信息')
|
||||
@StatisticsAPI.get("/age",response_model=list[StudentResponse],tags=['统计分析模块'],summary='根据年龄查询学生信息')
|
||||
def get_students(min_age:int|None=None,max_age:int|None=None,db=Depends(get_db)):
|
||||
l = select_age(min_age,max_age,db)
|
||||
return l
|
||||
|
||||
@StatisticsAPI.get("/all",response_model=StudentResponse,tags=['统计分析模块'],description='统计每个班级的学员总数和男女生总数')
|
||||
@StatisticsAPI.get("/all",response_model=list[AllStuResponse],tags=['统计分析模块'],summary='统计每个班级的学员总数和男女生总数')
|
||||
def get_students(db=Depends(get_db)):
|
||||
l = select_all(db)
|
||||
return [i for i in l]
|
||||
return l
|
||||
|
||||
@StatisticsAPI.get("/score",response_model=StudentResponse,tags=['统计分析模块'],description='根据成绩查询学生信息')
|
||||
@StatisticsAPI.get("/score",response_model=StudentResponse,tags=['统计分析模块'],summary='根据成绩查询学生信息')
|
||||
def get_students(min_score:int|None=None,max_score:int|None=None,db=Depends(get_db)):
|
||||
l = select_score(min_score,max_score,db)
|
||||
return [i for i in l]
|
||||
|
||||
@StatisticsAPI.get("/avg_score",response_model=list[AcgScoreResponse],tags=['统计分析模块'],summary='统计每次考试每个班级的平均分并排序')
|
||||
def get_scores(db=Depends(get_db)):
|
||||
l = select_avg_score(db)
|
||||
return l
|
||||
|
||||
@StatisticsAPI.get("/salary",response_model=list[StudentResponse],tags=['统计分析模块'],summary='统计薪资最高的前五名的学员信息')
|
||||
def get_scores(db=Depends(get_db)):
|
||||
l = select_salary(db)
|
||||
return l
|
||||
|
||||
@StatisticsAPI.get("/avg_day",response_model=list[AvgDayResponse],tags=['统计分析模块'],summary='统计每个班级的平均就业时长')
|
||||
def get_days(db=Depends(get_db)):
|
||||
l = select_days(db)
|
||||
return l
|
||||
|
||||
@@ -1,28 +1,41 @@
|
||||
from fastapi import APIRouter,Depends,HTTPException
|
||||
from dao.student_dao import delete_student_dao,add_student_dao,update_student_dao,get_student_dao
|
||||
from schema.student_schema import StudentRequest,StudentResponse,StugetResponse
|
||||
from dao.student_dao import *
|
||||
from schema.student_schema import *
|
||||
from util.database import get_db
|
||||
|
||||
|
||||
StudentAPI = APIRouter()
|
||||
|
||||
@StudentAPI.get('/',tags=['学⽣基本信息管理模块'],description='查询学生信息')
|
||||
@StudentAPI.get('/students',response_model=list[StudentPageResponse],tags=['学⽣基本信息管理模块'],description='查询学生信息')
|
||||
def get_students(stu_id:int|None=None
|
||||
,stu_name:str|None=None
|
||||
,class_id:int|None=None
|
||||
,db=Depends(get_db)
|
||||
,page:int=1
|
||||
,page_size:int=10):
|
||||
r=get_student_dao(stu_id,stu_name,class_id,db,page,page_size)
|
||||
if r:
|
||||
return r
|
||||
raise HTTPException(status_code=404,detail='学生不存在')
|
||||
r, total = get_student_dao(stu_id=stu_id
|
||||
,stu_name=stu_name
|
||||
,class_id=class_id
|
||||
,page=page
|
||||
,page_size=page_size
|
||||
,db=db)
|
||||
|
||||
if not r:
|
||||
raise HTTPException(status_code=404,detail='学生不存在')
|
||||
return {'code': 200
|
||||
, 'detail': 'ok'
|
||||
, 'page': page
|
||||
, 'page_size': page_size
|
||||
, 'total': total
|
||||
, 'data': r}
|
||||
|
||||
@StudentAPI.put('/{stu_id}',tags=['学⽣基本信息管理模块'])
|
||||
def update_students(s:StudentRequest
|
||||
,stu_id:int
|
||||
,db=Depends(get_db)):
|
||||
d = s.model_dump(exclude_unset=True)
|
||||
if not d:
|
||||
raise HTTPException(status_code=400, detail='更新内容不能为空!')
|
||||
r = update_student_dao( stu_id=stu_id,update_data=d,db=db )
|
||||
if not r:
|
||||
raise HTTPException(status_code=500, detail='没有更新!')
|
||||
@@ -36,16 +49,17 @@ def del_students(stu_id:int
|
||||
raise HTTPException(status_code=500,detail='没有删除')
|
||||
return {'code':200,'totals':rows,'detail':'删除成功'}
|
||||
|
||||
@StudentAPI.post('/',tags=['学⽣基本信息管理模块'],response_model=list[StugetResponse])
|
||||
@StudentAPI.post('/students',tags=['学⽣基本信息管理模块'],response_model=StugetResponse)
|
||||
def add_students(s:StudentRequest
|
||||
,db=Depends(get_db)):
|
||||
d=s.model_dump(exclude_unset=True)
|
||||
r=add_student_dao(o=d,db=db)
|
||||
if not r:
|
||||
d=s.model_dump(exclude_unset=False)
|
||||
stu_new=add_student_dao(o=d,db=db)
|
||||
if not stu_new:
|
||||
raise HTTPException(status_code=500,detail='添加失败')
|
||||
return stu_new
|
||||
|
||||
|
||||
@StudentAPI.put('/',tags=['学⽣基本信息管理模块'])
|
||||
@StudentAPI.put('/students',tags=['学⽣基本信息管理模块'])
|
||||
def get_students(stu_id:int|None = None
|
||||
,stu_name:str|None = None
|
||||
,class_id:int|None=None
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
from fastapi import APIRouter,HTTPException
|
||||
from fastapi import APIRouter,HTTPException,Depends
|
||||
from schema.teacher_schema import Teacher_ResponseModel, Teacher_RequestModel
|
||||
from dao.teacher_dao import *
|
||||
from dao.teacher_dao import add_teacher
|
||||
from util.database import get_db
|
||||
|
||||
teacher_api=APIRouter()
|
||||
|
||||
@teacher_api.post("/",response_model=Teacher_ResponseModel,tags=['教师基本信息管理模块'],summary='新增教师接口')
|
||||
def add_teacher(teacher:Teacher_RequestModel,session=Depends(get_db)):
|
||||
d=teacher.model_dump()
|
||||
r=add_teacher(req=d,session=session)
|
||||
if not r:
|
||||
@teacher_api.post("/teachers",response_model=Teacher_ResponseModel,tags=['教师基本信息管理模块'],summary='新增教师接口')
|
||||
def get_teacher(x1:Teacher_RequestModel,session=Depends(get_db)):
|
||||
y=add_teacher(x1.model_dump(),session)
|
||||
if not y:
|
||||
raise HTTPException(status_code=500,detail='添加异常!')
|
||||
return Teacher_ResponseModel(totals=1,data=d)
|
||||
return x1
|
||||
|
||||
@teacher_api.get("/teachers",tags=['教师基本信息管理模块'],summary='查询教师接口')
|
||||
def get_teacher(teacid:int, session=Depends(get_db)):
|
||||
# r = get_teacher(id=id,session=session)
|
||||
# if not r:
|
||||
# raise HTTPException(status_code=500, detail='查询异常!')
|
||||
try:
|
||||
l=get_teacher(teacid,session)
|
||||
return {'code': 200,'msg':'查询成功','data':l}
|
||||
except:
|
||||
raise HTTPException(status_code=500,detail='数据库查询异常!')
|
||||
|
||||
|
||||
@teacher_api.get("/",response_model=Teacher_ResponseModel,tags=['教师基本信息管理模块'],summary='查询教师接口')
|
||||
def get_teacher(id: int, session=Depends(get_db)):
|
||||
r = get_teacher(id=id, session=session)
|
||||
if not r:
|
||||
raise HTTPException(status_code=500, detail='查询异常!')
|
||||
|
||||
|
||||
@teacher_api.put("/",response_model=Teacher_ResponseModel,tags=['教师基本信息管理模块'],summary='更新教师接口')
|
||||
@teacher_api.put("/teachers",response_model=Teacher_ResponseModel,tags=['教师基本信息管理模块'],summary='更新教师接口')
|
||||
def update_teacher(id:int,teacher:Teacher_RequestModel,session=Depends(get_db)):
|
||||
d=teacher.model_dump()
|
||||
r=update_teacher(id=id,req=d,session=session)
|
||||
@@ -29,7 +33,7 @@ def update_teacher(id:int,teacher:Teacher_RequestModel,session=Depends(get_db)):
|
||||
return {'code': 200, 'totals': r, 'detail': '更新成功'}
|
||||
|
||||
|
||||
@teacher_api.delete("/",response_model=Teacher_ResponseModel,tags=['教师基本信息管理模块'],summary='删除教师接口')
|
||||
@teacher_api.delete("/teachers",response_model=Teacher_ResponseModel,tags=['教师基本信息管理模块'],summary='删除教师接口')
|
||||
def delete_teacher(id:int,session=Depends(get_db)):
|
||||
r=delete_teacher(id=id,session=session)
|
||||
if not r:
|
||||
|
||||
Reference in New Issue
Block a user