()
return jsonify({'data': end_data, 'total': total, 'status': 1})
查找报告
查找报告
查找报告
def find_report():
    """ 查找报告 """
    data = request.json
    project_id = data.get('projectId')
    case_name = data.get('caseName')
    page = data.get('page') if data.get('page') else 1
    per_page = data.get('sizePage') if data.get('sizePage') else 10
    if case_name:
        _data = Report.query.filter_by(project_id=project_id).filter(Report.case_names.like('%{}%'.format(case_name)))
        if not _data:
            return jsonify({'msg': '没有该用例报告', 'status': 0})
    else:
        _data = Report.query.filter_by(project_id=project_id)
    pagination = _data.order_by(Report.create_time.desc()).paginate(page, per_page=per_page, error_out=False)
    items = pagination.items
    total = pagination.total
    end_data = [
        {'name': c.case_names, 'project_id': project_id, 'id': c.id, 'read_status': c.read_status, 'result': c.result,
         'performer': c.performer, 'project_name': Project.query.filter_by(id=project_id).first().name,
         'create_time': str(c.create_time).split('.')[0]} for c in items]

    return jsonify({'data': end_data, 'total': total, 'status': 1})
def find_report ( ) : data = request . json project_id = data . get ( 'projectId' ) case_name = data . get ( 'caseName' ) page = data . get ( 'page' ) if data . get ( 'page' ) else 1 per_page = data . get ( 'sizePage' ) if data . get ( 'sizePage' ) else 10 if case_name : _data = Report . query . filter_by ( project_id = project_id ) . filter ( Report . case_names . like ( '%{}%' . format ( case_name ) ) ) if not _data : return jsonify ( { 'msg' : '没有该用例报告', 'status': 0} ) else : _data = Report . query . filter_by ( project_id = project_id ) pagination = _data . order_by ( Report . create_time . desc ( ) ) . paginate ( page , per_page = per_page , error_out = False ) items = pagination . items total = pagination . total end_data = [ { 'name' : c . case_names , 'project_id' : project_id , 'id' : c . id , 'read_status' : c . read_status , 'result' : c . result , 'performer' : c . performer , 'project_name' : Project . query . filter_by ( id = project_id ) . first ( ) . name , 'create_time' : str ( c . create_time ) . split ( '.' ) [ 0 ] } for c in items ] return jsonify ( { 'data' : end_data , 'total' : total , 'status' : 1 } )