删除curd层
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
from applications.extensions import db
|
||||
from applications.extensions import db, ma
|
||||
|
||||
|
||||
def model_to_dicts(Schema, model):
|
||||
def model_to_dicts(schema: ma.Schema, data):
|
||||
"""
|
||||
:param schema: schema类
|
||||
:param model: sqlalchemy查询结果
|
||||
:return: 返回单个查询结果
|
||||
"""
|
||||
# 如果是分页器返回,需要传入model.items
|
||||
common_schema = Schema(many=True) # 用已继承ma.ModelSchema类的自定制类生成序列化类
|
||||
output = common_schema.dump(model) # 生成可序列化对象
|
||||
common_schema = schema(many=True) # 用已继承ma.ModelSchema类的自定制类生成序列化类
|
||||
output = common_schema.dump(data) # 生成可序列化对象
|
||||
return output
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user