Merge remote-tracking branch 'origin/conding' into conding
# Conflicts: # PythonProject/api/student_api.py
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
from fastapi import Depends,HTTPException
|
||||
|
||||
from util.database import get_db
|
||||
|
||||
from model.grade_model import *
|
||||
|
||||
|
||||
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()
|
||||
if r1:
|
||||
return r1
|
||||
else:
|
||||
raise HTTPException(status_code=404,detail="学生不存在")
|
||||
@@ -1,8 +1,10 @@
|
||||
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 sqlalchemy import func
|
||||
|
||||
# 实现根据年龄查询学生信息的功能
|
||||
def select_age(min_age,max_age,session=Depends(get_db)):
|
||||
try:
|
||||
if min_age is None and max_age is None:
|
||||
@@ -18,6 +20,16 @@ def select_age(min_age,max_age,session=Depends(get_db)):
|
||||
except Exception:
|
||||
raise HTTPException(status_code=500,detail="查询异常")
|
||||
|
||||
# 实现统计每个班级的学员总数以及男女生的总数的功能
|
||||
def select_all(session=Depends(get_db)):
|
||||
print('1234')
|
||||
try:
|
||||
l1 = session.query(Student_Model.class_id,func.count(1)).group_by(Student_Model.class_id,Student_Model.gender).all()
|
||||
print(l1)
|
||||
return l1
|
||||
except Exception:
|
||||
raise HTTPException(status_code=500,detail="查询异常")
|
||||
|
||||
def add_student_dao(o,db=Depends(get_db)):
|
||||
try:
|
||||
o1 = Student_Model( **o)
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
from fastapi import HTTPException,Depends
|
||||
|
||||
from PythonProject.model.teacher_model import Teacher_Model
|
||||
from model.all_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)):
|
||||
try:
|
||||
data=req.model_dump()
|
||||
|
||||
Reference in New Issue
Block a user