refactor(api):移除marshal序列化

This commit is contained in:
zhengxinonly
2021-12-07 20:24:07 +08:00
parent 9490ccb7c0
commit 820ab9f5c6
13 changed files with 282 additions and 172 deletions
-36
View File
@@ -1,5 +1,3 @@
from flask_restful import fields
from applications.extensions import db
from ..base import BaseModel
@@ -18,37 +16,3 @@ class RightsPower(db.Model, BaseModel):
enable = db.Column(db.Boolean, comment='是否开启')
parent = db.relationship("RightsPower", remote_side=[id]) # 自关联
@staticmethod
def fields():
return {
'powerId': fields.String(attribute="id"),
'powerName': fields.String(attribute="name"),
'powerType': fields.String(attribute="type"),
'powerUrl': fields.String(attribute="url"),
'openType': fields.String(attribute="open_type"),
'parentId': fields.String(attribute="parent_id"),
'icon': fields.String,
'sort': fields.Integer,
'create_at': fields.DateTime,
'update_at': fields.DateTime,
'enable': fields.Integer,
}
@staticmethod
def fields2():
return {
'id': fields.Integer,
'title': fields.String(attribute="name"),
'type': fields.String,
'code': fields.String,
'href': fields.String(attribute="url"),
'openType': fields.String(attribute="open_type"),
'parent_id': fields.Integer,
'icon': fields.String,
'sort': fields.Integer,
'enable': fields.Boolean,
'update_at': fields.DateTime,
'create_at': fields.DateTime,
}
-14
View File
@@ -15,17 +15,3 @@ class RightsRole(db.Model, BaseModel):
sort = db.Column(db.Integer, comment='排序')
power = db.relationship('RightsPower', secondary="rt_role_power", backref=db.backref('role'))
@staticmethod
def fields():
return {
'id': fields.Integer,
'roleName': fields.String(attribute="name"),
'roleCode': fields.String(attribute="code"),
'enable': fields.Boolean,
'comment': fields.String,
'details': fields.String,
'sort': fields.Integer,
'create_at': fields.DateTime,
'update_at': fields.DateTime,
}