From ce62e18b14c5c25af27e1442a237c39866e6d516 Mon Sep 17 00:00:00 2001 From: Windows <2209639385@qq.com> Date: Mon, 21 Sep 2026 12:50:10 +0800 Subject: [PATCH 1/7] nb --- PythonProject/dao/grade_dao.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/PythonProject/dao/grade_dao.py b/PythonProject/dao/grade_dao.py index e69de29..daffaf5 100644 --- a/PythonProject/dao/grade_dao.py +++ b/PythonProject/dao/grade_dao.py @@ -0,0 +1,10 @@ +from fastapi import Depends + +from util.database import get_db + +from model.grade_model import * + + +def get_grade( stu_id:int + ,db=Depends(get_db)): + r =db.query(WlScore).filter(WlScore.stu_id == stu_id).all() \ No newline at end of file From ff088678236eae88dc70dd6dca64b1b499ce049a Mon Sep 17 00:00:00 2001 From: Windows <2209639385@qq.com> Date: Mon, 21 Sep 2026 14:06:18 +0800 Subject: [PATCH 2/7] nb --- PythonProject/dao/grade_dao.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/PythonProject/dao/grade_dao.py b/PythonProject/dao/grade_dao.py index daffaf5..7afd623 100644 --- a/PythonProject/dao/grade_dao.py +++ b/PythonProject/dao/grade_dao.py @@ -1,4 +1,4 @@ -from fastapi import Depends +from fastapi import Depends,HTTPException from util.database import get_db @@ -7,4 +7,9 @@ from model.grade_model import * def get_grade( stu_id:int ,db=Depends(get_db)): - r =db.query(WlScore).filter(WlScore.stu_id == stu_id).all() \ No newline at end of file + + r1 =db.query(WlScore).filter(WlScore.stu_id == stu_id,WlScore.delete_status == 0).all() + if r1: + return r1 + else: + raise HTTPException(status_code=404,detail="学生不存在") From 9de7f64802802c64502049c3324ddf29f4f8fd97 Mon Sep 17 00:00:00 2001 From: Windows <2209639385@qq.com> Date: Mon, 21 Sep 2026 14:12:04 +0800 Subject: [PATCH 3/7] nb --- PythonProject/dao/grade_dao.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PythonProject/dao/grade_dao.py b/PythonProject/dao/grade_dao.py index 7afd623..8ee4926 100644 --- a/PythonProject/dao/grade_dao.py +++ b/PythonProject/dao/grade_dao.py @@ -5,7 +5,7 @@ from util.database import get_db from model.grade_model import * -def get_grade( stu_id:int +def get_grade_dao( stu_id:int ,db=Depends(get_db)): r1 =db.query(WlScore).filter(WlScore.stu_id == stu_id,WlScore.delete_status == 0).all() From f82f46ef4fc67ad3b04d2931f98f04acd3a6cdfd Mon Sep 17 00:00:00 2001 From: wolin_chenyulin001 <123@163.com> Date: Mon, 21 Sep 2026 14:13:23 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=B0=B1=E4=B8=9A=E7=9A=84schema=EF=BC=9A?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E4=BD=93=E5=92=8C=E5=93=8D=E5=BA=94=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PythonProject/schema/employment_schema.py | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/PythonProject/schema/employment_schema.py b/PythonProject/schema/employment_schema.py index e69de29..47a153f 100644 --- a/PythonProject/schema/employment_schema.py +++ b/PythonProject/schema/employment_schema.py @@ -0,0 +1,30 @@ +from fastapi import Query,HTTPException +from pydantic import BaseModel, field_validator +from datetime import datetime + +class EmlpoymentRequest(BaseModel): + stu_id: int=Query(ge=1) + email: str|None + employment_opening_date:datetime + offer_issuance_date:datetime + company_name:str + company_address:str|None + salary:float + + @field_validator('stu_id') + def check(cls,n): + i = cls.model_dump() + if i['stu_id'] == n: + return n + raise HTTPException(status_code=404,detail='未找到该学生的就业信息!') + +class EmploymentResponse(BaseModel): + code:int = 200 + detail:str = 'OK' + stu_id: int + email: str | None + employment_opening_date: datetime + offer_issuance_date: datetime + company_name: str + company_address: str | None + salary: float \ No newline at end of file From 3f083bf8504ea92fc62c5b7d2c180d0c72f6ab4d Mon Sep 17 00:00:00 2001 From: wolin_chenyulin001 <123@163.com> Date: Mon, 21 Sep 2026 14:13:58 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=B0=B1=E4=B8=9A=E7=9A=84model=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PythonProject/model/employment_model.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PythonProject/model/employment_model.py b/PythonProject/model/employment_model.py index e5930f8..aaae71d 100644 --- a/PythonProject/model/employment_model.py +++ b/PythonProject/model/employment_model.py @@ -1,5 +1,5 @@ from util.database import Base,engine -from sqlalchemy import Column,Integer,String,DATE,DATETIME,ForeignKey +from sqlalchemy import Column,Integer,String,DATE,DATETIME,ForeignKey,Numeric from datetime import datetime class Employment_info(Base): @@ -38,7 +38,8 @@ class Employment_info(Base): ,comment='就业公司地址' ) - salary = Column(Integer + salary = Column(Numeric(10,2) + ,nullable=False ,comment='薪资' ) From baf87e003ffc2169dd3545d111f70744704190d9 Mon Sep 17 00:00:00 2001 From: Windows <2209639385@qq.com> Date: Mon, 21 Sep 2026 14:18:38 +0800 Subject: [PATCH 6/7] nb --- PythonProject/api/grade_api.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/PythonProject/api/grade_api.py b/PythonProject/api/grade_api.py index b87e9dc..2f372eb 100644 --- a/PythonProject/api/grade_api.py +++ b/PythonProject/api/grade_api.py @@ -1,9 +1,14 @@ from fastapi import APIRouter,Depends,HTTPException,Path from util.database import get_db -from model.student_model import Student_Model +from model.grade_model import * +from dao.grade_dao import * -gradeAPI = APIRouter() +gradeAPI = APIRouter(tags=['学生考核成绩']) -@gradeAPI.get(f"/grade/{id}",summary="根据ID查询单条成绩") -def get_grade(id:int,db=Depends(get_db)): - r =db. +@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,'msg':'查询成功','data':res} + except Exception as e: + raise HTTPException(status_code=500,detail=f'数据库查询异常:{str(e)}') From 275a733dd2d3fbf420b4d6fcb805b548884328b9 Mon Sep 17 00:00:00 2001 From: Windows <2209639385@qq.com> Date: Mon, 21 Sep 2026 14:34:03 +0800 Subject: [PATCH 7/7] nb --- PythonProject/main.py | 4 ++++ PythonProject/model/grade_model.py | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/PythonProject/main.py b/PythonProject/main.py index ce32cfe..3070f6f 100644 --- a/PythonProject/main.py +++ b/PythonProject/main.py @@ -1,5 +1,9 @@ from fastapi import FastAPI from api.student_api import * +from api.grade_api import * + app = FastAPI() app.include_router(studentapi) + +app.include_router(gradeAPI,tags=['订单接口']) diff --git a/PythonProject/model/grade_model.py b/PythonProject/model/grade_model.py index a1235e1..4594767 100644 --- a/PythonProject/model/grade_model.py +++ b/PythonProject/model/grade_model.py @@ -2,7 +2,6 @@ from sqlalchemy import Column, Integer, Numeric, DATETIME,ForeignKey from datetime import datetime from util.database import Base,engine -# 成绩、删除状态(0:已删除,1:初始值)、作成时间、更新时间 class WlScore(Base): __tablename__ = 'wl_score'