Merge remote-tracking branch 'origin/conding' into conding
This commit is contained in:
@@ -24,7 +24,7 @@ def get_students(stu_id:int|None=None
|
||||
raise HTTPException(status_code=404,detail='学生不存在')
|
||||
return StudentPageResponse(page=page,
|
||||
page_size=page_size,
|
||||
total=total,
|
||||
totals=total,
|
||||
data=r)
|
||||
|
||||
@StudentAPI.put('/{stu_id}',tags=['学⽣基本信息管理模块'],summary='学生信息更新接口',description='更新学生信息')
|
||||
@@ -50,7 +50,7 @@ def del_students(stu_id:int
|
||||
@StudentAPI.post('/students',tags=['学⽣基本信息管理模块'],response_model=StugetResponse,summary='学生信息新增接口',description='新增学生信息')
|
||||
def add_students(s:StudentRequest
|
||||
,db=Depends(get_db)):
|
||||
d=s.model_dump(exclude_unset=False)
|
||||
d=s.model_dump(exclude_unset=True)
|
||||
stu_new=add_student_dao(o=d,db=db)
|
||||
if not stu_new:
|
||||
raise HTTPException(status_code=500,detail='添加失败')
|
||||
|
||||
@@ -44,13 +44,13 @@ def get_student_dao(stu_id:Optional[int]
|
||||
,db
|
||||
) -> tuple[List[Dict[str, Any]], int]:
|
||||
try:
|
||||
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,Student_Model.delete_status == 0)
|
||||
q = q.filter(Student_Model.stu_id == stu_id)
|
||||
if stu_name and stu_name.strip() != "":
|
||||
q = q.filter(Student_Model.stu_name.like(f"%{stu_name}%"),Student_Model.delete_status == 0)
|
||||
q = q.filter(Student_Model.stu_name.like(f"%{stu_name}%"))
|
||||
if class_id:
|
||||
q= q.filter(Student_Model.class_id == class_id,Student_Model.delete_status == 0)
|
||||
q= q.filter(Student_Model.class_id == class_id)
|
||||
total = q.count()
|
||||
r = q.offset((page - 1) * page_size).limit(page_size).all()
|
||||
return r,total
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from datetime import date
|
||||
from typing import Self,List
|
||||
from pydantic import BaseModel, field_serializer, field_validator,model_validator
|
||||
from pydantic import BaseModel, field_serializer, field_validator,model_validator,ConfigDict
|
||||
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ class StudentResponse(BaseModel):
|
||||
return d1.get(progress,'暂不明确')
|
||||
|
||||
class StugetResponse(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
code:int = 200
|
||||
detail:str = 'ok'
|
||||
class_id: int | None = None
|
||||
|
||||
Reference in New Issue
Block a user