()
return jsonify({'data': end_data, 'total': total, 'status': 1})
查找用例
查找用例
查找用例
def find_case():
    """ 查找用例 """
    data = request.json
    project_id = data.get('projectId')
    case_name = data.get('caseName')
    set_id = data.get('setId')
    page = data.get('page') if data.get('page') else 1
    per_page = data.get('sizePage') if data.get('sizePage') else 10
    if not project_id:
        return jsonify({'msg': '请选择项目', 'status': 0})
    if case_name:
        _data = Case.query.filter_by(case_set_id=set_id).filter(Case.name.like('%{}%'.format(case_name)))
        if not _data:
            return jsonify({'msg': '没有该用例', 'status': 0})
    else:
        _data = Case.query.filter_by(case_set_id=set_id)

    pagination = _data.order_by(Case.num.asc()).paginate(page, per_page=per_page, error_out=False)
    items = pagination.items
    total = pagination.total
    end_data = [{'num': c.num, 'name': c.name, 'label': c.name, 'leaf': True, 'desc': c.desc, 'sceneId': c.id,
                 }
                for c in items]
    return jsonify({'data': end_data, 'total': total, 'status': 1})
def find_case ( ) : data = request . json project_id = data . get ( 'projectId' ) case_name = data . get ( 'caseName' ) set_id = data . get ( 'setId' ) page = data . get ( 'page' ) if data . get ( 'page' ) else 1 per_page = data . get ( 'sizePage' ) if data . get ( 'sizePage' ) else 10 if not project_id : return jsonify ( { 'msg' : '请选择项目', 'status' : 0}) if case_name : _data = Case . query . filter_by ( case_set_id = set_id ) . filter ( Case . name . like ( '%{}%' . format ( case_name ) ) ) if not _data : return jsonify ( { 'msg' : '没有该用例', 'status' : 0}) else : _data = Case . query . filter_by ( case_set_id = set_id ) pagination = _data . order_by ( Case . num . asc ( ) ) . paginate ( page , per_page = per_page , error_out = False ) items = pagination . items total = pagination . total end_data = [ { 'num' : c . num , 'name' : c . name , 'label' : c . name , 'leaf' : True , 'desc' : c . desc , 'sceneId' : c . id , } for c in items ] return jsonify ( { 'data' : end_data , 'total' : total , 'status' : 1 } )