Compare commits
228
Commits
ddc16dfe88
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79da6dc3a0 | ||
|
|
1af01f94ee | ||
|
|
fd1f9f71de | ||
|
|
4849e73771 | ||
|
|
4e99cfd3b1 | ||
|
|
739c8887fc | ||
|
|
30ae0af56e | ||
|
|
5b10d0e868 | ||
|
|
6ff3d5974d | ||
|
|
de67f868cb | ||
|
|
a132eb47b2 | ||
|
|
847b908c4f | ||
|
|
664741e52f | ||
|
|
7a25cf6f68 | ||
|
|
0a7fd06d83 | ||
|
|
40a6d79b37 | ||
|
|
acd04828a1 | ||
|
|
85b0d97a3d | ||
|
|
b829e4063f | ||
|
|
5a191c291e | ||
|
|
0c099b5f9c | ||
|
|
4341606d65 | ||
|
|
4f8114c9a1 | ||
|
|
13278d38c7 | ||
|
|
a67828a29f | ||
|
|
5cc1565225 | ||
|
|
55d99e17e0 | ||
|
|
3df20541be | ||
|
|
4dbb23e5c5 | ||
|
|
6c04e1b306 | ||
|
|
0813204469 | ||
|
|
ae2af187e7 | ||
|
|
957e826e0f | ||
|
|
acb4036589 | ||
|
|
2a3d1be2e3 | ||
|
|
43c558d5bc | ||
|
|
f7911c8911 | ||
|
|
d7083402aa | ||
|
|
e9086e842b | ||
|
|
7d8971fc83 | ||
|
|
bf44ac9450 | ||
|
|
14e792885a | ||
|
|
a4136ea648 | ||
|
|
fba5750c6d | ||
|
|
63da43df1e | ||
|
|
d9fc0b97a0 | ||
|
|
6cb4c4a1af | ||
|
|
476e75118a | ||
|
|
601e3b7d39 | ||
|
|
da935f93bd | ||
|
|
e57476f741 | ||
|
|
5a85014b64 | ||
|
|
7eb33e633b | ||
|
|
5a39567f47 | ||
|
|
bb32be8f99 | ||
|
|
d270bd7ad1 | ||
|
|
d650cfe928 | ||
|
|
bff10de7fa | ||
|
|
4681652172 | ||
|
|
4198e0af4e | ||
|
|
751d430e3e | ||
|
|
3223836126 | ||
|
|
3ee3c2e850 | ||
|
|
f52f598a21 | ||
|
|
9132c17fb4 | ||
|
|
7ae2f0009b | ||
|
|
abfb7bf448 | ||
|
|
5ff7e0620e | ||
|
|
2c9d9d1d1c | ||
|
|
603fee7fd4 | ||
|
|
59f81833a3 | ||
|
|
9e13a01c76 | ||
|
|
dccc0b6092 | ||
|
|
42e8130166 | ||
|
|
ffc07d3f38 | ||
|
|
abf6e3829d | ||
|
|
b31b3f055c | ||
|
|
2d9ddd051a | ||
|
|
359542b373 | ||
|
|
ed51aecf76 | ||
|
|
2b2b4b658f | ||
|
|
28e3738968 | ||
|
|
67cc0d100f | ||
|
|
1b80ef0857 | ||
|
|
a2688dd41c | ||
|
|
337bfce8b1 | ||
|
|
7216922d8d | ||
|
|
e53e0fd764 | ||
|
|
9296deb563 | ||
|
|
6c77d9646d | ||
|
|
a4ff2dcfe7 | ||
|
|
0fb561a4f4 | ||
|
|
c391bf2ebd | ||
|
|
7e1e50fb8a | ||
|
|
3733dadd8e | ||
|
|
61109cb252 | ||
|
|
e459c94917 | ||
|
|
57e2e81c94 | ||
|
|
40337d7f91 | ||
|
|
ce6034b987 | ||
|
|
ab36fa1868 | ||
|
|
6d1cfdd433 | ||
|
|
a3daccddb9 | ||
|
|
f95d627b7f | ||
|
|
4262c7f3f4 | ||
|
|
e0a5234563 | ||
|
|
231d2bfdb4 | ||
|
|
fee4a29876 | ||
|
|
1abeb3c68c | ||
|
|
90d9e067a0 | ||
|
|
85c3cc6508 | ||
|
|
3d95139558 | ||
|
|
b6f93fb804 | ||
|
|
5ea7a73295 | ||
|
|
4823c29059 | ||
|
|
8669a33916 | ||
|
|
b86616cc91 | ||
|
|
5811a68d65 | ||
|
|
6bb3a77955 | ||
|
|
60165857bf | ||
|
|
274fcd57a8 | ||
|
|
807dcba1a5 | ||
|
|
5e89b44b22 | ||
|
|
3222c831b5 | ||
|
|
3ad1720868 | ||
|
|
b23fe9eafd | ||
|
|
a47b79770b | ||
|
|
21ab22daa6 | ||
|
|
e5c2284ad1 | ||
|
|
44f2d89f62 | ||
|
|
9b2de683f7 | ||
|
|
0e0b4125ec | ||
|
|
3f75a75f76 | ||
|
|
87e6083295 | ||
|
|
f97b46961a | ||
|
|
da7fabc20e | ||
|
|
9a47e485db | ||
|
|
e146ed53d5 | ||
|
|
b8a4883321 | ||
|
|
8be7c2ab99 | ||
|
|
4cad0902d6 | ||
|
|
8143aff3ae | ||
|
|
732475b2a7 | ||
|
|
f55e9e474a | ||
|
|
abb7b97389 | ||
|
|
67a9d81071 | ||
|
|
89763566a1 | ||
|
|
3581bba893 | ||
|
|
b57f15a0e2 | ||
|
|
4bd954b0f1 | ||
|
|
8b808a3681 | ||
|
|
7fca627f15 | ||
|
|
9b4e3cfe06 | ||
|
|
0089d681e9 | ||
|
|
e2c45057c3 | ||
|
|
4425b99b87 | ||
|
|
d018843043 | ||
|
|
c386779c06 | ||
|
|
e4fb09c2e3 | ||
|
|
1f0da3748f | ||
|
|
0a92849be6 | ||
|
|
9ccf526ba5 | ||
|
|
9631c41579 | ||
|
|
4dbef61c56 | ||
|
|
08142f9619 | ||
|
|
ed0d685ab5 | ||
|
|
7e6fa8b769 | ||
|
|
290710d94c | ||
|
|
cc1309ff73 | ||
|
|
3192a8a012 | ||
|
|
86e03ea7d8 | ||
|
|
46c03a9634 | ||
|
|
7ec2e9afd8 | ||
|
|
840b195e47 | ||
|
|
501b2403ea | ||
|
|
aecd0c0011 | ||
|
|
7313415f65 | ||
|
|
f99fa66ffe | ||
|
|
275a733dd2 | ||
|
|
c756d4027f | ||
|
|
baf87e003f | ||
|
|
b7566749fb | ||
|
|
3f083bf850 | ||
|
|
f82f46ef4f | ||
|
|
9de7f64802 | ||
|
|
ff08867823 | ||
|
|
ce62e18b14 | ||
|
|
bf7073be09 | ||
|
|
a469461f88 | ||
|
|
94283cf4a8 | ||
|
|
27c4c6b240 | ||
|
|
9c26b8c0f5 | ||
|
|
1128627c00 | ||
|
|
eb56d26b36 | ||
|
|
c23d5aada7 | ||
|
|
6871434146 | ||
|
|
3f37e642d9 | ||
|
|
9a064751ea | ||
|
|
a3d8cf76a6 | ||
|
|
c32de1f5ac | ||
|
|
e8e9690faa | ||
|
|
3df28d07ff | ||
|
|
c322688260 | ||
|
|
1b5f985b7f | ||
|
|
1837764dd2 | ||
|
|
b45d16ff8e | ||
|
|
46a707c5b0 | ||
|
|
4dbe02d50c | ||
|
|
98f0d328a3 | ||
|
|
810d47a2cc | ||
|
|
a78742428b | ||
|
|
093fe608fb | ||
|
|
a775a1a334 | ||
|
|
e73e1ae1e9 | ||
|
|
959efb1e95 | ||
|
|
82aafb4340 | ||
|
|
627864b03d | ||
|
|
92b98226d8 | ||
|
|
19b1e466b7 | ||
|
|
6cc776899f | ||
|
|
a710e95b27 | ||
|
|
cc75050bb6 | ||
|
|
1a7281f0c0 | ||
|
|
e13ace8616 | ||
|
|
29fe223a74 | ||
|
|
8626f57db5 | ||
|
|
46faa300a8 | ||
|
|
26429d6b6f |
@@ -0,0 +1,25 @@
|
||||
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
|
||||
|
||||
claAPI = APIRouter(prefix="/class", tags=["班级管理模块"])
|
||||
|
||||
@claAPI.post("/", summary="新增班级信息")
|
||||
def add_class(data: claRequest, Session = Depends(get_db)):
|
||||
return add_class_dao(data, Session)
|
||||
|
||||
@claAPI.get("/list", summary="查询班级信息")
|
||||
def list_class(n:int,m:int,Session = Depends(get_db)):
|
||||
return get_class_dao(n,m,Session)
|
||||
|
||||
@claAPI.put("/{class_id}", summary="更新班级信息")
|
||||
def update_class(class_id: int, data: claRequest, Session = Depends(get_db)):
|
||||
return update_class_dao(class_id, data, Session)
|
||||
|
||||
@claAPI.delete("/{class_id}", summary="逻辑删除班级信息")
|
||||
def delete_class(class_id: int, Session = Depends(get_db)):
|
||||
return delete_class_dao(class_id, Session)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
from fastapi import APIRouter, Query, Depends, HTTPException, Path,Form
|
||||
from dao import employment_dao
|
||||
from dao.employment_dao import add_emp_dao, update_emp_dao, delete_emp_dao
|
||||
from schema.employment_schema import EmploymentRequest,UpdateEmpRequest,EmploymentResponse
|
||||
from util.database import get_db
|
||||
from typing import Optional
|
||||
emp_api = APIRouter(tags=['学生就业管理模块'])
|
||||
|
||||
@emp_api.get('/employment/class/{class_id}',response_model=list[EmploymentResponse],summary='获取班级学生就业信息')
|
||||
def get_emp_info1(class_id: Optional[int]=Path(description='班级编号')
|
||||
,db=Depends(get_db)):
|
||||
e1 = employment_dao.get_emp_dao(class_id=class_id, db=db)
|
||||
if e1:
|
||||
return e1
|
||||
raise HTTPException(status_code=404, detail='该班级就业信息不存在')
|
||||
|
||||
@emp_api.get('/employment/students/{stu_id}',response_model=list[EmploymentResponse],summary='按照学⽣编号,公司名字,⼯资范围查询学⽣就业信息')
|
||||
def get_emp_info2(stu_id:int = Path(description='学生编号')
|
||||
,company_name: str|None = Query(None,description='公司名称')
|
||||
,min_salary: float|None = Query(None,ge=0,description='最低工资')
|
||||
,max_salary: float|None = Query(None,ge=0,description='最高工资')
|
||||
,db=Depends(get_db)):
|
||||
if min_salary and max_salary:
|
||||
if min_salary > max_salary:
|
||||
raise HTTPException(status_code=404, detail='最低工资不能大于最高工资')
|
||||
l1 = employment_dao.get_emp_dao(db, stu_id=stu_id
|
||||
, company_name=company_name
|
||||
, min_salary=min_salary
|
||||
, max_salary=max_salary)
|
||||
if not l1:
|
||||
raise HTTPException(status_code=404,detail='该学生就业信息不存在!')
|
||||
return l1
|
||||
|
||||
@emp_api.post('/employment/students/{stu_id}',response_model=EmploymentResponse,summary='新增学生就业信息')
|
||||
def create_emp_info(emp:EmploymentRequest=Form(),db=Depends(get_db)):
|
||||
d=emp.model_dump(exclude_unset=False)
|
||||
r=add_emp_dao(d,db)
|
||||
if not r:
|
||||
raise HTTPException(status_code=500,detail='服务器繁忙,请稍后添加!')
|
||||
return r
|
||||
|
||||
@emp_api.put('/employment/students/{emp_id}',summary='更新学生就业信息')
|
||||
def update_emp_info(emp_id:int,emp:UpdateEmpRequest,db=Depends(get_db)):
|
||||
r = update_emp_dao(emp_id,emp.model_dump(exclude_unset=True),db)
|
||||
if not r:
|
||||
raise HTTPException(status_code=500,detail='没有更新!')
|
||||
return {'code':200,'totals':r,'detail':'更新成功!'}
|
||||
|
||||
@emp_api.delete('/employment/{emp_id}',summary='删除学生就业信息')
|
||||
def delete_emp_info(emp_id:int=Path(description='序号'),db=Depends(get_db)):
|
||||
rows = delete_emp_dao(emp_id, db)
|
||||
if not rows:
|
||||
raise HTTPException(status_code=500, detail='没有删除!')
|
||||
return {'code':200,'detail':'删除成功!'}
|
||||
@@ -0,0 +1,80 @@
|
||||
from fastapi import APIRouter,Depends,HTTPException,Path,Form
|
||||
from util.database import get_db
|
||||
from model.all_model import Student_Model
|
||||
from dao.grade_dao import *
|
||||
from schema.grade_schema import *
|
||||
from fastapi import APIRouter, Depends, HTTPException, Body
|
||||
|
||||
gradeAPI = APIRouter(tags=['学生考核成绩管理模块'])
|
||||
|
||||
@gradeAPI.get("/grade/{stu_id}",summary="根据学生id查询成绩")
|
||||
def get_grade(stu_id: int,db=Depends(get_db)):
|
||||
try:
|
||||
res=get_grade_dao(stu_id,db)
|
||||
return {
|
||||
"code": 200,
|
||||
"detail": "查询成功",
|
||||
"data": res
|
||||
}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500,detail=f'数据库查询异常:{str(e)}')
|
||||
|
||||
@gradeAPI.post('/grade',summary='添加学生成绩')
|
||||
def post_grade(o:GradeRequest,db=Depends(get_db)):
|
||||
d=o.model_dump()
|
||||
r=add_grade_dao(g=d,db=db)
|
||||
if not r:
|
||||
raise HTTPException(status_code=400, detail='学生不存在')
|
||||
return o
|
||||
|
||||
@gradeAPI.put("/grade/{score_id}", summary="成绩修改")
|
||||
def put_grade(
|
||||
score_id: int,
|
||||
exam_order: int | None = Body(default=None),
|
||||
score: float | None = Body(default=None),
|
||||
db=Depends(get_db)
|
||||
):
|
||||
# 1. 查询这条成绩记录是否存在(未删除)
|
||||
old_obj = get_score_by_id_dao(score_id=score_id, db=db)
|
||||
if not old_obj:
|
||||
raise HTTPException(status_code=404, detail="成绩记录不存在(已删除)")
|
||||
|
||||
# 2. 组装需要更新的字典,只把不为None的字段放进去
|
||||
update_data = {}
|
||||
if exam_order is not None:
|
||||
update_data["exam_order"] = exam_order
|
||||
if score is not None:
|
||||
update_data["score"] = score
|
||||
|
||||
# 没有传入任何要修改的字段
|
||||
if not update_data:
|
||||
raise HTTPException(status_code=400, detail="请传入需要修改的字段:exam_order 或 score")
|
||||
|
||||
# 3. 如果要修改考核序次,做重复校验:同一个学生不能重复的exam_order
|
||||
if "exam_order" in update_data:
|
||||
exist_obj = get_score_by_stu_exam_order_dao(
|
||||
stu_id=old_obj.stu_id,
|
||||
exam_order=update_data["exam_order"],
|
||||
db=db
|
||||
)
|
||||
# 查询到别的记录占用该学生该考核序次
|
||||
if exist_obj and exist_obj.score_id != score_id:
|
||||
raise HTTPException(status_code=409, detail="修改后的考核序次,该学生已有成绩!")
|
||||
|
||||
# 4.执行数据库更新
|
||||
try:
|
||||
rows = update_grade_dao(score_id=score_id, update_data=update_data, db=db)
|
||||
except Exception:
|
||||
raise HTTPException(status_code=409, detail="数据冲突,重复数据")
|
||||
|
||||
if rows == 0:
|
||||
return {"code": 200, "totals": rows, "detail": "数据未发生变化"}
|
||||
|
||||
return {"code": 200, "totals": rows, "detail": "更新成功"}
|
||||
|
||||
@gradeAPI.delete('/{score_id}',summary='删除成绩')
|
||||
def delete_grade(score_id:int,db=Depends(get_db)):
|
||||
r = delete_grade_dao(stu_id=score_id,db=db)
|
||||
if not r:
|
||||
raise HTTPException(status_code=404,detail='删除失败')
|
||||
return {'code':200,'totals':r,'detail':'删除成功'}
|
||||
@@ -0,0 +1,52 @@
|
||||
from fastapi import APIRouter,Depends,Query
|
||||
from dao.statistics_dao import *
|
||||
from schema.statistics_schema import *
|
||||
from schema.student_schema import *
|
||||
from util.database import get_db
|
||||
|
||||
StatisticsAPI = APIRouter(tags=['统计分析模块'])
|
||||
|
||||
@StatisticsAPI.get("/age",response_model=list[StugetResponse],summary='根据年龄查询学生信息')
|
||||
def get_students(min_age:int|None=Query(None,ge=0,le=150),max_age:int|None=Query(None,ge=0,le=150),db=Depends(get_db)):
|
||||
l = select_age(min_age,max_age,db)
|
||||
return l
|
||||
|
||||
@StatisticsAPI.get("/all",response_model=list[AllStuResponse],summary='统计每个班级的学员总数和男女生总数')
|
||||
def get_students(db=Depends(get_db)):
|
||||
l = select_all(db)
|
||||
return l
|
||||
|
||||
@StatisticsAPI.get("/score",response_model=list[GetScoreResponse],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 l
|
||||
|
||||
@StatisticsAPI.get("/avg_score",response_model=list[AcgScoreResponse],summary='统计每次考试每个班级的平均分并排序')
|
||||
def get_scores(db=Depends(get_db)):
|
||||
l = select_avg_score(db)
|
||||
return l
|
||||
|
||||
@StatisticsAPI.get("/salary",response_model=list[GetStuResponse],summary='统计薪资最高的前五名的学员信息')
|
||||
def get_scores(db=Depends(get_db)):
|
||||
l = select_salary(db)
|
||||
return l
|
||||
|
||||
@StatisticsAPI.get("/avg_day",response_model=list[AvgDayResponse],summary='统计每个班级的平均就业时长')
|
||||
def get_days(db=Depends(get_db)):
|
||||
l = select_avg_days(db)
|
||||
return l
|
||||
|
||||
@StatisticsAPI.get('/emp',response_model=list[AllDayResponse],summary='统计每个学生的就业时长')
|
||||
def get_emp(db=Depends(get_db)):
|
||||
l= select_days(db)
|
||||
return l
|
||||
|
||||
@StatisticsAPI.get('/salaries',summary='统计薪资分布')
|
||||
def get_salaries(db=Depends(get_db)):
|
||||
s=classify_salary(db)
|
||||
return s
|
||||
|
||||
@StatisticsAPI.get('/avg_salaries',summary='统计每个班级平均薪资')
|
||||
def get_avg_salaries(db=Depends(get_db)):
|
||||
s=avg_salary(db)
|
||||
return s
|
||||
@@ -1,11 +1,61 @@
|
||||
from fastapi import APIRouter
|
||||
from dao.student_dao import select_age
|
||||
from schema.student_schema import StudentResponse
|
||||
from fastapi import APIRouter,HTTPException,Depends
|
||||
from dao.student_dao import *
|
||||
from schema.student_schema import *
|
||||
from util.database import get_db
|
||||
|
||||
studentapi = APIRouter()
|
||||
|
||||
@studentapi.get("/age",response_model=StudentResponse,tags=['统计分析模块'],description='根据年龄查询学生信息')
|
||||
def get_students(min_age:int|None=None,max_age:int|None=None):
|
||||
l = select_age(min_age,max_age)
|
||||
return [i for i in l]
|
||||
StudentAPI = APIRouter(tags=['学生基本信息管理模块'])
|
||||
|
||||
@StudentAPI.get('/students',response_model=StuPageResponse,summary='学生信息查询接口',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, total = get_student_dao(stu_id=stu_id
|
||||
,stu_name=stu_name
|
||||
,class_id=class_id
|
||||
,page=page
|
||||
,page_size=page_size
|
||||
,db=db)
|
||||
return StuPageResponse(page=page,
|
||||
page_size=page_size,
|
||||
totals=total,
|
||||
data=r)
|
||||
|
||||
@StudentAPI.post('/students',response_model=StugetResponse,summary='学生信息新增接口',description='新增学生信息')
|
||||
def add_students(s:StudentRequest
|
||||
,db=Depends(get_db)):
|
||||
d = s.model_dump(exclude_unset=True)
|
||||
if not d:
|
||||
raise HTTPException(status_code=400, detail='添加内容不能为空')
|
||||
r = add_student_dao( o=d, db=db)
|
||||
if r == 'conflict':
|
||||
raise HTTPException(status_code=409, detail='身份证号已存在,请勿重复添加')
|
||||
if r == 'error':
|
||||
raise HTTPException(status_code=500, detail='添加失败,请稍后重试')
|
||||
return r
|
||||
|
||||
@StudentAPI.put('/students/{stu_id}',summary='学生信息更新接口',description='更新学生信息')
|
||||
def update_students(stu_id:int
|
||||
,s:StuUpdateRequest
|
||||
,db=Depends(get_db)):
|
||||
d = s.model_dump(exclude_unset=True)
|
||||
d.pop('stu_id', None)
|
||||
if not d:
|
||||
raise HTTPException(status_code=400, detail='更新内容不能为空')
|
||||
r = update_student_dao( stu_id=stu_id,update_data=d,db=db )
|
||||
if r == 'error':
|
||||
raise HTTPException(status_code=500, detail='更新失败,请稍后重试')
|
||||
if not r:
|
||||
raise HTTPException(status_code=404, detail='学生不存在或已被删除,更新失败')
|
||||
return {'code':200,'totals':r,'detail':'更新成功'}
|
||||
|
||||
@StudentAPI.delete('/students/{stu_id}',response_model= StudelResponse,summary='学生信息删除接口',description='删除学生信息')
|
||||
def del_students(stu_id:int
|
||||
,db=Depends(get_db)):
|
||||
rows=delete_student_dao( stu_id=stu_id,db=db )
|
||||
if not rows:
|
||||
raise HTTPException(status_code=404,detail='学生不存在或已被删除')
|
||||
return {'code':200,'totals':rows,'detail':'删除成功'}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
from fastapi import APIRouter,HTTPException,Depends
|
||||
from schema.teacher_schema import Teacher_ResponseModel, Teacher_RequestModel
|
||||
from dao.teacher_dao import add_teacher
|
||||
from util.database import get_db
|
||||
from dao.teacher_dao import update_teacher
|
||||
from dao.teacher_dao import delete_teacher
|
||||
from dao.teacher_dao import get_teacher
|
||||
|
||||
teacher_api=APIRouter(tags=['教师基本信息管理模块'])
|
||||
|
||||
@teacher_api.post("/teachers",response_model=Teacher_ResponseModel,summary='新增教师接口')
|
||||
def add_teacher1(x1:Teacher_RequestModel,session=Depends(get_db)):
|
||||
y=add_teacher(x1.model_dump(),session)
|
||||
if not y:
|
||||
raise HTTPException(status_code=500,detail='添加异常!')
|
||||
return x1
|
||||
|
||||
@teacher_api.get("/teachers",summary='查询教师接口')
|
||||
def get_teacher1(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.put("/teachers/{t_id}",summary='更新教师接口')
|
||||
def update_teacher1(t_id:int,teacher:Teacher_RequestModel,session=Depends(get_db)):
|
||||
d=teacher.model_dump(exclude_unset=True)
|
||||
r=update_teacher(id=t_id,req=d,session=session)
|
||||
if not r:
|
||||
raise HTTPException(status_code=500, detail='更新异常!')
|
||||
return {'code':200,'detail':'更新成功!','data':teacher}
|
||||
|
||||
|
||||
@teacher_api.delete("/teachers/{t_id}",summary='删除教师接口')
|
||||
def delete_teacher1(t_id:int,session=Depends(get_db)):
|
||||
r=delete_teacher(id=t_id,session=session)
|
||||
if not r:
|
||||
raise HTTPException(status_code=500,detail='删除异常!')
|
||||
return {'code': 200, 'detail':'删除成功!'}
|
||||
@@ -0,0 +1,48 @@
|
||||
from model.all_model import ClassManagement
|
||||
from fastapi import HTTPException
|
||||
from schema.cla_schema import claRequest
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def add_class_dao(c: claRequest, session):
|
||||
try:
|
||||
data = c.model_dump()
|
||||
d = ClassManagement(**data)
|
||||
session.add(d)
|
||||
session.commit()
|
||||
session.refresh(d)
|
||||
return d
|
||||
except:
|
||||
session.rollback()
|
||||
raise HTTPException(400, "输入有误,请重新添加班级!")
|
||||
|
||||
def get_class_dao(n,m,session):
|
||||
try:
|
||||
class_list=session.query(ClassManagement).filter(ClassManagement.delete_status==0).offset((n-1)*m).limit(m).all()
|
||||
return class_list
|
||||
except:
|
||||
raise HTTPException(status_code=406,detail="输入查询信息有误,请重新输入!")
|
||||
|
||||
def update_class_dao(id:int,req:claRequest,session):
|
||||
try:
|
||||
session.query(ClassManagement).filter(ClassManagement.class_id==id)\
|
||||
.filter(ClassManagement.delete_status==0).update(req.model_dump(exclude_unset=True))
|
||||
session.commit()
|
||||
except:
|
||||
raise HTTPException(status_code=400,detail="更新格式错误或参数缺失,请重新输入!")
|
||||
return '更新成功,请核对信息!'
|
||||
|
||||
def delete_class_dao(id:int,session):
|
||||
try:
|
||||
session.query(ClassManagement).filter(ClassManagement.class_id==id,ClassManagement.delete_status==0)\
|
||||
.update({'delete_status': 1,'delete_time': datetime.now()})
|
||||
session.commit()
|
||||
except:
|
||||
raise HTTPException(status_code=404, detail="删除异常,请重新核对之后删除!")
|
||||
return '删除成功,请核对信息!'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
from fastapi import HTTPException
|
||||
from model.all_model import Employment_info, ClassManagement, Student_Model
|
||||
from datetime import datetime
|
||||
|
||||
def get_emp_dao(db,stu_id=None,class_id=None,company_name=None,min_salary=None,max_salary=None):
|
||||
q = db.query(Employment_info.emp_id
|
||||
,Employment_info.stu_id
|
||||
,Student_Model.stu_name
|
||||
,Student_Model.class_id
|
||||
,Employment_info.email
|
||||
,Employment_info.employment_opening_date
|
||||
,Employment_info.offer_issuance_date
|
||||
,Employment_info.company_name
|
||||
,Employment_info.company_address
|
||||
,Employment_info.salary)\
|
||||
.join(Student_Model,Employment_info.stu_id == Student_Model.stu_id)\
|
||||
.join(ClassManagement,Student_Model.class_id == ClassManagement.class_id)\
|
||||
.filter(Employment_info.delete_status == 0)\
|
||||
.filter(Student_Model.delete_status == 0)\
|
||||
.filter(ClassManagement.delete_status == 0)
|
||||
|
||||
if stu_id:
|
||||
q = q.filter(Employment_info.stu_id == stu_id)
|
||||
if class_id:
|
||||
q = q.filter(ClassManagement.class_id == class_id)
|
||||
if company_name:
|
||||
q = q.filter(Employment_info.company_name == company_name)
|
||||
if min_salary:
|
||||
q = q.filter(Employment_info.salary >= min_salary)
|
||||
if max_salary:
|
||||
q = q.filter(Employment_info.salary <= max_salary)
|
||||
|
||||
r = q.all()
|
||||
return r
|
||||
|
||||
|
||||
def add_emp_dao(o,db):
|
||||
try:
|
||||
stu = db.query(Student_Model).filter(Student_Model.stu_id == o['stu_id']
|
||||
, Student_Model.delete_status == 0).first()
|
||||
if not stu:
|
||||
raise HTTPException(status_code=404, detail='该学生不存在,无法添加就业信息')
|
||||
|
||||
exist = (db.query(Employment_info).filter(Employment_info.stu_id == o['stu_id']
|
||||
,Employment_info.delete_status == 0).first())
|
||||
if exist:
|
||||
raise HTTPException(status_code=409, detail='该学生已有就业信息,请勿重复增加!')
|
||||
|
||||
e1 = Employment_info(**o)
|
||||
db.add(e1)
|
||||
db.commit()
|
||||
return e1
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
raise HTTPException(status_code=500, detail=f'新增就业信息失败: {e}')
|
||||
|
||||
def update_emp_dao(emp_id,emp,db):
|
||||
try:
|
||||
rows = db.query(Employment_info)\
|
||||
.filter(Employment_info.emp_id == emp_id,Employment_info.delete_status == 0)\
|
||||
.update(emp)
|
||||
db.commit()
|
||||
return rows
|
||||
except:
|
||||
db.rollback()
|
||||
raise HTTPException(status_code=404,detail='该就业记录已存在')
|
||||
|
||||
|
||||
def delete_emp_dao(emp_id:int,db):
|
||||
try:
|
||||
rows = db.query(Employment_info)\
|
||||
.filter(Employment_info.emp_id == emp_id
|
||||
,Employment_info.delete_status == 0)\
|
||||
.update({'delete_status':1,'delete_time': datetime.now()})
|
||||
db.commit()
|
||||
except:
|
||||
db.rollback()
|
||||
rows = 0
|
||||
finally:
|
||||
return rows
|
||||
@@ -0,0 +1,79 @@
|
||||
from fastapi import Depends,HTTPException
|
||||
|
||||
from util.database import get_db
|
||||
|
||||
from model.all_model import *
|
||||
|
||||
# 根据id查询单条有效成绩
|
||||
def get_score_by_id_dao(score_id:int, db):
|
||||
return db.query(WlScore).filter(
|
||||
WlScore.score_id == score_id
|
||||
,WlScore.delete_status==0
|
||||
).first()
|
||||
|
||||
# 根据stu_id+exam_order查重(新增、修改时校验重复)
|
||||
def get_score_by_stu_exam_order_dao(stu_id:str,exam_order:int,db):
|
||||
return db.query(WlScore).filter(WlScore.stu_id==stu_id
|
||||
,WlScore.exam_order==exam_order
|
||||
,WlScore.delete_status==0).first()
|
||||
|
||||
def get_grade_dao( stu_id:int , db):
|
||||
|
||||
r1 =(db.query( WlScore.score_id
|
||||
,WlScore.stu_id
|
||||
,Student_Model.stu_name
|
||||
,WlScore.exam_order
|
||||
,WlScore.score
|
||||
)
|
||||
.join(Student_Model,WlScore.stu_id == Student_Model.stu_id)
|
||||
.filter(WlScore.stu_id == stu_id,WlScore.delete_status == 0,Student_Model.delete_status == 0)
|
||||
.all())
|
||||
if r1:
|
||||
data_list = []
|
||||
for row in r1:
|
||||
data_list.append({
|
||||
"score_id": row.score_id,
|
||||
"stu_id": row.stu_id,
|
||||
"stu_name": row.stu_name,
|
||||
"exam_order": row.exam_order,
|
||||
"score": row.score
|
||||
})
|
||||
return data_list
|
||||
else:
|
||||
raise HTTPException(status_code=404,detail="学生不存在")
|
||||
|
||||
def add_grade_dao(g,db):
|
||||
try:
|
||||
o1 = WlScore(**g)
|
||||
db.add(o1)
|
||||
db.commit()
|
||||
return o1
|
||||
except Exception:
|
||||
db.rollback()
|
||||
raise HTTPException(status_code=500,detail="学生添加失败")
|
||||
|
||||
def update_grade_dao(score_id:int, update_data, db):
|
||||
try:
|
||||
rows = db.query(WlScore).filter(
|
||||
WlScore.score_id == score_id,
|
||||
WlScore.delete_status == 0
|
||||
).update(update_data)
|
||||
except Exception:
|
||||
db.rollback()
|
||||
return False
|
||||
else:
|
||||
db.commit()
|
||||
return rows
|
||||
|
||||
def delete_grade_dao(stu_id:int,db):
|
||||
try:
|
||||
rows = db.query(WlScore).filter(
|
||||
WlScore.stu_id == stu_id,
|
||||
WlScore.delete_status == 0
|
||||
).update({'delete_status':1,'delete_time':datetime.now()})
|
||||
except:
|
||||
db.rollback()
|
||||
return False
|
||||
else:
|
||||
db.commit()
|
||||
return rows
|
||||
@@ -0,0 +1,196 @@
|
||||
from fastapi import HTTPException
|
||||
from sqlalchemy import func
|
||||
from model.all_model import Student_Model,WlScore,Employment_info
|
||||
|
||||
# 实现根据年龄查询学生信息的功能
|
||||
def select_age(min_age,max_age,db):
|
||||
try:
|
||||
if min_age is None and max_age is None:
|
||||
raise HTTPException(status_code=400, detail="请至少传入一个参数")
|
||||
db = db.query(Student_Model)
|
||||
if min_age is not None:
|
||||
db = db.filter(Student_Model.age >= min_age,Student_Model.delete_status == 0)
|
||||
if max_age is not None:
|
||||
db = db.filter(Student_Model.age <= max_age,Student_Model.delete_status == 0)
|
||||
return db.all()
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception:
|
||||
raise HTTPException(status_code=500,detail="查询异常")
|
||||
|
||||
# 实现统计每个班级的学员总数以及男女生的总数的功能
|
||||
def select_all(db):
|
||||
try:
|
||||
l1 = db.query(Student_Model.class_id,Student_Model.gender,func.count(1).label('cnt'))\
|
||||
.group_by(Student_Model.class_id,Student_Model.gender).all()
|
||||
|
||||
d1 = {}
|
||||
for i in l1:
|
||||
if i.class_id not in d1:
|
||||
d1[i.class_id] = 0
|
||||
d1[i.class_id] += i.cnt
|
||||
|
||||
l2 = []
|
||||
for i in l1:
|
||||
l2.append({
|
||||
"all_cnt": d1[i.class_id],
|
||||
"class_id": i.class_id,
|
||||
"gender": i.gender,
|
||||
"cnt": i.cnt
|
||||
})
|
||||
if not l2:
|
||||
raise HTTPException(status_code=404, detail="没有数据")
|
||||
return l2
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception:
|
||||
raise HTTPException(status_code=500,detail="查询异常")
|
||||
|
||||
# 实现根据成绩查询学员信息的功能
|
||||
def select_score(min_score,max_score,db):
|
||||
try:
|
||||
if min_score is None and max_score is None:
|
||||
raise HTTPException(status_code=400, detail="请至少传入一个参数")
|
||||
db = db.query(WlScore.score
|
||||
,Student_Model.stu_name
|
||||
,Student_Model.age
|
||||
,Student_Model.gender
|
||||
,Student_Model.native_place
|
||||
,Student_Model.school
|
||||
,Student_Model.major
|
||||
,Student_Model.degree
|
||||
,Student_Model.admission_date
|
||||
,Student_Model.graduation_date
|
||||
,Student_Model.progress
|
||||
)\
|
||||
.join(WlScore,WlScore.stu_id == Student_Model.stu_id)\
|
||||
.filter(WlScore.delete_status==0,Student_Model.delete_status == 0)
|
||||
if min_score is not None:
|
||||
db = db.filter(WlScore.score >= min_score)
|
||||
if max_score is not None:
|
||||
db = db.filter(WlScore.score <= max_score)
|
||||
l1 = db.all()
|
||||
if not l1:
|
||||
raise HTTPException(status_code=404, detail="没有数据")
|
||||
return l1
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception:
|
||||
raise HTTPException(status_code=500,detail="查询异常")
|
||||
|
||||
# 实现统计每次考试每个班级的平均分并排序的功能
|
||||
def select_avg_score(db):
|
||||
try:
|
||||
l1 = db.query(Student_Model.class_id,func.round(func.avg(WlScore.score),1).label('avg_score'))\
|
||||
.join(Student_Model,WlScore.stu_id == Student_Model.stu_id)\
|
||||
.filter(WlScore.delete_status==0,Student_Model.delete_status == 0)\
|
||||
.group_by(Student_Model.class_id)\
|
||||
.order_by(func.round(func.avg(WlScore.score),1)).all()
|
||||
if not l1:
|
||||
raise HTTPException(status_code=404, detail="没有数据")
|
||||
return l1
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception:
|
||||
raise HTTPException(status_code=500,detail="查询异常")
|
||||
|
||||
# 实现统计薪资最高的前五名的学员信息
|
||||
def select_salary(db):
|
||||
try:
|
||||
l1 = db.query(Employment_info.salary
|
||||
,Student_Model.stu_name
|
||||
,Student_Model.age
|
||||
,Student_Model.gender
|
||||
,Student_Model.native_place
|
||||
,Student_Model.school
|
||||
,Student_Model.major
|
||||
,Student_Model.degree
|
||||
,Student_Model.admission_date
|
||||
,Student_Model.graduation_date
|
||||
,Student_Model.progress)\
|
||||
.join(Employment_info,Employment_info.stu_id==Student_Model.stu_id)\
|
||||
.filter(Employment_info.delete_status==0,Student_Model.delete_status == 0)\
|
||||
.order_by(Employment_info.salary.desc())\
|
||||
.limit(5).all()
|
||||
if not l1:
|
||||
raise HTTPException(status_code=404, detail="没有数据")
|
||||
return l1
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception:
|
||||
raise HTTPException(status_code=500,detail="查询异常")
|
||||
|
||||
# 实现统计每个班级的平均就业时长
|
||||
def select_avg_days(db):
|
||||
try:
|
||||
l1 = db.query(Student_Model.class_id,
|
||||
func.coalesce(
|
||||
func.avg(
|
||||
func.datediff(
|
||||
Employment_info.offer_issuance_date, Employment_info.employment_opening_date
|
||||
)
|
||||
),0).label("avg_days")
|
||||
).join(Employment_info,Employment_info.stu_id == Student_Model.stu_id)\
|
||||
.filter(Student_Model.delete_status == 0,
|
||||
Employment_info.delete_status == 0,
|
||||
Employment_info.employment_opening_date.isnot(None),
|
||||
Employment_info.offer_issuance_date.isnot(None),)\
|
||||
.group_by(Student_Model.class_id)\
|
||||
.order_by(func.avg(func.datediff(Employment_info.offer_issuance_date,Student_Model.admission_date)).desc()).all()
|
||||
if not l1:
|
||||
raise HTTPException(status_code=404, detail="没有数据")
|
||||
return l1
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception:
|
||||
raise HTTPException(status_code=500, detail="查询异常")
|
||||
|
||||
#统计每个学⽣的就业时⻓
|
||||
def select_days(db):
|
||||
try:
|
||||
l1 =db.query(Employment_info.stu_id
|
||||
,func.coalesce(func.datediff(Employment_info.offer_issuance_date
|
||||
,Employment_info.employment_opening_date),0)\
|
||||
.label("diff_days")
|
||||
).filter(Employment_info.delete_status == 0).all()
|
||||
if not l1:
|
||||
raise HTTPException(status_code=404, detail="没有数据")
|
||||
return l1
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception:
|
||||
raise HTTPException(status_code=500, detail="查询异常")
|
||||
|
||||
|
||||
# 薪资区间分布:统计薪资在5k以下、5k-10k、10k-15k、15k以上的人数分布,反映学生的整体就业质量。
|
||||
def classify_salary(db):
|
||||
try:
|
||||
a=b=c=d=0
|
||||
l=db.query(Employment_info).filter(Employment_info.delete_status==0).all()
|
||||
for i in l:
|
||||
if i.salary is None:
|
||||
continue
|
||||
elif i.salary<5000:
|
||||
a+=1
|
||||
elif 5000<=i.salary<10000:
|
||||
b+=1
|
||||
elif 10000<=i.salary<15000:
|
||||
c+=1
|
||||
else:
|
||||
d+=1
|
||||
return {'5k以下': a, '5k-10k': b, '10k-15k': c, '15k以上': d}
|
||||
except:
|
||||
raise HTTPException(status_code=500,detail='查询异常!')
|
||||
|
||||
#统计每个班的平均就业薪资
|
||||
def avg_salary(db):
|
||||
try:
|
||||
l=db.query(Student_Model.class_id,func.avg(Employment_info.salary).label('avg_salaries'))\
|
||||
.join(Employment_info,Employment_info.stu_id == Student_Model.stu_id)\
|
||||
.filter(Employment_info.salary>0,Employment_info.delete_status==0,Student_Model.delete_status==0)\
|
||||
.group_by(Student_Model.class_id)\
|
||||
.order_by(func.avg(Employment_info.salary).desc()).all()
|
||||
return [{'class_id':i[0],'avg_salaries':i[1]} for i in l]
|
||||
except:
|
||||
raise HTTPException(status_code=500,detail='统计异常!')
|
||||
|
||||
@@ -1,65 +1,71 @@
|
||||
from fastapi import HTTPException,Depends
|
||||
from util.database import get_db
|
||||
from model.student_model import Student_Model
|
||||
from model.all_model import Student_Model
|
||||
from typing import List, Optional, Dict, Any
|
||||
from datetime import datetime
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
def select_age(min_age,max_age,session=Depends(get_db)):
|
||||
def add_student_dao(o,db):
|
||||
if o.get('id_card'):
|
||||
conflict = (db.query(Student_Model)
|
||||
.filter(Student_Model.id_card == o['id_card'],
|
||||
Student_Model.delete_status == 0)
|
||||
.first())
|
||||
if conflict:
|
||||
return 'conflict'
|
||||
try:
|
||||
if min_age is None and max_age is None:
|
||||
raise HTTPException(status_code=400, detail="请至少传入一个参数")
|
||||
session = session.query(Student_Model)
|
||||
if min_age is not None:
|
||||
session = session.filter(Student_Model.age >= min_age)
|
||||
if max_age is not None:
|
||||
session = session.filter(Student_Model.age <= max_age)
|
||||
return session.all()
|
||||
except HTTPException:
|
||||
raise
|
||||
o2 = Student_Model(**o)
|
||||
db.add(o2)
|
||||
db.commit()
|
||||
return o2
|
||||
except IntegrityError:
|
||||
db.rollback()
|
||||
return 'conflict'
|
||||
except Exception:
|
||||
raise HTTPException(status_code=500,detail="查询异常")
|
||||
|
||||
def delete_student_dao(stu_id,db):
|
||||
try:
|
||||
rows = db.query(Student_Model).filter(Student_Model.stu_id == stu_id).delete()
|
||||
except:
|
||||
db.rollback()
|
||||
rows = 0
|
||||
else:
|
||||
db.commit()
|
||||
finally:
|
||||
return rows
|
||||
return 'error'
|
||||
|
||||
def update_student_dao(stu_id,update_data,db):
|
||||
def delete_student_dao(stu_id, db):
|
||||
try:
|
||||
rows = db.query( Student_Model ).filter( Student_Model.stu_id == stu_id ).update( update_data )
|
||||
except:
|
||||
db.rollback()
|
||||
return False
|
||||
else:
|
||||
rows = (db.query(Student_Model)
|
||||
.filter(Student_Model.stu_id == stu_id,
|
||||
Student_Model.delete_status == 0)
|
||||
.update({'delete_status': 1, 'delete_time': datetime.now()}))
|
||||
db.commit()
|
||||
return rows
|
||||
except Exception:
|
||||
db.rollback()
|
||||
raise
|
||||
|
||||
def update_student_dao(stu_id, update_data, db):
|
||||
if not update_data:
|
||||
return 0
|
||||
try:
|
||||
rows = (db.query(Student_Model)
|
||||
.filter(Student_Model.stu_id == stu_id,
|
||||
Student_Model.delete_status == 0)
|
||||
.update(update_data))
|
||||
db.commit()
|
||||
except IntegrityError:
|
||||
db.rollback()
|
||||
return 'conflict'
|
||||
except Exception:
|
||||
db.rollback()
|
||||
return 'error'
|
||||
return rows
|
||||
|
||||
def get_student_dao(stu_id:Optional[int]
|
||||
,stu_name:Optional[str]
|
||||
,class_id:Optional[int]
|
||||
,db: Session
|
||||
,page: int
|
||||
,page_size: int
|
||||
,db
|
||||
) -> tuple[List[Dict[str, Any]], int]:
|
||||
q = db.query(Student_Model)
|
||||
q = db.query(Student_Model).filter(Student_Model.delete_status == 0)
|
||||
if stu_id:
|
||||
q = q.filter(Student_Model.stu_id == stu_id)
|
||||
if stu_name:
|
||||
if stu_name and stu_name.strip() != "":
|
||||
q = q.filter(Student_Model.stu_name.like(f"%{stu_name}%"))
|
||||
if class_id:
|
||||
q= q.filter(Student_Model.class_id == class_id)
|
||||
q = q.filter(Student_Model.class_id == class_id)
|
||||
total = q.count()
|
||||
r = q.offset((page - 1) * page_size).limit(page_size).all()
|
||||
data = []
|
||||
for i in r:
|
||||
data.append({'stu_id': i.stu_id
|
||||
,'stu_name': i.stu_name
|
||||
,'class_id': i.class_id
|
||||
,'create_date': i.create_date
|
||||
,'update_date': i.update_date
|
||||
})
|
||||
return data, total
|
||||
return r, total
|
||||
|
||||
@@ -1,38 +1,43 @@
|
||||
from fastapi import HTTPException,Depends
|
||||
from fastapi import HTTPException
|
||||
from model.all_model import Teacher_Model
|
||||
from datetime import datetime
|
||||
|
||||
from PythonProject.model.teacher_model import Teacher_Model
|
||||
from util.database import *
|
||||
from schema.teacher_schema import Teacher_RequestModel
|
||||
|
||||
|
||||
def add_teacher(req:Teacher_RequestModel,session=Depends(get_db)):
|
||||
def add_teacher(teacher,session):
|
||||
try:
|
||||
data=req.model_dump()
|
||||
session.add(Teacher_Model(**data))
|
||||
x=Teacher_Model(**teacher)
|
||||
session.add(x)
|
||||
session.commit()
|
||||
return teacher
|
||||
except:
|
||||
raise HTTPException(status_code=500,detail="添加异常!")
|
||||
return req.model_dump()
|
||||
session.rollback()
|
||||
return None
|
||||
|
||||
def select_teacher(session=Depends(get_db)):
|
||||
def get_teacher(id,session):
|
||||
l=session.query(Teacher_Model).filter(Teacher_Model.teac_id==id)\
|
||||
.filter(Teacher_Model.delete_status==0).all()
|
||||
if l:
|
||||
return l
|
||||
else:
|
||||
raise HTTPException(status_code=404,detail='该老师不存在!')
|
||||
|
||||
def update_teacher(id:int,req,session):
|
||||
try:
|
||||
teacher_list=session.query(Teacher_Model).all()
|
||||
return teacher_list
|
||||
r=session.query(Teacher_Model).filter(Teacher_Model.teac_id==id) \
|
||||
.filter(Teacher_Model.delete_status==0).update(req)
|
||||
except:
|
||||
raise HTTPException(status_code=500,detail="查询异常!")
|
||||
|
||||
def update_teacher(id:int,req:Teacher_RequestModel,session=Depends(get_db)):
|
||||
try:
|
||||
session.query(Teacher_Model).filter(Teacher_Model.teac_id==id)\
|
||||
.update(req.model_dump(exclude_unset=True))
|
||||
session.rollback()
|
||||
return False
|
||||
else:
|
||||
session.commit()
|
||||
except:
|
||||
raise HTTPException(status_code=500,detail="更新异常!")
|
||||
return r
|
||||
|
||||
def delete_teacher(id:int,session=Depends(get_db)):
|
||||
def delete_teacher(id:int,session):
|
||||
try:
|
||||
session.query(Teacher_Model).filter(Teacher_Model.teac_id==id).delete()
|
||||
session.commit()
|
||||
r=session.query(Teacher_Model).filter(Teacher_Model.teac_id==id,Teacher_Model.delete_status==0)\
|
||||
.update({'delete_status':1,'delete_time':datetime.now()})
|
||||
except:
|
||||
raise HTTPException(status_code=500,detail="删除异常")
|
||||
return {'code':200,'details':'删除成功'}
|
||||
session.rollback()
|
||||
return False
|
||||
else:
|
||||
session.commit()
|
||||
return r
|
||||
|
||||
+23
-3
@@ -1,5 +1,25 @@
|
||||
from fastapi import FastAPI
|
||||
from api.student_api import *
|
||||
app = FastAPI()
|
||||
from api.employment_api import emp_api
|
||||
from api.student_api import StudentAPI
|
||||
from api.statistics_api import StatisticsAPI
|
||||
from api.teacher_api import teacher_api
|
||||
from api.grade_api import gradeAPI
|
||||
from api.cla_api import claAPI
|
||||
|
||||
app.include_router(studentapi)
|
||||
tags_metadata = [
|
||||
{"name": "教师基本信息管理模块"},
|
||||
{"name": "班级管理模块"},
|
||||
{"name": "学生基本信息管理模块"},
|
||||
{"name": "学生考核成绩管理模块"},
|
||||
{"name": "学生就业管理模块"},
|
||||
{"name": "统计分析模块"},
|
||||
]
|
||||
app = FastAPI(title='沃林学生管理系统',openapi_tags=tags_metadata)
|
||||
|
||||
app.include_router(StudentAPI)
|
||||
|
||||
app.include_router(StatisticsAPI)
|
||||
app.include_router(teacher_api)
|
||||
app.include_router(emp_api)
|
||||
app.include_router(gradeAPI)
|
||||
app.include_router(claAPI)
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
|
||||
|
||||
from sqlalchemy import DATETIME,Column,Integer,String,DATE,ForeignKey,Numeric,Date
|
||||
from datetime import datetime,date
|
||||
from util.database import Base,engine
|
||||
|
||||
class Student_Model(Base):
|
||||
__tablename__ = 'wl_student'
|
||||
|
||||
stu_id = Column(Integer
|
||||
, primary_key=True
|
||||
, autoincrement=True
|
||||
,comment='学生编号')
|
||||
|
||||
class_id = Column(Integer
|
||||
,ForeignKey('wl_class.class_id')
|
||||
,comment='班级编号'
|
||||
)
|
||||
|
||||
stu_name=Column(String(100),comment='学生姓名')
|
||||
|
||||
age=Column(Integer,comment='年龄')
|
||||
|
||||
gender=Column(String(50),comment='性别')
|
||||
|
||||
native_place=Column(String(200),comment='籍贯')
|
||||
|
||||
id_card=Column(String(18),unique=True,comment='身份证号')
|
||||
|
||||
birthday=Column(DATE,comment='生日')
|
||||
|
||||
school=Column(String(100),comment='毕业学校')
|
||||
|
||||
major=Column(String(50),comment='专业')
|
||||
|
||||
degree=Column(String(50),comment='学历')
|
||||
|
||||
admission_date=Column(DATE,comment='入学日期')
|
||||
|
||||
graduation_date=Column(DATE,comment='毕业日期')
|
||||
|
||||
progress=Column(Integer,default=0,comment='课程进度:学习中=0,求职中=1,已就业=2')
|
||||
|
||||
create_date=Column(DATETIME
|
||||
,default=datetime.now)
|
||||
|
||||
update_date=Column(DATETIME
|
||||
,default=datetime.now
|
||||
,onupdate=datetime.now)
|
||||
|
||||
delete_status = Column(
|
||||
Integer,default=0,comment='删除状态:0未删除,1已删除')
|
||||
|
||||
delete_time = Column(DATETIME,comment='删除时间')
|
||||
|
||||
class ClassManagement(Base):
|
||||
__tablename__ = "wl_class"
|
||||
|
||||
class_id= Column(Integer, primary_key=True, autoincrement=True,comment='班级编号')
|
||||
|
||||
class_name = Column(String(100), comment='班级名字')
|
||||
|
||||
start_class_date = Column(Date,default=date.today,comment='开课时间')
|
||||
|
||||
head_teacher_id= Column(Integer,ForeignKey('wl_teacher.teac_id'),comment='班主任')
|
||||
|
||||
class_teacher_id = Column(Integer,ForeignKey('wl_teacher.teac_id'),comment='授课教师')
|
||||
|
||||
Entry_date= Column(DATETIME,default=datetime.now,comment='录入时间')
|
||||
|
||||
update_date = Column(DATETIME,default=datetime.now,onupdate=datetime.now,comment='更新时间')
|
||||
|
||||
delete_status = Column(Integer,default=0,comment='删除状态:0未删除,1已删除')
|
||||
|
||||
delete_time = Column(DATETIME,comment='删除时间')
|
||||
|
||||
class Teacher_Model(Base):
|
||||
__tablename__ = 'wl_teacher'
|
||||
|
||||
teac_id=Column(Integer,primary_key=True,autoincrement=True,comment='老师编号')
|
||||
|
||||
teac_name=Column(String(100),comment='老师姓名')
|
||||
|
||||
teac_gender=Column(String(100),comment='老师性别')
|
||||
|
||||
teac_age=Column(Integer,comment='老师年龄')
|
||||
|
||||
teac_position =Column(String(100),comment='老师职位')
|
||||
|
||||
create_date=Column(DATETIME,default=datetime.now)
|
||||
|
||||
update_date=Column(DATETIME,default=datetime.now,onupdate=datetime.now)
|
||||
|
||||
delete_status = Column(Integer,default=0,comment='删除状态:0未删除,1已删除')
|
||||
|
||||
delete_time = Column(DATETIME,comment='删除时间')
|
||||
|
||||
class Employment_info(Base):
|
||||
__tablename__ = 'wl_employment'
|
||||
|
||||
emp_id = Column(Integer
|
||||
,primary_key=True
|
||||
,autoincrement=True
|
||||
,comment='序号'
|
||||
)
|
||||
|
||||
stu_id = Column(Integer
|
||||
,ForeignKey('wl_student.stu_id')
|
||||
,nullable=False
|
||||
,comment='学生编号'
|
||||
)
|
||||
|
||||
email = Column(String(50)
|
||||
,unique=True
|
||||
,comment='邮箱'
|
||||
)
|
||||
|
||||
employment_opening_date = Column(DATE
|
||||
,comment='就业开放日期'
|
||||
)
|
||||
|
||||
offer_issuance_date = Column(DATE
|
||||
,comment='offer下发日期'
|
||||
)
|
||||
|
||||
company_name = Column(String(50)
|
||||
,comment='就业公司名称'
|
||||
)
|
||||
|
||||
company_address = Column(String(100)
|
||||
,comment='就业公司地址'
|
||||
)
|
||||
|
||||
salary = Column(Integer
|
||||
,comment='薪资'
|
||||
)
|
||||
|
||||
create_time = Column(DATETIME
|
||||
,default=datetime.now
|
||||
,comment='创建时间'
|
||||
)
|
||||
|
||||
update_time = Column(DATETIME
|
||||
,default=datetime.now
|
||||
,onupdate=datetime.now
|
||||
,comment='更新时间'
|
||||
)
|
||||
|
||||
delete_status = Column(
|
||||
Integer,default=0,comment='删除状态:0未删除,1已删除')
|
||||
|
||||
delete_time = Column(DATETIME,comment='删除时间')
|
||||
|
||||
class WlScore(Base):
|
||||
__tablename__ = 'wl_score'
|
||||
|
||||
score_id = Column(Integer
|
||||
,primary_key=True
|
||||
,autoincrement=True
|
||||
,comment='序号'
|
||||
)
|
||||
|
||||
stu_id = Column( Integer
|
||||
,ForeignKey('wl_student.stu_id')
|
||||
,comment='学生编号')
|
||||
|
||||
exam_order = Column(Integer
|
||||
, nullable=False
|
||||
, comment="考核序次")
|
||||
|
||||
score=Column(Numeric(5, 2)
|
||||
, comment="成绩")
|
||||
|
||||
create_time = Column(DATETIME
|
||||
, nullable=False
|
||||
, default=datetime.now
|
||||
, comment="作成时间")
|
||||
|
||||
update_time = Column(DATETIME
|
||||
, nullable=False
|
||||
, default=datetime.now
|
||||
, onupdate=datetime.now
|
||||
, comment="更新时间")
|
||||
|
||||
delete_status = Column(
|
||||
Integer,default=0,comment='删除状态:0未删除,1已删除')
|
||||
|
||||
delete_time = Column(DATETIME,comment='删除时间')
|
||||
|
||||
Base.metadata.create_all(engine)
|
||||
@@ -1,36 +0,0 @@
|
||||
|
||||
from sqlalchemy import DateTime,Date,Column,Integer,ForeignKey,Boolean
|
||||
from util.database import Base,engine
|
||||
|
||||
class ClassManagement(Base):
|
||||
__tablename__ = "wl_class"
|
||||
|
||||
class_id= Column(Integer, primary_key=True, autoincrement=True,comment='班级编号')
|
||||
|
||||
start_class_date = Column(Date,comment='开课时间')
|
||||
|
||||
head_teacher_id= Column(Integer,ForeignKey('wl_teacher.id'),comment='班主任')
|
||||
|
||||
class_teacher_id = Column(Integer,ForeignKey('wl_teacher.id'),comment='授课教师')
|
||||
|
||||
Entry_date= Column(DateTime,comment='录入时间')
|
||||
|
||||
update_date = Column(DateTime,comment='更新时间')
|
||||
|
||||
delete_status = Column(
|
||||
Boolean,
|
||||
nullable=False,
|
||||
default=False,
|
||||
server_default='0',
|
||||
comment='删除状态:0未删除,1已删除'
|
||||
)
|
||||
delete_time = Column(DateTime, nullable=True, comment='删除时间')
|
||||
|
||||
Base.metadata.create_all(engine)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
from util.database import Base,engine
|
||||
from sqlalchemy import Column,Integer,String,DATE,DATETIME,ForeignKey
|
||||
from datetime import datetime
|
||||
|
||||
class Employment_info(Base):
|
||||
__tablename__ = 'wl_employment'
|
||||
emp_id = Column(Integer
|
||||
,primary_key=True
|
||||
,autoincrement=True
|
||||
,comment='序号'
|
||||
)
|
||||
stu_id = Column(Integer
|
||||
,ForeignKey('wl_student.stu_id')
|
||||
,nullable=False
|
||||
,comment='学生编号'
|
||||
)
|
||||
email = Column(String(50)
|
||||
,unique=True
|
||||
,comment='邮箱'
|
||||
)
|
||||
employment_opening_date = Column(DATE
|
||||
,comment='就业开放日期'
|
||||
)
|
||||
offer_issuance_date = Column(DATE
|
||||
,comment='offer下发日期'
|
||||
)
|
||||
company_name = Column(String(50)
|
||||
,comment='就业公司名称'
|
||||
)
|
||||
company_address = Column(String(100)
|
||||
,comment='就业公司地址')
|
||||
salary = Column(Integer
|
||||
,comment='薪资')
|
||||
deletion_status = Column(Integer
|
||||
,default=0
|
||||
,comment='信息留存状态【0:初始值;1:已删除】'
|
||||
)
|
||||
create_time = Column(DATETIME
|
||||
,default=datetime.now
|
||||
,comment='创建时间'
|
||||
)
|
||||
update_time = Column(DATETIME
|
||||
,default=datetime.now
|
||||
,onupdate=datetime.now
|
||||
,comment='更新时间'
|
||||
)
|
||||
|
||||
Base.metadata.create_all(engine)
|
||||
@@ -1,35 +0,0 @@
|
||||
from sqlalchemy import Column, BigInteger, Integer, String, Numeric, TinyInteger, DateTime
|
||||
from sqlalchemy.orm import declarative_base
|
||||
from datetime import datetime
|
||||
from util.database import Base,engine
|
||||
# 成绩、删除状态(0:已删除,1:初始值)、作成时间、更新时间
|
||||
class WlScore(Base):
|
||||
__tablename__ = 'Assessment grade'
|
||||
stu_id = Column( Integer
|
||||
,primary_key=True
|
||||
,autoincrement=True
|
||||
,comment='学生编号,自增主键')
|
||||
exam_order = Column(Integer
|
||||
, nullable=False
|
||||
, comment="考核序次")
|
||||
|
||||
score=Column(Numeric(5, 2)
|
||||
, comment="成绩")
|
||||
|
||||
del_flag = Column(Integer
|
||||
, nullable=False
|
||||
, default=1
|
||||
, comment="删除状态(0:已删除,1:初始值)")
|
||||
|
||||
create_time = Column(DateTime
|
||||
, nullable=False
|
||||
, default=datetime.now
|
||||
, comment="作成时间")
|
||||
|
||||
update_time = Column(DateTime
|
||||
, nullable=False
|
||||
, default=datetime.now
|
||||
, onupdate=datetime.now
|
||||
, comment="更新时间")
|
||||
Base.metadata.create_all(engine)
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
from sqlalchemy import DATETIME,Column, Integer, String, Date,ForeignKey
|
||||
from datetime import datetime
|
||||
from util.database import Base,engine
|
||||
|
||||
class Student_Model(Base):
|
||||
__tablename__ = 'wl_student'
|
||||
stu_id = Column(Integer
|
||||
, primary_key=True
|
||||
, autoincrement=True
|
||||
,comment='学生编号')
|
||||
class_id=Column(Integer
|
||||
,ForeignKey('wl_class.class_id')
|
||||
,nullable=False
|
||||
,comment='班级编号')
|
||||
stu_name=Column(String(100),comment='学生姓名')
|
||||
age=Column(Integer,comment='年龄')
|
||||
gender=Column(String(50),comment='性别')
|
||||
native_place=Column(String(200),comment='籍贯')
|
||||
birthday=Column(Date,comment='生日')
|
||||
school=Column(String(100),comment='毕业学校')
|
||||
major=Column(String(50),comment='专业')
|
||||
degree=Column(String(50),comment='学历')
|
||||
admission_date=Column(Date,comment='入学日期')
|
||||
graduation_date=Column(Date,comment='毕业日期')
|
||||
progress=Column(Integer,default=0,comment='课程进度:学习中=0,求职中=1,已就业=2')
|
||||
create_date=Column(DATETIME
|
||||
,default=datetime.now)
|
||||
update_date=Column(DATETIME
|
||||
,default=datetime.now
|
||||
,onupdate=datetime.now)
|
||||
|
||||
Base.metadata.create_all(engine)
|
||||
@@ -1,17 +0,0 @@
|
||||
from sqlalchemy import DATETIME,Column, Integer, String, Date,ForeignKey
|
||||
from datetime import datetime
|
||||
from util.database import Base,engine
|
||||
|
||||
class Teacher_Model(Base):
|
||||
__tablename__ = 'wl_teacher'
|
||||
teac_id=Column(Integer,primary_key=True,autoincrement=True,comment='老师编号')
|
||||
teac_name=Column(String(20),comment='老师姓名')
|
||||
teac_gender=Column(String(5),comment='老师性别')
|
||||
teac_age=Column(Integer,comment='老师年龄')
|
||||
teac_position =Column(String(20),comment='老师职位')
|
||||
status=Column(Integer,default=0,comment='课程进度:学习中=0,求职中=1,已就业=2')
|
||||
create_date=Column(DATETIME,default=datetime.now)
|
||||
update_date=Column(DATETIME,default=datetime.now,onupdate=datetime.now)
|
||||
|
||||
Base.metadata.create_all(engine)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
from datetime import date
|
||||
from pydantic import BaseModel
|
||||
|
||||
class claRequest(BaseModel):
|
||||
|
||||
class_name : str|None = None
|
||||
|
||||
start_class_date :date
|
||||
|
||||
head_teacher_id : int|None = None
|
||||
|
||||
class_teacher_id : int|None = None
|
||||
|
||||
class claResponse(BaseModel):
|
||||
|
||||
code: int = 200
|
||||
|
||||
detail: str = 'ok'
|
||||
|
||||
class_name: str | None = None
|
||||
|
||||
head_teacher_id: int | None = None
|
||||
|
||||
class_teacher_id: int | None = None
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
from pydantic import BaseModel, Field,field_validator, model_validator
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
class EmploymentRequest(BaseModel):
|
||||
stu_id: int=Field(ge=1,description='学生编号')
|
||||
email: Optional[str] = Field(None, description='邮箱')
|
||||
employment_opening_date:Optional[date] = Field(None, description='就业开放日期')
|
||||
offer_issuance_date:Optional[date] = Field(None, description='offer下发日期')
|
||||
company_name:Optional[str] = Field(None, description='公司名称')
|
||||
company_address:Optional[str] = Field(None, description='公司地址')
|
||||
salary:Optional[float] = Field(None, description='薪资')
|
||||
|
||||
@model_validator(mode='after')
|
||||
def check_date(self):
|
||||
if self.employment_opening_date and self.offer_issuance_date:
|
||||
if self.employment_opening_date > self.offer_issuance_date:
|
||||
raise ValueError('offer下发日期不能早于就业开放日期')
|
||||
return self
|
||||
|
||||
class UpdateEmpRequest(BaseModel):
|
||||
email: Optional[str] = Field(None, description='邮箱')
|
||||
employment_opening_date:Optional[date] = Field(None, description='就业开放日期')
|
||||
offer_issuance_date:Optional[date] = Field(None, description='offer下发日期')
|
||||
company_name:Optional[str] = Field(None, description='公司名称')
|
||||
company_address:Optional[str] = Field(None, description='公司地址')
|
||||
salary:Optional[float] = Field(None, description='薪资')
|
||||
|
||||
@model_validator(mode='after')
|
||||
def check_date(self):
|
||||
if self.employment_opening_date and self.offer_issuance_date:
|
||||
if self.employment_opening_date > self.offer_issuance_date:
|
||||
raise ValueError('offer下发日期不能早于就业开放日期')
|
||||
return self
|
||||
|
||||
class EmploymentResponse(BaseModel):
|
||||
code:int = 200
|
||||
detail:str = 'OK'
|
||||
emp_id: int
|
||||
stu_id:int
|
||||
stu_name: Optional[str] = None
|
||||
class_id: Optional[int] = None
|
||||
email: str|None = None
|
||||
employment_opening_date:date|None = None
|
||||
offer_issuance_date:date|None = None
|
||||
company_name:str|None = None
|
||||
company_address:str|None = None
|
||||
salary:float|None = None
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
|
||||
|
||||
class GradeRequest(BaseModel):
|
||||
stu_id:int = Field(description="学生编号")
|
||||
exam_order:int = Field(description='考核序次')
|
||||
score:float = Field(description='成绩')
|
||||
|
||||
@field_validator("score")
|
||||
def check_score(cls, v):
|
||||
if not (0 <= v <= 100):
|
||||
raise ValueError("成绩必须在0~100之间")
|
||||
return v
|
||||
|
||||
@field_validator("exam_order")
|
||||
def check_exam_order(cls, v):
|
||||
if v <= 0:
|
||||
raise ValueError("考核序次必须大于0")
|
||||
return v
|
||||
|
||||
class GradeResponse(BaseModel):
|
||||
code: int = 200
|
||||
detail: str = 'OK'
|
||||
score_id: float
|
||||
stu_id:int
|
||||
exam_order:int
|
||||
score:float
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
from pydantic import BaseModel,field_serializer
|
||||
from datetime import date
|
||||
|
||||
class AllStuResponse(BaseModel):
|
||||
all_cnt: int
|
||||
class_id: int
|
||||
gender: str | None
|
||||
cnt: int
|
||||
|
||||
class AcgScoreResponse(BaseModel):
|
||||
class_id: int
|
||||
avg_score: float
|
||||
|
||||
class GetScoreResponse(BaseModel):
|
||||
code:int = 200
|
||||
detail:str = 'ok'
|
||||
score:float
|
||||
stu_name: str | None = None
|
||||
age: int | None = None
|
||||
gender: str | None = None
|
||||
native_place: str | None = None
|
||||
school: str | None = None
|
||||
major: str | None = None
|
||||
degree: str | None = None
|
||||
admission_date: date | None = None
|
||||
graduation_date: date | None = None
|
||||
progress: int = 0
|
||||
|
||||
@field_serializer('progress')
|
||||
def int_to_string(self, progress: int):
|
||||
d1 = {
|
||||
0: '学习中',
|
||||
1: '求职中',
|
||||
2: '已就业'
|
||||
}
|
||||
return d1.get(progress, '暂不明确')
|
||||
|
||||
class GetStuResponse(BaseModel):
|
||||
code:int = 200
|
||||
detail:str = 'ok'
|
||||
salary:float
|
||||
stu_name: str | None = None
|
||||
age: int | None = None
|
||||
gender: str | None = None
|
||||
native_place: str | None = None
|
||||
school: str | None = None
|
||||
major: str | None = None
|
||||
degree: str | None = None
|
||||
admission_date: date | None = None
|
||||
graduation_date: date | None = None
|
||||
progress: int = 0
|
||||
|
||||
@field_serializer('progress')
|
||||
def int_to_string(self, progress: int):
|
||||
d1 = {
|
||||
0: '学习中',
|
||||
1: '求职中',
|
||||
2: '已就业'
|
||||
}
|
||||
return d1.get(progress, '暂不明确')
|
||||
|
||||
class AvgDayResponse(BaseModel):
|
||||
class_id: int
|
||||
avg_days: float | None
|
||||
|
||||
class AllDayResponse(BaseModel):
|
||||
code:int = 200
|
||||
detail:str = 'ok'
|
||||
stu_id: int
|
||||
diff_days: int | None
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
from datetime import date
|
||||
from typing import Self
|
||||
from pydantic import BaseModel, field_serializer, field_validator,model_validator
|
||||
from typing import Self,List
|
||||
from pydantic import BaseModel, field_serializer, field_validator,model_validator,ConfigDict
|
||||
|
||||
|
||||
|
||||
class StudentRequest(BaseModel):
|
||||
class_id:int |None = None
|
||||
stu_name:str |None = None
|
||||
stu_name:str
|
||||
age:int |None = None
|
||||
gender:str |None = None
|
||||
id_card:str
|
||||
native_place:str |None = None
|
||||
birthday:date
|
||||
birthday:date |None = None
|
||||
school:str |None = None
|
||||
major:str |None = None
|
||||
degree:str |None = None
|
||||
admission_date:date
|
||||
graduation_date:date
|
||||
admission_date:date |None = None
|
||||
graduation_date:date |None = None
|
||||
@field_validator('age')
|
||||
@classmethod
|
||||
def check_age(cls, v):
|
||||
@@ -29,19 +31,78 @@ class StudentRequest(BaseModel):
|
||||
raise ValueError ('入学日期不能晚于毕业日期')
|
||||
return self
|
||||
|
||||
class StudentResponse(BaseModel):
|
||||
class StuUpdateRequest(BaseModel):
|
||||
class_id: int | None = None
|
||||
stu_name: str | None = None
|
||||
age: int | None = None
|
||||
gender: str | None = None
|
||||
id_card: str | None = None
|
||||
native_place: str | None = None
|
||||
birthday: date | None = None
|
||||
school: str | None = None
|
||||
major: str | None = None
|
||||
degree: str | None = None
|
||||
admission_date: date | None = None
|
||||
graduation_date: date | None = None
|
||||
progress: int | None = None
|
||||
|
||||
@field_validator('age')
|
||||
@classmethod
|
||||
def check_age(cls, v):
|
||||
if v is not None and v < 0:
|
||||
raise ValueError('年龄不能为负数')
|
||||
return v
|
||||
|
||||
@model_validator(mode='after')
|
||||
def check_admission_graduation(self) -> Self:
|
||||
if self.admission_date and self.graduation_date:
|
||||
if self.admission_date > self.graduation_date:
|
||||
raise ValueError('入学日期不能晚于毕业日期')
|
||||
return self
|
||||
|
||||
class StugetResponse(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
code:int = 200
|
||||
detail:str = 'ok'
|
||||
stu_name:str
|
||||
age:int
|
||||
gender:str
|
||||
progress:int
|
||||
stu_id:int | None = None
|
||||
class_id: int | None = None
|
||||
stu_name: str | None = None
|
||||
age: int | None = None
|
||||
gender: str | None = None
|
||||
id_card: str | None = None
|
||||
native_place: str | None = None
|
||||
birthday: date | None = None
|
||||
school: str | None = None
|
||||
major: str | None = None
|
||||
degree: str | None = None
|
||||
admission_date: date | None = None
|
||||
graduation_date: date | None = None
|
||||
progress: int
|
||||
|
||||
@field_serializer('progress')
|
||||
def int_to_string(cls,progress:int):
|
||||
d1 ={
|
||||
0:'学习中',
|
||||
1:'求职中',
|
||||
2:'已就业'
|
||||
def progress_to_label(self, progress):
|
||||
d1 = {
|
||||
0: '学习中',
|
||||
1: '求职中',
|
||||
2: '已就业'
|
||||
}
|
||||
return d1.get(progress,'暂不明确')
|
||||
try:
|
||||
return d1.get(int(progress), '暂不明确')
|
||||
except (TypeError, ValueError):
|
||||
return progress
|
||||
|
||||
class StuPageResponse(BaseModel):
|
||||
code: int = 200
|
||||
detail: str = "ok"
|
||||
page: int
|
||||
page_size: int
|
||||
totals: int
|
||||
data: List[StugetResponse]
|
||||
|
||||
class StudelResponse(BaseModel):
|
||||
code: int = 200
|
||||
detail: str = "ok"
|
||||
totals: int
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
from datetime import date
|
||||
from pydantic import BaseModel
|
||||
|
||||
from pydantic.v1 import BaseModel
|
||||
from datetime import datetime
|
||||
|
||||
class Teacher_RequestModel(BaseModel):
|
||||
teac_id: int
|
||||
teac_name:str
|
||||
teac_gender:str
|
||||
teac_age:int
|
||||
teac_position:str
|
||||
status=int
|
||||
create_date:datetime
|
||||
update_date:datetime
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Teacher_ResponseModel(BaseModel):
|
||||
code:int=200
|
||||
detail:str='OK!'
|
||||
teac_name:str
|
||||
teac_gender:str
|
||||
teac_age:int
|
||||
teac_position:str
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import declarative_base,sessionmaker
|
||||
|
||||
db_url = 'mysql+pymysql://root:123456@127.0.0.1:3306/ai0824?charset=utf8mb4'
|
||||
db_url = 'mysql+pymysql://root:123456@192.168.5.12:3306/ai0824?charset=utf8mb4'
|
||||
engine = create_engine(db_url,pool_size=50)
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ wl_student(学⽣编号、学⽣班级、学⽣姓名、年龄、性别、籍
|
||||
学⽣考核成绩表 **hzl 做完了**
|
||||
wl_score(学⽣编号、考核序次、成绩、删除状态(0:已删除,1:初始值)、作成时间、更新时间)
|
||||
|
||||
学⽣就业管理模表 **cyl 做成中**
|
||||
学⽣就业管理模表 **cyl 做完了**
|
||||
wl_employment(学⽣编号、就业开放时间(只有进入就业课的才会输入数据)、offer下发时间()、就业公司名称、就业薪资、删除状态(0:已删除,1:初始值)、作成时间、更新时间)
|
||||
|
||||
班级管理表 **xxx 做成中**
|
||||
@@ -18,15 +18,11 @@ wl_class(班级编号,开课时间,删除状态(0:已删除,1:初始
|
||||
⽼师管理表 **sgt 做完了**
|
||||
wl_teacher(老师编号,姓名,性别,年龄,删除状态(0:已删除,1:初始值),职位,作成时间,更新时间)
|
||||
|
||||
dao层(每一个功能就是一个函数,判断能否功能复用)
|
||||
|
||||
通用模块
|
||||
|
||||
学生模块
|
||||
实现增加学生的功能 **xxx 做成中**
|
||||
实现查询学生的功能:需要能进行多条件查询 **xxx 做成中**
|
||||
实现更新学生信息的功能 **xxx 做成中**
|
||||
实现删除学生信息的功能 (更新删除状态这个列,即软删除)**xxx 做成中**
|
||||
实现增加学生的功能 **msj 做成中**
|
||||
实现查询学生的功能:需要能进行多条件查询 **msj 做成中**
|
||||
实现更新学生信息的功能 **msj 做成中**
|
||||
实现删除学生信息的功能 (更新删除状态这个列,即软删除)**msj 做成中**
|
||||
|
||||
成绩模块
|
||||
实现增加学生成绩的功能 **hzl 做成中**
|
||||
@@ -35,10 +31,10 @@ dao层(每一个功能就是一个函数,判断能否功能复用)
|
||||
实现删除成绩的功能 **hzl 做成中**
|
||||
|
||||
就业模块
|
||||
实现增加学生就业信息的功能 **xxx 做成中**
|
||||
实现查询学生就业信息的功能 **xxx 做成中**
|
||||
实现修改学生就业信息的功能 **xxx 做成中**
|
||||
实现删除学生就业信息的功能 **xxx 做成中**
|
||||
实现增加学生就业信息的功能 **cyl 做成中**
|
||||
实现查询学生就业信息的功能 **cyl 做成中**
|
||||
实现修改学生就业信息的功能 **cyl 做成中**
|
||||
实现删除学生就业信息的功能 **cyl 做成中**
|
||||
|
||||
班级模块
|
||||
实现增加班级的功能 **xxx 做成中**
|
||||
@@ -47,17 +43,17 @@ dao层(每一个功能就是一个函数,判断能否功能复用)
|
||||
实现删除班级的功能 **xxx 做成中**
|
||||
|
||||
老师模块
|
||||
实现增加老师的功能 **xxx 做成中**
|
||||
实现查询老师的功能 **xxx 做成中**
|
||||
实现更新老师的功能 **xxx 做成中**
|
||||
实现删除老师的功能 **xxx 做成中**
|
||||
实现增加老师的功能 **sgt 做完了**
|
||||
实现查询老师的功能 **sgt 做完了**
|
||||
实现更新老师的功能 **sgt 做完了**
|
||||
实现删除老师的功能 **sgt 做完了**
|
||||
|
||||
统计分析模块
|
||||
实现根据年龄查询学生信息的功能 **mrz 已作成**
|
||||
实现统计每个班级的学员总数以及男女生的总数的功能 **mrz 做成中**
|
||||
实现根据成绩查询学员信息的功能 **xxx 做成中**
|
||||
实现统计每次考试每个班级的平均分并排序的功能 **xxx 做成中**
|
||||
实现统计薪资最高的前五名的学员信息 **xxx 做成中**
|
||||
实现查询每个学生的就业时长 **xxx 做成中**
|
||||
实现统计每个班级的平均就业时长 **xxx 做成中**
|
||||
实现统计每个班级的学员总数以及男女生的总数的功能 **mrz 已作成**
|
||||
实现根据成绩查询学员信息的功能 **mrz 已作成**
|
||||
实现统计每次考试每个班级的平均分并排序的功能 **mrz 已作成**
|
||||
实现统计薪资最高的前五名的学员信息 **mrz 已作成**
|
||||
实现查询每个学生的就业时长 **msj 做成中**
|
||||
实现统计每个班级的平均就业时长 **xxx 已作成**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user