序列化类移到models里,简化代码
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user