def delete_interface(interface_id, user_id): """删除接口""" # 查询是否在调度内 if InterfaceModel.get_schedule_detail(db.etl_db, interface_id): abort(400, **make_result(status=400, msg='调度任务运行中, 请停止调度任务后删除')) # 查询是否有任务依赖 ids = InterfaceModel.get_job_prep_by_interface(db.etl_db, interface_id) job_ids = [] out_ids = [] for items in ids: if items['job_id']: job_ids.append(items['job_id']) if items['out_id']: out_ids.append(items['out_id']) if set(out_ids) - set(job_ids): abort(400, **make_result(status=400, msg='接口中任务作为其他任务依赖, 请停止依赖任务后删除')) # 删除接口 InterfaceModel.delete_interface(db.etl_db, interface_id, user_id) return Response(interface_id=interface_id)
def delete_interface(interface_id, user_id): """删除任务流""" # 查询是否在调度内 if InterfaceModel.get_schedule_detail(db.etl_db, interface_id): abort(400, **make_result(status=400, msg='调度任务运行中, 请停止调度任务后删除')) # 任务流前后置依赖 parent = InterfaceModel.get_interface_parent(db.etl_db, interface_id) child = InterfaceModel.get_interface_child(db.etl_db, interface_id) if parent or child: abort(400, **make_result(status=400, msg='任务流存在前/后置依赖, 不可删除')) # # 查询是否有任务依赖 # ids = InterfaceModel.get_job_prep_by_interface(db.etl_db, interface_id) # job_ids = [] # out_ids = [] # for items in ids: # if items['job_id']: # job_ids.append(items['job_id']) # if items['out_id']: # out_ids.append(items['out_id']) # if set(out_ids) - set(job_ids): # abort(400, **make_result(status=400, msg='任务流中任务作为其他任务依赖, 请停止依赖任务后删除')) # 删除任务流 InterfaceModel.delete_interface(db.etl_db, interface_id, user_id) return Response(interface_id=interface_id)