|
@@ -267,38 +267,38 @@ async def create_emergency_plan(
|
|
|
# raise HTTPException(status_code=500, detail=str(e))
|
|
|
#
|
|
|
#
|
|
|
-# @router.delete('/plan/delete')
|
|
|
-# async def delete_emergency_plan(
|
|
|
-# plan_data: dict,
|
|
|
-# db: Session = Depends(get_db)
|
|
|
-# ):
|
|
|
-# try:
|
|
|
-# # 提取请求数据
|
|
|
-# query = db.query(EmergencyPlan)
|
|
|
-# query = query.filter(EmergencyPlan.plan_id == plan_data.get('plan_id'))
|
|
|
-# query = query.filter(EmergencyPlan.del_flag != '2')
|
|
|
-# plan = query.first()
|
|
|
-# if not plan:
|
|
|
-# detail = "预案不存在"
|
|
|
-# raise HTTPException(status_code=404, detail="预案不存在")
|
|
|
-#
|
|
|
-# plan.del_flag = '2'
|
|
|
-#
|
|
|
-# # 更新到数据库会话并提交
|
|
|
-# db.commit()
|
|
|
-# db.refresh(new_plan) # 可选,如果需要刷新实例状态
|
|
|
-#
|
|
|
-# # 返回创建成功的响应
|
|
|
-# return {
|
|
|
-# "code": 200,
|
|
|
-# "msg": "预案删除成功",
|
|
|
-# "data": None
|
|
|
-# }
|
|
|
-# except Exception as e:
|
|
|
-# # 处理异常
|
|
|
-# if str(e) == '':
|
|
|
-# e = detail
|
|
|
-# raise HTTPException(status_code=500, detail=str(e))
|
|
|
+@router.delete('/plan/delete/{planUid}')
|
|
|
+async def delete_emergency_plan(
|
|
|
+ planUid: str,
|
|
|
+ db: Session = Depends(get_db)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ # 提取请求数据
|
|
|
+ query = db.query(EmergencyPlan)
|
|
|
+ query = query.filter(EmergencyPlan.del_flag != '2')
|
|
|
+ query = query.filter(EmergencyPlan.plan_id == planUid)
|
|
|
+ plan = query.first()
|
|
|
+ if not plan:
|
|
|
+ detail = "预案不存在"
|
|
|
+ raise HTTPException(status_code=404, detail="预案不存在")
|
|
|
+
|
|
|
+ plan.del_flag = '2'
|
|
|
+
|
|
|
+ # 更新到数据库会话并提交
|
|
|
+ db.commit()
|
|
|
+ db.refresh(plan) # 可选,如果需要刷新实例状态
|
|
|
+
|
|
|
+ # 返回创建成功的响应
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "预案删除成功",
|
|
|
+ "data": None
|
|
|
+ }
|
|
|
+ except Exception as e:
|
|
|
+ # 处理异常
|
|
|
+ if str(e) == '':
|
|
|
+ e = detail
|
|
|
+ raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
|
|
|
@router.get('/drill/list')
|
|
@@ -482,6 +482,38 @@ async def create_emergency_drill(
|
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
|
|
|
+@router.delete('/drill/delete/{drillUid}')
|
|
|
+async def delete_emergency_drill(
|
|
|
+ drillUid: str,
|
|
|
+ db: Session = Depends(get_db)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ # 提取请求数据
|
|
|
+ query = db.query(EmergencyDrill)
|
|
|
+ query = query.filter(EmergencyDrill.del_flag != '2')
|
|
|
+ query = query.filter(EmergencyDrill.drill_id == drillUid)
|
|
|
+ drill = query.first()
|
|
|
+ if not drill:
|
|
|
+ detail = "演练不存在"
|
|
|
+ raise HTTPException(status_code=404, detail="演练不存在")
|
|
|
+
|
|
|
+ drill.del_flag = '2'
|
|
|
+
|
|
|
+ # 更新到数据库会话并提交
|
|
|
+ db.commit()
|
|
|
+ db.refresh(drill) # 可选,如果需要刷新实例状态
|
|
|
+
|
|
|
+ # 返回创建成功的响应
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "演练删除成功",
|
|
|
+ "data": None
|
|
|
+ }
|
|
|
+ except Exception as e:
|
|
|
+ # 处理异常
|
|
|
+ if str(e) == '':
|
|
|
+ e = detail
|
|
|
+ raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
|
|
|
|
|
@@ -511,7 +543,7 @@ async def get_emergency_training_list(
|
|
|
# 将查询结果转换为列表形式的字典
|
|
|
emergency_training_list = [
|
|
|
{
|
|
|
- "textId": training.training_id,
|
|
|
+ "trainingId": training.training_id,
|
|
|
"theme": training.training_theme,
|
|
|
"unitName": training.training_unit,
|
|
|
"peopleNum": "%s人"%training.participant_count,
|
|
@@ -587,4 +619,37 @@ async def create_emergency_training(
|
|
|
}
|
|
|
except Exception as e:
|
|
|
# 处理异常
|
|
|
- raise HTTPException(status_code=500, detail=str(e))
|
|
|
+ raise HTTPException(status_code=500, detail=str(e))
|
|
|
+
|
|
|
+@router.delete('/training/delete/{trainingUid}')
|
|
|
+async def delete_emergency_training(
|
|
|
+ trainingUid: str,
|
|
|
+ db: Session = Depends(get_db)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ # 提取请求数据
|
|
|
+ query = db.query(EmergencyTrainingSession)
|
|
|
+ query = query.filter(EmergencyTrainingSession.del_flag != '2')
|
|
|
+ query = query.filter(EmergencyTrainingSession.training_id == trainingUid)
|
|
|
+ training = query.first()
|
|
|
+ if not drill:
|
|
|
+ detail = "培训不存在"
|
|
|
+ raise HTTPException(status_code=404, detail="培训不存在")
|
|
|
+
|
|
|
+ training.del_flag = '2'
|
|
|
+
|
|
|
+ # 更新到数据库会话并提交
|
|
|
+ db.commit()
|
|
|
+ db.refresh(training) # 可选,如果需要刷新实例状态
|
|
|
+
|
|
|
+ # 返回创建成功的响应
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "培训删除成功",
|
|
|
+ "data": None
|
|
|
+ }
|
|
|
+ except Exception as e:
|
|
|
+ # 处理异常
|
|
|
+ if str(e) == '':
|
|
|
+ e = detail
|
|
|
+ raise HTTPException(status_code=500, detail=str(e))
|