示例#1
0
class ManagerListPageNum(Resource):
    def __init__(self):
        self.dao = ManagerDAO()
        self.userDao = UserDAO()

    def post(self):
        if (request.data != ""):
            data = json.loads(request.data)
            token = data['token']
            user = self.userDao.verify_token(token, '')
            if (not user):
                return make_response(jsonify({'error': '用户不存在或登录过期', 'errorcode': 10000000}), 400)
            elif user == 1010301:
                return make_response(jsonify({'error': '登录过期', 'errorcode': user}), 400)
            elif user == 1010302:
                return make_response(jsonify({'error': '用户验证错误', 'errorcode': user}), 400)
            else:
                args = parser.parse_args()
                device_type=args.get('device_type')
                device_status=args.get('device_status')
                device_ver=args.get('device_ver')
                page_size = args.get('page_size')
                rs=self.dao.query_pages(user,device_type,device_ver,device_status,page_size)
                return rs
        else:
            return make_response(jsonify({'error': '输入参数有误', 'errorcode': 10000000}), 401)

    def get(self):
        return(self.post())
示例#2
0
class ManagerListPageNum(Resource):
    def __init__(self):
        self.dao = ManagerDAO()
        self.userDao = UserDAO()

    def post(self):
        if (request.data != ""):
            data = json.loads(request.data)
            token = data['token']
            page_size=data['page_size']
            user = self.userDao.verify_token(token, '')
            if (not user):
                 return make_response(jsonify({'error': 'Unauthorized access'}), 401)
            else:
                rs=self.dao.query_pages(user,page_size)
                return json.dumps(rs)
        else:
                return make_response(jsonify({'error': 'Unauthorized access'}), 401)

    def get(self):
        return(self.post())