This commit is contained in:
msj
2026-09-21 22:25:16 +08:00
parent f95d627b7f
commit a4ff2dcfe7
3 changed files with 14 additions and 15 deletions
+7 -6
View File
@@ -2,22 +2,23 @@ from fastapi import Depends
from util.database import get_db
from model.all_model import Student_Model
from typing import List, Optional, Dict, Any
from datetime import datetime
def add_student_dao(o,db):
try:
o1 = Student_Model( **o)
db.add(o1)
db.commit()
stu_id=o1.stu_id
return db.query(Student_Model).filter(Student_Model.stu_id == stu_id).first()
except:
db.rollback()
return False
else:
db.commit()
return True
return None
def delete_student_dao(stu_id,db):
try:
rows = db.query(Student_Model).filter(Student_Model.stu_id == stu_id,Student_Model.delete_status == 0)\
.update({'delete_status':1})
.update({'delete_status':1,'delete_time': datetime.now()})
db.commit()
except:
db.rollback()
@@ -52,7 +53,7 @@ def get_student_dao(stu_id:Optional[int]
q= q.filter(Student_Model.class_id == class_id,Student_Model.delete_status == 0)
total = q.count()
r = q.offset((page - 1) * page_size).limit(page_size).all()
return total,r
return r,total
except:
db.rollback()
return [],0