Exemplo n.º 1
0
def api_v1_save():
    # post请求
    data = request.get_json()
    # 参数校验
    if 'mock' not in data or not data['mock']:
        return jsonify({
            'status': 400,
            'message': 'invalid parameters mock',
            'data': data
        })

    if 'snippet' not in data or not data['snippet']:
        return jsonify({
            'status': 400,
            'message': 'invalid parameters snippet',
            'data': data
        })

    # 业务逻辑处理
    try:
        service = Service()
        data = service.save(data)
        print(data)
        return jsonify({'status': 0, 'message': 'ok', 'data': data})
    except Exception as e:
        return jsonify({'status': 500, 'message': str(e), 'data': data})
Exemplo n.º 2
0
def api_v1_search():
    data = request.values.to_dict()
    # 参数校验
    if 'type' not in data or not data['type']:
        return jsonify({
            'status': 400,
            'message': 'invalid parameters type',
            'data': data
        })

    # if 'team' not in data or not data['team']:
    #     return jsonify({
    #         'status':400,
    #         'message':'invalid parameters team',
    #         'data':data
    #     })

    # 业务逻辑处理
    try:
        service = Service()
        data = service.search(data)
        print(data)
        return jsonify({'status': 0, 'message': 'ok', 'data': data})
    except Exception as e:
        return jsonify({'status': 500, 'message': str(e), 'data': data})
Exemplo n.º 3
0
def api_v1_update():
    # post请求
    data = request.get_json()
    # 参数校验
    if 'id' not in data or not data['id']:
        return jsonify({
            'status': 400,
            'message': 'invalid parameters _id',
            'data': data
        })
    if 'type' not in data or not data['type']:
        return jsonify({
            'status': 400,
            'message': 'invalid parameters type',
            'data': data
        })

    if 'team' not in data or not data['team']:
        return jsonify({
            'status': 400,
            'message': 'invalid parameters key',
            'data': data
        })
    if 'project' not in data or not data['project']:
        return jsonify({
            'status': 400,
            'message': 'invalid parameters key',
            'data': data
        })
    if 'name' not in data or not data['name']:
        return jsonify({
            'status': 400,
            'message': 'invalid parameters name',
            'data': data
        })
    if 'value' not in data or not data['value']:
        return jsonify({
            'status': 400,
            'message': 'invalid parameters value',
            'data': data
        })

    # 业务逻辑处理
    try:
        service = Service()
        data = service.update(data)
        print(data)
        return jsonify({'status': 0, 'message': 'ok', 'data': data})
    except Exception as e:
        return jsonify({'status': 500, 'message': str(e), 'data': data})
Exemplo n.º 4
0
def api_v1_save():
    # 获取数据
    data = request.get_json()
    # 参数校验
    if 'mock' not in data or not data['mock']:
        return jsonify({
            'status': 400,
            'message': 'invalid  mock parameter',
            'data': data
        })

    if 'snippet' not in data or not data['snippet']:
        return jsonify({
            'status': 400,
            'message': 'invalid snippet parameter',
            'data': data
        })

        # 给前端返回数据
    try:
        # 逻辑处理:查询数据库
        data = Service().save(data)
        return jsonify({'status': 0, 'message': 'ok', 'data': data})
    except Exception as e:
        return jsonify({'status': 0, 'message': e, 'data': data})
Exemplo n.º 5
0
def api_v1_aggregate():
    # 获取参数
    data = request.get_json()
    # 参数校验

    if 'type' not in data or not data['type']:
        return jsonify({
            'status': 400,
            'message': 'invalid type parameter',
            'data': data
        })
    if 'key' not in data or not data['key']:
        return jsonify({
            'status': 400,
            'message': 'invalid key parameter',
            'data': data
        })

    # 给前端返回数据
    try:
        # 逻辑处理:查询数据库
        data = Service().aggregate(data)
        return jsonify({'status': 0, 'message': 'ok', 'data': data})
    except Exception as e:
        return jsonify({'status': 0, 'message': e, 'data': data})
