class AddAdminParse(BaseMarshmallow): username = fields.String(validate=[validate.str_range(6, 16)], required=True) password = fields.String(validate=[validate.str_range(8, 16)], required=True) password_ = fields.String(validate=[validate.str_range(8, 16)], required=True) nickname = fields.String(validate=[validate.str_range(0, 32)], missing="admin") remark = fields.String(validate=[validate.str_range(0, 255)]) image_id = fields.Integer(validate=[validate.image_exist])
class UserRegisterParse(BaseMarshmallow): email = fields.Email(validate=[validate.str_range(0, 128)], required=True) password = fields.String(validate=[validate.str_range(8, 16)], required=True) password_ = fields.String(validate=[validate.str_range(8, 16)], required=True) code = fields.String(validate=[validate.str_range(6, 6)], required=True)
class AddDownloadParse(BaseMarshmallow): title = fields.String(validate=[validate.str_range(0, 128)], required=True) description = fields.String() version = fields.String(validate=[validate.str_range(0, 64)]) language = fields.String(validate=[validate.str_range(0, 128)]) file_id = fields.Integer(validate=[validate.data_exist(Upload)], required=True) category_id = fields.Integer( validate=[validate.category_exist("download")], required=True) cover_id = fields.Integer(validate=[validate.image_exist], required=True)
class AddArticleParse(BaseMarshmallow): title = fields.String(validate=[validate.str_range(1, 255)], required=True) content = fields.String() recom = fields.Boolean(missing=False) top = fields.Boolean(missing=False) published = fields.Boolean(missing=True) publish_date = fields.DateTime('%Y-%m-%d %H:%M') description = fields.String() cover_id = fields.Integer(validate=[validate.image_exist], required=True) category_id = fields.Integer(validate=[validate.category_exist("article")], required=True) tag_id = fields.List(fields.Integer(validate=[validate.data_exist(Tag)]))
class AddAlbumParse(BaseMarshmallow): title = fields.String(validate=[validate.str_range(0, 128)], required=True) description = fields.String() category_id = fields.Integer(validate=[validate.category_exist("picture")], required=True) cover_id = fields.Integer(validate=[validate.image_exist], required=True)
class AddTagParse(BaseMarshmallow): name = fields.String(validate=[validate.str_range(0, 128)], required=True) sort = fields.Integer(validate=[validate.positive], missing=20)
class AdminLoginParse(BaseMarshmallow): username = fields.String(validate=[validate.str_range(6, 16)], required=True) password = fields.String(validate=[validate.str_range(8, 16)], required=True)
class UpdateAdminInfoParse(BaseMarshmallow): password = fields.String(validate=[validate.str_range(8, 16)]) password_ = fields.String(validate=[validate.str_range(8, 16)]) nickname = fields.String(validate=[validate.str_range(0, 32)], missing="admin") remark = fields.String(validate=[validate.str_range(0, 255)]) image_id = fields.Integer(validate=[validate.image_exist])
class UserLoginParse(BaseMarshmallow): username = fields.Email(validate=[validate.str_range(0, 128)], required=True) password = fields.String(validate=[validate.str_range(8, 16)], required=True)
class UserModifyPasswordParse(BaseMarshmallow): password = fields.String(validate=[validate.str_range(8, 16)], required=True) password_ = fields.String(validate=[validate.str_range(8, 16)], required=True) code = fields.String(validate=[validate.str_range(6, 6)], required=True)
class UpdateUserInfoParse(BaseMarshmallow): nickname = fields.String(validate=[validate.str_range(0, 32)]) description = fields.String(validate=[validate.str_range(0, 255)]) gender = fields.Integer(validate=[validate.choice([0, 1, 2])], missing=0) image_id = fields.Integer(validate=[validate.image_exist])
class SendEmailCodeParse(BaseMarshmallow): email = fields.Email(validate=[validate.str_range(0, 128)], required=True)
class UpdateCategoryParse(BaseMarshmallow): title = fields.String(validate=[validate.str_range(1, 128)], required=True) sort = fields.Integer(missing=20) upper_id = fields.Integer(validate=[validate.category_exist(level=1)])
class AddCategoryParse(BaseMarshmallow): title = fields.String(validate=[validate.str_range(1, 128)], required=True) sort = fields.Integer(missing=20) module = fields.String(validate=[validate.choice(array=Category.MODULE_TYPE.keys())]) upper_id = fields.Integer(validate=[validate.category_exist(level=1)])