From 94c13a69e4683206c99b5e40580af3c834332897 Mon Sep 17 00:00:00 2001 From: wolin_chenyulin001 <123@163.com> Date: Mon, 21 Sep 2026 09:45:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?cyl=E6=B5=8B=E8=AF=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 需求文档.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/需求文档.md b/需求文档.md index 42c7048..52ab3e7 100644 --- a/需求文档.md +++ b/需求文档.md @@ -9,7 +9,7 @@ wl_student(学⽣编号、学⽣班级、学⽣姓名、年龄、性别、籍 学⽣考核成绩表 **xxx 做成中** wl_score(学⽣编号、考核序次、成绩、删除状态(0:已删除,1:初始值)、作成时间、更新时间) -学⽣就业管理模表 **xxx 做成中** +学⽣就业管理模表 **cyl 做成中** wl_employment(学⽣编号、就业开放时间(只有进入就业课的才会输入数据)、offer下发时间()、就业公司名称、就业薪资、删除状态(0:已删除,1:初始值)、作成时间、更新时间) 班级管理表 **xxx 做成中** -- 2.54.0 From c2481fc5c616328716c7f97327c3aba0228fcffd Mon Sep 17 00:00:00 2001 From: test1 Date: Mon, 21 Sep 2026 09:52:48 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PythonProject/model/teacher_model.py | 20 +++++++++++++++++--- 需求文档.md | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/PythonProject/model/teacher_model.py b/PythonProject/model/teacher_model.py index 49035bc..eff69dc 100644 --- a/PythonProject/model/teacher_model.py +++ b/PythonProject/model/teacher_model.py @@ -1,3 +1,17 @@ -# MaRuiZhi NB -# MaRuiZhi NB Plus -# hahaha \ No newline at end of file +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) + diff --git a/需求文档.md b/需求文档.md index 42c7048..a3a8b7c 100644 --- a/需求文档.md +++ b/需求文档.md @@ -15,7 +15,7 @@ wl_employment(学⽣编号、就业开放时间(只有进入就业课的才 班级管理表 **xxx 做成中** wl_class(班级编号,开课时间,删除状态(0:已删除,1:初始值),班主任(老师编号),授课⽼师(老师编号),作成时间,更新时间) -⽼师管理表 **xxx 做成中** +⽼师管理表 **sgt 做成中** wl_teacher(老师编号,姓名,性别,年龄,删除状态(0:已删除,1:初始值),职位,作成时间,更新时间) dao层(每一个功能就是一个函数,判断能否功能复用) -- 2.54.0 From def360eae6f309a6eaac3b38a2005555790e7372 Mon Sep 17 00:00:00 2001 From: maruizhi <3088243241@qq.com> Date: Mon, 21 Sep 2026 09:54:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AD=A6=E7=94=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PythonProject/dao/student_dao.py | 49 +++++++++++++++++++++++--- PythonProject/model/student_model.py | 9 +++-- PythonProject/schema/student_schema.py | 33 +++++++++++++++-- 3 files changed, 79 insertions(+), 12 deletions(-) diff --git a/PythonProject/dao/student_dao.py b/PythonProject/dao/student_dao.py index edc92f2..5188ffb 100644 --- a/PythonProject/dao/student_dao.py +++ b/PythonProject/dao/student_dao.py @@ -1,6 +1,7 @@ from fastapi import HTTPException,Depends from util.database import get_db from model.student_model import Student_Model +from typing import List, Optional, Dict, Any def select_age(min_age,max_age,session=Depends(get_db)): try: @@ -17,8 +18,48 @@ def select_age(min_age,max_age,session=Depends(get_db)): except Exception: raise HTTPException(status_code=500,detail="查询异常") -def abc(): - return None - - +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 +def update_student_dao(stu_id,update_data,db): + try: + rows = db.query( Student_Model ).filter( Student_Model.stu_id == stu_id ).update( update_data ) + except: + db.rollback() + return False + else: + db.commit() + 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 + ) -> tuple[List[Dict[str, Any]], int]: + q = db.query(Student_Model) + if stu_id: + q = q.filter(Student_Model.stu_id == stu_id) + if stu_name: + q = q.filter(Student_Model.stu_name.like(f"%{stu_name}%")) + if 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 diff --git a/PythonProject/model/student_model.py b/PythonProject/model/student_model.py index f631579..4f62126 100644 --- a/PythonProject/model/student_model.py +++ b/PythonProject/model/student_model.py @@ -8,10 +8,10 @@ class Student_Model(Base): , primary_key=True , autoincrement=True ,comment='学生编号') - # class_id=Column(Integer - # ,ForeignKey('wl_class.class_id') - # ,nullable=False - # ,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='性别') @@ -30,4 +30,3 @@ class Student_Model(Base): ,onupdate=datetime.now) Base.metadata.create_all(engine) - diff --git a/PythonProject/schema/student_schema.py b/PythonProject/schema/student_schema.py index c950945..7ee65af 100644 --- a/PythonProject/schema/student_schema.py +++ b/PythonProject/schema/student_schema.py @@ -1,4 +1,33 @@ -from pydantic import BaseModel,field_serializer +from datetime import date +from typing import Self +from pydantic import BaseModel, field_serializer, field_validator,model_validator + + +class StudentRequest(BaseModel): + class_id:int |None = None + stu_name:str |None = None + age:int |None = None + gender:str |None = None + native_place:str |None = None + birthday:date + school:str |None = None + major:str |None = None + degree:str |None = None + admission_date:date + graduation_date:date + @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 StudentResponse(BaseModel): code:int = 200 @@ -16,5 +45,3 @@ class StudentResponse(BaseModel): 2:'已就业' } return d1.get(progress,'暂不明确') - - -- 2.54.0