更新debug
This commit is contained in:
@@ -56,12 +56,12 @@ def add_address(
|
||||
|
||||
|
||||
@CURD.put('/emp',tags=['更改就业信息'])
|
||||
def updata_stuinfo(company:PostRequest
|
||||
def updata_stuinfo(up:PostRequest
|
||||
,id:int
|
||||
,db=Depends(get_db)
|
||||
):
|
||||
d = company.model_dump(exclude_unset=True)
|
||||
r = update_orders_dao(id=id, update_data=d, db=db)
|
||||
d = up.model_dump(exclude_unset=True)
|
||||
r = update_emp_dao(id=id, update_data=d, db=db)
|
||||
if not r:
|
||||
raise HTTPException(status_code=500, detail='没有更新!')
|
||||
return {'code': 200, 'totals': r, 'detail': '更新成功'}
|
||||
@@ -69,7 +69,7 @@ def updata_stuinfo(company:PostRequest
|
||||
@CURD.delete('/emp',tags=['删除就业信息'])
|
||||
def delete_stuinfo(id:int
|
||||
,db=Depends(get_db)):
|
||||
rows = delete_orders_dao(id, db)
|
||||
rows = delete_emp_dao(id, db)
|
||||
if not rows:
|
||||
raise HTTPException(status_code=500, detail='没有删除!')
|
||||
return {'code': 200, 'totals': rows, 'detail': '删除成功'}
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ def add_address_dao(o,db):
|
||||
return True
|
||||
|
||||
|
||||
def update_orders_dao(id,update_data,db):
|
||||
def update_emp_dao(id,update_data,db):
|
||||
try: # 数据更新是有返回值的,返回的是影响的行数
|
||||
rows = db.query( Employments ).filter( Employments.id == id ).update( update_data )
|
||||
except Exception as e:
|
||||
@@ -98,7 +98,7 @@ def get_emp_dao(
|
||||
"is_deleted":i.is_deleted } for i,compname,somewhere in r ]
|
||||
|
||||
|
||||
def delete_orders_dao(id,db):
|
||||
def delete_emp_dao(id,db):
|
||||
try: # 删除有返回值,删除的行数
|
||||
rows = db.query(Employments).filter(Employments.id == id).update( is_deleted=1 )
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ class PostRequest(BaseModel):
|
||||
salary: int|None=None
|
||||
employment_open_date:date|None=None
|
||||
offer_date:date|None=None
|
||||
updated_date:date|None=None
|
||||
is_deleted:int=0
|
||||
class EmpResponse(BaseModel):
|
||||
code: int = 200
|
||||
detail: str = 'OK'
|
||||
|
||||
Reference in New Issue
Block a user