コード例 #1
0
class DataServiceDelete(Resource):
    def __init__(self):
        self.dao = DataServiceDao()
        self.userDao = UserDAO()

    def post(self):
        if (request.data != ""):
            data = json.loads(request.data)
            token = data['token']
            serviceid = data['serviceid']

            user = self.userDao.verify_token(token, '')
            if (not user):
                return make_response(jsonify({'error': '用户不存在或登录过期','errorcode':10000000}), 400)
            if user==1010301:
                return make_response(jsonify({'error': '登录过期','errorcode':user}), 400)
            if user==1010302:
                return make_response(jsonify({'error': '用户验证错误', 'errorcode': user}), 400)

            rs = self.dao.dataservice_delete(serviceid)
            if rs == None:
                return make_response(jsonify({'error': '删除服务失败','errorcode':10000000}), 401)
            else:
                return make_response(jsonify({'success': '删除服务成功'}), 200)
        else:
            return make_response(jsonify({'error': '没有登录,无权限删除服务', 'errorcode': 10000000}), 401)

    def get(self):
        return self.post()
コード例 #2
0
class DataServiceModify(Resource):
    def __init__(self):
        self.dao = DataServiceDao()
        self.userDao = UserDAO()

    def post(self):
        if (request.data != ""):
            data = json.loads(request.data)
            token = data['token']
            id=data['id']
            linename = data['linename']
            urlLink = data['url']
            type = data['type']
            dataservice = DataService()
            dataservice.tb_dataservice_linename=linename
            dataservice.tb_dataservice_url = urlLink
            dataservice.tb_dataservice_type=type

            user = self.userDao.verify_token(token, '')
            if (not user):
                return make_response(jsonify({'error': '用户不存在或登录过期','errorcode':10000000}), 400)
            if user==1010301:
                return make_response(jsonify({'error': '登录过期','errorcode':user}), 400)
            if user==1010302:
                return make_response(jsonify({'error': '用户验证错误', 'errorcode': user}), 400)


            rs=self.dao.dataservice_modify(id,linename,urlLink,type)
            if rs==None:
                return make_response(jsonify({'error': '添加服务失败','errorcode':10000000}), 401)
            else:
                return make_response(jsonify({'success': '添加服务成功'}), 200)
        else:
            return  make_response(jsonify({'error': '没有登录,无权限添加服务','errorcode':10000000}), 401)

    def get(self):
        return self.post()
コード例 #3
0
 def __init__(self):
     self.dao = DataServiceDao()
     self.userDao = UserDAO()