()
return jsonify({'status': 1, 'data': end_data, 'msg': 1})
查找函数文件
查找函数文件
查找函数文件
def find_func_file():
    """ 查找函数文件 """
    data = request.json
    privates = data.get('privates')

    kwargs = {'higher_id': 0}
    if privates:
        kwargs['user_id'] = current_user.id

    def get_data(all_data):
        if isinstance(all_data, list):
            if all_data:
                _t = []
                for d in all_data:
                    _t.append(get_data(d))
                return _t
            else:
                return []
        else:
            _d = {'id': all_data.id, 'num': all_data.num, 'name': all_data.name, 'status': all_data.status,
                  'higher_id': all_data.higher_id}
            if all_data.status == 0:
                kwargs['higher_id'] = all_data.id
                _d['children'] = get_data(
                    FuncFile.query.filter_by(**kwargs).order_by(FuncFile.num.asc()).all())
            return _d

    end_data = get_data(FuncFile.query.filter_by(**kwargs).order_by(FuncFile.num.asc()).all())

    return jsonify({'status': 1, 'data': end_data, 'msg': 1})
def find_func_file ( ) : data = request . json privates = data . get ( 'privates' ) kwargs = { 'higher_id' : 0 } if privates : kwargs [ 'user_id' ] = current_user . id def get_data ( all_data ) : if isinstance ( all_data , list ) : if all_data : _t = [ ] for d in all_data : _t . append ( get_data ( d ) ) return _t else : return [ ] else : _d = { 'id' : all_data . id , 'num' : all_data . num , 'name' : all_data . name , 'status' : all_data . status , 'higher_id' : all_data . higher_id } if all_data . status == 0 : kwargs [ 'higher_id' ] = all_data . id _d [ 'children' ] = get_data ( FuncFile . query . filter_by ( * * kwargs ) . order_by ( FuncFile . num . asc ( ) ) . all ( ) ) return _d end_data = get_data ( FuncFile . query . filter_by ( * * kwargs ) . order_by ( FuncFile . num . asc ( ) ) . all ( ) ) return jsonify ( { 'status' : 1 , 'data' : end_data , 'msg' : 1 } )