Exemplo n.º 6
0
def api_v1_delete():
    # 获取参数
    data = request.get_json()
    print('data的数据是', data)
    # 参数校验
    if 'id_list' not in data or not data['id_list']:
        return jsonify({
            'status': 400,
            'message': 'invalid id_list parameter',
            'data': data
        })

    if 'type' not in data or not data['type']:
        return jsonify({
            'status': 400,
            'message': 'invalid type parameter',
            'data': data
        })

    # 给前端返回数据
    try:
        # 逻辑处理:查询数据库
        data = Service().delete(data)
        return jsonify({'status': 0, 'message': 'ok', 'data': data})
    except Exception as e:
        return jsonify({'status': 0, 'message': e, 'data': data})
Exemplo n.º 7
0
def api_v1_delete():
    # post请求
    data = request.get_json()
    # 参数校验
    if 'id_list' not in data or not data['id_list']:
        return jsonify({
            'status': 400,
            'message': 'invalid parameters type',
            'data': data
        })

    # 业务逻辑处理
    try:
        service = Service()
        data = service.delete(data)
        print(data)
        return jsonify({'status': 0, 'message': 'ok', 'data': data})
    except Exception as e:
        return jsonify({'status': 0, 'message': str(e), 'data': data})
Exemplo n.º 8
0
def api_v1_aggregate():
    # post请求
    data = request.get_json()
    # 参数校验
    if 'type' not in data or not data['type']:
        return jsonify({
            'status': 400,
            'message': 'invalid parameters type',
            'data': data
        })

    if 'key' not in data or not data['key']:
        return jsonify({
            'status': 400,
            'message': 'invalid parameters key',
            'data': data
        })

    # 业务逻辑处理
    service = Service()
    data = service.aggregate(data)
    print(data)
    return jsonify({'status': 0, 'message': 'ok', 'data': data})
Exemplo n.º 9
0
def api_v1_update():
    # 获取参数
    data = request.get_json()
    # 参数校验
    if '_id' not in data or not data['_id']:
        return jsonify({
            'status': 400,
            'message': 'invalid _id parameter',
            'data': data
        })

    if 'type' not in data or not data['type']:
        return jsonify({
            'status': 400,
            'message': 'invalid type parameter',
            'data': data
        })
    if 'team' not in data or not data['team']:
        return jsonify({
            'status': 400,
            'message': 'invalid team parameter',
            'data': data
        })
    if 'project' not in data or not data['project']:
        return jsonify({
            'status': 400,
            'message': 'invalid project parameter',
            'data': data
        })
    if 'name' not in data or not data['name']:
        return jsonify({
            'status': 400,
            'message': 'invalid name parameter',
            'data': data
        })
    if 'value' not in data or not data['value']:
        return jsonify({
            'status': 400,
            'message': 'invalid value parameter',
            'data': data
        })

    # 给前端返回数据
    try:
        # 逻辑处理:查询数据库
        data = Service().update(data)
        return jsonify({'status': 0, 'message': 'ok', 'data': data})
    except Exception as e:
        return jsonify({'status': 0, 'message': e, 'data': data})
Exemplo n.º 10
0
def api_v1_search():
    # 获取参数
    data = request.values.to_dict()
    #参数校验

    if 'type' not in data or not data['type']:
        return jsonify({
            'status': 400,
            'message': 'invalid type parameter',
            'data': data
        })

    # 给前端返回数据
    try:
        # 逻辑处理:查询数据库
        data = Service().search(data)
        return jsonify({'status': 0, 'message': 'ok', 'data': data})
    except Exception as e:
        return jsonify({'status': 0, 'message': e, 'data': data})
Exemplo n.º 11
0
def api_v1_save():
    data = request.get_json()
    service = Service()
    return service.keyword_save(data)
Exemplo n.º 12
0
import json
import re
from flask import Blueprint, jsonify, request, render_template
from variable.service import Service

variable = Blueprint('variable',
                     __name__,
                     static_folder='variable_static',
                     template_folder='variable_templates')
service = Service()


@variable.route('/')
def index():
    return render_template('variable.html')


@variable.route('/keyword')
def keyword():
    return render_template('keyword.html')


@variable.route('/api/v1/debug', methods=['POST'])
def api_v1_debug():
    data = request.get_json()
    service = Service()
    return service.keyword_debug(data)


@variable.route('/api/v1/save', methods=['POST'])
def api_v1_save():