()
return jsonify({'data': end_data, 'total': total, 'status': 1})
查找任务信息
查找任务信息
查找任务信息
def find_task():
    """ 查找任务信息 """
    data = request.json
    project_id = data.get('projectId')
    task_name = data.get('taskName')
    page = data.get('page') if data.get('page') else 1
    per_page = data.get('sizePage') if data.get('sizePage') else 10

    # CaseSet.get_all(project_id=project_id)
    # set_list = []
    # # 获取每个项目下的用例集
    # set_list[p.id] = [{'label': s.name, 'id': s.id} for s in p.case_sets]
    # scene_list= []
    # # 获取每个用例集的用例
    # for s in p.case_sets:
    #     scene_list["{}".format(s.id)] = [{'label': scene.name, 'id': scene.id} for scene in
    #                                      Case.get_all(case_set_id=s.id)]

    if task_name:
        _data = Task.query.filter_by(project_id=project_id).filter(Task.task_name.like('%{}%'.format(task_name)))
        if not _data:
            return jsonify({'msg': '没有该任务', 'status': 0})
    else:
        _data = Task.query.filter_by(project_id=project_id)
    pagination = _data.order_by(Task.id.asc()).paginate(page, per_page=per_page, error_out=False)
    items = pagination.items
    total = pagination.total
    end_data = [{'task_name': c.task_name, 'task_config_time': c.task_config_time,
                 'id': c.id, 'task_type': c.task_type, 'status': c.status} for c in items]
    return jsonify({'data': end_data, 'total': total, 'status': 1})
def find_task ( ) : data = request . json project_id = data . get ( 'projectId' ) task_name = data . get ( 'taskName' ) page = data . get ( 'page' ) if data . get ( 'page' ) else 1 per_page = data . get ( 'sizePage' ) if data . get ( 'sizePage' ) else 10 # CaseSet.get_all(project_id=project_id) # set_list = [] # # 获取每个项目下的用例集 # set_list[p.id] = [{'label': s.name, 'id': s.id} for s in p.case_sets] # scene_list= [] # # 获取每个用例集的用例 # for s in p.case_sets: #     scene_list["{}".format(s.id)] = [{'label': scene.name, 'id': scene.id} for scene in #                                      Case.get_all(case_set_id=s.id)] if task_name : _data = Task . query . filter_by ( project_id = project_id ) . filter ( Task . task_name . like ( '%{}%' . format ( task_name ) ) ) if not _data : return jsonify ( { 'msg' : '没有该任务', 'status' : 0}) else : _data = Task . query . filter_by ( project_id = project_id ) pagination = _data . order_by ( Task . id . asc ( ) ) . paginate ( page , per_page = per_page , error_out = False ) items = pagination . items total = pagination . total end_data = [ { 'task_name' : c . task_name , 'task_config_time' : c . task_config_time , 'id' : c . id , 'task_type' : c . task_type , 'status' : c . status } for c in items ] return jsonify ( { 'data' : end_data , 'total' : total , 'status' : 1 } )