Merge remote-tracking branch 'origin/conding' into conding
This commit is contained in:
@@ -46,8 +46,6 @@ def update_students(stu_id:int
|
|||||||
if not d:
|
if not d:
|
||||||
raise HTTPException(status_code=400, detail='更新内容不能为空')
|
raise HTTPException(status_code=400, detail='更新内容不能为空')
|
||||||
r = update_student_dao( stu_id=stu_id,update_data=d,db=db )
|
r = update_student_dao( stu_id=stu_id,update_data=d,db=db )
|
||||||
if r == 'conflict':
|
|
||||||
raise HTTPException(status_code=409, detail = '身份证号已被其他学生占用')
|
|
||||||
if r == 'error':
|
if r == 'error':
|
||||||
raise HTTPException(status_code=500, detail='更新失败,请稍后重试')
|
raise HTTPException(status_code=500, detail='更新失败,请稍后重试')
|
||||||
if not r:
|
if not r:
|
||||||
|
|||||||
@@ -38,15 +38,6 @@ def delete_student_dao(stu_id, db):
|
|||||||
def update_student_dao(stu_id, update_data, db):
|
def update_student_dao(stu_id, update_data, db):
|
||||||
if not update_data:
|
if not update_data:
|
||||||
return 0
|
return 0
|
||||||
id_card = update_data.get('id_card')
|
|
||||||
if id_card:
|
|
||||||
conflict = (db.query(Student_Model)
|
|
||||||
.filter(Student_Model.id_card == id_card,
|
|
||||||
Student_Model.stu_id != stu_id,
|
|
||||||
Student_Model.delete_status == 0)
|
|
||||||
.first())
|
|
||||||
if conflict:
|
|
||||||
return 'conflict'
|
|
||||||
try:
|
try:
|
||||||
rows = (db.query(Student_Model)
|
rows = (db.query(Student_Model)
|
||||||
.filter(Student_Model.stu_id == stu_id,
|
.filter(Student_Model.stu_id == stu_id,
|
||||||
@@ -59,7 +50,6 @@ def update_student_dao(stu_id, update_data, db):
|
|||||||
except Exception:
|
except Exception:
|
||||||
db.rollback()
|
db.rollback()
|
||||||
return 'error'
|
return 'error'
|
||||||
|
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
def get_student_dao(stu_id:Optional[int]
|
def get_student_dao(stu_id:Optional[int]
|
||||||
|
|||||||
Reference in New Issue
Block a user