Esempio n. 1
0
 def update_interface_detail(interface_id, interface_name, interface_desc,
                             retry, user_id, is_deleted):
     """修改接口详情"""
     InterfaceModel.update_interface_detail(db.etl_db, interface_id,
                                            interface_name, interface_desc,
                                            retry, user_id, is_deleted)
     return Response(interface_id=interface_id)
Esempio n. 2
0
 def update_interface_detail(interface_id, interface_name, interface_desc,
                             interface_index, old_parent, parent_interface,
                             run_time, retry, user_id, is_deleted):
     """修改任务流详情"""
     # 任务流名称查重
     interface_detail = InterfaceModel.get_interface_detail_by_name(
         db.etl_db, interface_name)
     if interface_detail and interface_detail[
             'interface_id'] != interface_id:
         abort(400, **make_result(status=400, msg='任务流名称重复, 已存在数据库中'))
     # 调度查重
     if is_deleted == 1:
         if InterfaceModel.get_schedule_detail(db.etl_db, interface_id):
             abort(400, **make_result(status=400, msg='任务流在调度任务中, 不能设置失效'))
     # 修改任务流
     if not run_time:
         run_time = (date.today() + timedelta(days=-1)).strftime('%Y-%m-%d')
     InterfaceModel.update_interface_detail(db.etl_db, interface_id,
                                            interface_name, interface_desc,
                                            interface_index, run_time,
                                            retry, user_id, is_deleted)
     # 修改任务流前置
     old_parent = set() if not old_parent else set(old_parent)
     parent_interface = set() if not parent_interface else set(
         parent_interface)
     # 删
     del_data = []
     for parent_id in old_parent - parent_interface:
         del_data.append({
             'interface_id': interface_id,
             'parent_id': parent_id,
             'user_id': user_id,
             'update_time': int(time.time())
         })
     InterfaceModel.delete_job_parent(db.etl_db,
                                      del_data) if del_data else None
     # 增
     add_data = []
     for parent_id in parent_interface - old_parent:
         add_data.append({
             'interface_id': interface_id,
             'parent_id': parent_id,
             'user_id': user_id,
             'insert_time': int(time.time()),
             'update_time': int(time.time())
         })
     InterfaceModel.add_job_parent(db.etl_db,
                                   add_data) if add_data else None
     return Response(interface_id=interface_id)