加入webargs验证扩展,分区用于验证的inschema和用户序列化的outschema
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user