加入webargs验证扩展,分区用于验证的inschema和用户序列化的outschema
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from .admin_user import UserSchema
|
||||
from .admin_role import RoleSchema
|
||||
from .admin_power import PowerSchema, PowerSchema2
|
||||
from .admin_dict import DictDataSchema, DictTypeSchema
|
||||
from .admin_dept import DeptSchema
|
||||
from .admin_log import LogSchema
|
||||
from .admin_photo import PhotoSchema
|
||||
from .admin_user import UserOutSchema
|
||||
from .admin_role import RoleOutSchema
|
||||
from .admin_power import PowerOutSchema, PowerOutSchema2
|
||||
from .admin_dict import DictDataOutSchema, DictTypeOutSchema
|
||||
from .admin_dept import DeptOutSchema
|
||||
from .admin_log import LogOutSchema
|
||||
from .admin_photo import PhotoOutSchema
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
from applications.extensions import ma
|
||||
from applications.extensions import ma
|
||||
from marshmallow import fields, validate
|
||||
|
||||
|
||||
class DeptSchema(ma.Schema):
|
||||
class DeptInSchema(ma.Schema):
|
||||
parentId = fields.Integer(required=True)
|
||||
deptName = fields.Str(required=True)
|
||||
leader = fields.Str(required=True)
|
||||
phone = fields.Str(required=True)
|
||||
email = fields.Str(validate=validate.Email())
|
||||
address = fields.Str()
|
||||
status = fields.Str(validate=validate.OneOf(["0", "1"]))
|
||||
sort = fields.Integer()
|
||||
|
||||
|
||||
class DeptOutSchema(ma.Schema):
|
||||
deptId = fields.Integer(attribute="id")
|
||||
parentId = fields.Integer(attribute="parent_id")
|
||||
deptName = fields.Str(attribute="dept_name")
|
||||
|
||||
@@ -2,7 +2,7 @@ from applications.extensions import ma
|
||||
from marshmallow import fields
|
||||
|
||||
|
||||
class DictTypeSchema(ma.Schema):
|
||||
class DictTypeOutSchema(ma.Schema):
|
||||
id = fields.Str(attribute="id")
|
||||
typeName = fields.Str(attribute="type_name")
|
||||
typeCode = fields.Str(attribute="type_code")
|
||||
@@ -13,7 +13,7 @@ class DictTypeSchema(ma.Schema):
|
||||
enable = fields.Str()
|
||||
|
||||
|
||||
class DictDataSchema(ma.Schema):
|
||||
class DictDataOutSchema(ma.Schema):
|
||||
dataId = fields.Str(attribute="id")
|
||||
dataLabel = fields.Str(attribute="data_label")
|
||||
dataValue = fields.Str(attribute="data_value")
|
||||
|
||||
@@ -2,7 +2,7 @@ from applications.extensions import ma
|
||||
from marshmallow import fields
|
||||
|
||||
|
||||
class LogSchema(ma.Schema):
|
||||
class LogOutSchema(ma.Schema):
|
||||
id = fields.Integer()
|
||||
method = fields.Str()
|
||||
uid = fields.Str()
|
||||
|
||||
@@ -2,7 +2,7 @@ from applications.extensions import ma
|
||||
from marshmallow import fields
|
||||
|
||||
|
||||
class PhotoSchema(ma.Schema):
|
||||
class PhotoOutSchema(ma.Schema):
|
||||
id = fields.Integer()
|
||||
name = fields.Str()
|
||||
href = fields.Str()
|
||||
|
||||
@@ -3,7 +3,7 @@ from marshmallow import fields
|
||||
|
||||
|
||||
# 权限models序列化类
|
||||
class PowerSchema(ma.Schema):
|
||||
class PowerOutSchema(ma.Schema):
|
||||
id = fields.Integer()
|
||||
title = fields.Str(attribute="name")
|
||||
type = fields.Str()
|
||||
@@ -18,7 +18,7 @@ class PowerSchema(ma.Schema):
|
||||
enable = fields.Integer()
|
||||
|
||||
|
||||
class PowerSchema2(ma.Schema): # 序列化类
|
||||
class PowerOutSchema2(ma.Schema): # 序列化类
|
||||
powerId = fields.Str(attribute="id")
|
||||
powerName = fields.Str(attribute="name")
|
||||
powerType = fields.Str(attribute="type")
|
||||
|
||||
@@ -2,7 +2,7 @@ from applications.extensions import ma
|
||||
from marshmallow import fields
|
||||
|
||||
|
||||
class RoleSchema(ma.Schema):
|
||||
class RoleOutSchema(ma.Schema):
|
||||
id = fields.Integer()
|
||||
roleName = fields.Str(attribute="name")
|
||||
roleCode = fields.Str(attribute="code")
|
||||
|
||||
@@ -4,7 +4,7 @@ from applications.models import Dept
|
||||
|
||||
|
||||
# 用户models的序列化类
|
||||
class UserSchema(ma.Schema):
|
||||
class UserOutSchema(ma.Schema):
|
||||
id = fields.Integer()
|
||||
username = fields.Str()
|
||||
realname = fields.Str()
|
||||
|
||||
Reference in New Issue
Block a user