序列化类移到models里,简化代码

This commit is contained in:
mkg
2021-04-29 13:09:10 +08:00
parent 8f4054e576
commit 3d5e4b9e9b
14 changed files with 123 additions and 157 deletions
+1 -15
View File
@@ -1,24 +1,10 @@
import os
from flask import current_app
from flask_marshmallow import Marshmallow
from marshmallow import fields
from sqlalchemy import desc
from applications.models import db
from applications.models.admin_photo import Photo
from applications.models.admin_photo import Photo, PhotoSchema
from applications.service.upload import photos
ma = Marshmallow()
class PhotoSchema(ma.Schema):
id = fields.Integer()
name = fields.Str()
href = fields.Str()
mime = fields.Str()
size = fields.Str()
ext = fields.Str()
create_time = fields.DateTime()
def get_photo(page, limit):
photo = Photo.query.order_by(desc(Photo.create_time)).paginate(page=page, per_page=limit, error_out=False)