Ejemplo n.º 1
0
def project_deluser(*args, **kwargs):
    project_id = request.json.get("project_id")
    user_id = request.json.get("user_id")
    try:
        pro_user = ProjectUser(project_id=project_id, user_id=user_id)
        db_session.add(pro_user)
        db_session.commit()
        return make_response(jsonify({'code': 200, 'msg': u'删除项目用户成功!'}))
    except Exception as e:
        return make_response(jsonify({'code': 401, 'error_msg': u'删除项目用户失败!'}))
Ejemplo n.º 2
0
def api_delete(*args,**kwargs):

    api_id = request.json.get('api_id')  # 接口描述
    try:
        api = db_session.query(Api).filter_by(id=api_id).one()
        db_session.delete(api)
        db_session.commit()
        return make_response(jsonify({"code":200,"msg": u'删除接口成功'}))
    except Exception as e:
        return make_response(jsonify({"code":404,"error_msg": u'新增接口失败'}))
Ejemplo n.º 3
0
def script_adduser(*args,**kwargs):
    user_id = request.json.get('user_id')
    script_id = request.json.get('script_id')
    try:
        userscript = UserScript(user_id=user_id,script_id=script_id)
        db_session.add(userscript)
        db_session.commit()
        return make_response(jsonify({"code": 200, "msg": u'添加用户成功'}))
    except Exception as e:
        return make_response(jsonify({"code": 404, "msg": e}))
Ejemplo n.º 4
0
def project_del(*args, **kwargs):
    # 判断是否还有挂接的接口
    project = request.json.get("project_name")
    version = request.json.get("project_version")
    try:
        pro = Project(project=project, version=version)
        db_session.delete(pro)
        db_session.commit()
        return make_response(jsonify({'code': 200, 'msg': u'删除项目成功!'}))
    except Exception:
        return make_response(jsonify({'code': 401, 'error_msg': u'删除项目失败!'}))
Ejemplo n.º 5
0
def results_delete(*args, **kwargs):
    results_id = request.json.get("results_id")  # 有可能报错这里
    try:
        result = db_session.query(Results).filter(
            Results.id.in_(results_id)).all()
        db_session.delete(result)
        db_session.commit()
        return make_response(jsonify({"code": 200, "msg": u'删除成功'}))
    except Exception as e:
        print('results_delete接口有可能results_id参数格式错误')
        return make_response(jsonify({"code": 404, "error_msg": u'删除失败'}))
Ejemplo n.º 6
0
def script_delete(*args,**kwargs):
    user_id = request.json.get('user_id')
    script_id = request.json.get('script_id')
    try:
        script = db_session.query(UserScript).filter_by(user_id=user_id).filter_by(script_id=script_id).one()

        if script.id is not None:
            db_session.query(Script).filter_by(script_id=script_id).delete()
            db_session.commit()
            return make_response(jsonify({"code": 200, "msg": u'脚本删除成功'}))

    except Exception as e:
        return make_response(jsonify({"code": 404, "msg": e}))
Ejemplo n.º 7
0
def api_add(*args,**kwargs):

    project_name = request.json.get("project_name")
    module_sub = request.json.get("module_sub")
    api_description = request.json.get("api_description")  # 接口描述
    try:
        project = db_session.query(Project).filter_by(project=project_name).one()
        api = Api(project_id=project.id,module_sub=module_sub,api_description=api_description)
        db_session.add(api)
        db_session.commit()
        return make_response(jsonify({"code":200,"msg": u'新增接口成功'}))
    except Exception as e:
        return make_response(jsonify({"code":404,"error_msg": u'新增接口失败'}))
Ejemplo n.º 8
0
def project_add(*args, **kwargs):
    # 用户自己添加脚本或者,
    # 前端校验必输项
    project = request.json.get("project_name")
    version = request.json.get("project_version")
    try:
        pro = Project(project=project, version=version)
        db_session.add(pro)
        # db_session.rollback()
        db_session.commit()
        return make_response(jsonify({'code': 200, 'msg': u'添加项目成功!'}))
    except Exception as e:
        print(e)
        return make_response(jsonify({'code': 401, 'msg': u'添加项目失败!'}))
Ejemplo n.º 9
0
def api_upgrade(*args,**kwargs):
    api_id = request.json.get('api_id')  # 接口描述
    # project_name = request.json.get("project_name")
    module_sub = request.json.get("module_sub")
    api_description = request.json.get("api_description")
    try:
        db_session.query(Api).filter_by(id=api_id).upgrade(module_sub=module_sub,
                                                                 api_description=api_description)

        db_session.commit()

        return make_response(jsonify({"code":200,"msg": u'修改接口成功'}))
    except Exception as e:
        return make_response(jsonify({"code":404,"error_msg": u'新增接口失败'}))
Ejemplo n.º 10
0
def project_update(*args, **kwargs):
    # 判断是否还有挂接的接口
    project_id = request.json.get("project_id")
    project = request.json.get("project_name")

    version = request.json.get("project_version")
    try:

        db_session.query(Project).filter_by(id=project_id).update(
            project=project, version=version)
        db_session.commit()

        return make_response(jsonify({'code': 200, 'msg': u'删除项目成功!'}))
    except Exception:
        return make_response(jsonify({'code': 401, 'error_msg': u'删除项目失败!'}))
Ejemplo n.º 11
0
def script_upgrade(*args,**kwargs):
    user_id = request.json.get('user_id')
    script_id = request.json.get('script_id')
    script_content = request.json.get('script_content')
    description = request.json.get('script_description')
    try:
        script = db_session.query(UserScript).filter_by(user_id=user_id).filter_by(script_id=script_id).one()

        if script.id is not None:
            db_session.query(Script).filter_by(script_id=script_id).update(script_content=script_content,description=description)
            db_session.commit()
            return make_response(jsonify({"code": 200, "msg": u'脚本更新成功'}))

    except Exception as e:
        return make_response(jsonify({"code": 404, "msg": e}))
Ejemplo n.º 12
0
def script_add(*args,**kwargs):
    # 用户自己添加脚本或者,
    username = request.json.get('username')
    api_description = request.json.get('api_description')
    try:
        user = db_session.query(User).filter_by(username=username).one()
        user_id = user.id
        api = db_session.query(Api).filter_by(api_description=api_description).one()
        api_id = api.id
        api_user = db_session.query(ApiUser).filter_by(user_id=user_id,api_id=api_id).one()
        api_user_id = api_user.id
    except Exception as e:
        return make_response(jsonify({"code": 404,"error_msg":e}))
    script_content = request.json.get('script_content')
    description = request.json.get('script_description')
    try:
        script = Script(api_user_id=api_user_id,script_content=script_content,description=description)
        db_session.add(script)
        db_session.commit()
        return make_response(jsonify({"code": 200,"msg": u'脚本添加成功'}))
    except Exception as e:
        return make_response(jsonify({"code": 404, "error_msg": e}))