下面是属性视图的视图功能,我想给这个添加分页。
类属性视图(资源):
def get(self):
try:
data = request.json
verifyJwt= request.headers.get('Authorization')
token = jwt.decode(verifyJwt,"secret",algorithm="HS256")
print(token.get('email'))
data = request.json
user_email= User.query.filter_by(email=token.get('email')).first()
print(user_email,"TEST")
if user_email != "null" :
property_data = Property.query.order_by(Property.id.desc()).all()
property_list = []
for property_obj in property_data:
property_list.append({'id': property_obj.id, 'address': property_obj.address, "latitude": property_obj.latitude, "longitude":property_obj.longitude, "cdr_date": property_obj.cdr_date, "building_grossfloor_area": property_obj.building_grossfloor_area, "multi_family": property_obj.multi_family, "artist_studios": property_obj.artist_studios, "max_building_height": property_obj.max_building_height, "stories": property_obj.stories, "retail_commercial_sf": property_obj.retail_commercial_sf, "parking_spaces": property_obj.parking_spaces, "bike_spaces": property_obj.bike_spaces, "architect": property_obj.architect, "developer": property_obj.developer, "site_area": property_obj.site_area, "picture_1": property_obj.picture_1, "picture_2": property_obj.picture_2, "original_name": property_obj.original_name})
response_data = property_list
return ResponseGenerator(data=response_data,
status=status.HTTP_201_CREATED).make_success_response()
except Exception as e:
logger.exception(e)
return ResponseGenerator(message='Exception: {}'.format(e),
status=status.HTTP_400_BAD_REQUEST).make_error_response()