mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2025-08-26 04:33:09 +08:00

* Add tool to build tree structure data * Update to keyword parameter style * Add department-related interfaces * Update departmental section interface permissions * Add TODO and minor fixes * Fix department relationships * Fix user foreign key relationship deletion setting * Add path parameters to the operation log * Complete todo items * Update department deletion logic * Update operation log entry records * Add AES encryption algorithm * Add operation log request entry to the secret * Fix naming prefixes * Add easy encryption tools * FIX CASBIN_EXCLUDE typing * Update user password reset interface * Add confirm_password to the operation log encryption
57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field, validator
|
|
|
|
from backend.app.utils.re_verify import is_phone
|
|
|
|
|
|
class DeptBase(BaseModel):
|
|
name: str
|
|
parent_id: int | None = Field(default=None, ge=1, description='菜单父级ID')
|
|
sort: int = Field(default=0, ge=0, description='排序')
|
|
leader: str | None = None
|
|
phone: str | None = None
|
|
email: str | None = None
|
|
status: bool
|
|
|
|
@validator('phone')
|
|
def phone_validator(cls, v):
|
|
if v is not None and not v.isdigit():
|
|
if not is_phone(v):
|
|
raise ValueError('手机号码输入有误')
|
|
return v
|
|
|
|
@validator('email')
|
|
def email_validator(cls, v):
|
|
if v is not None:
|
|
from email_validator import validate_email, EmailNotValidError
|
|
|
|
try:
|
|
validate_email(v, check_deliverability=False).email
|
|
except EmailNotValidError:
|
|
raise ValueError('邮箱格式错误')
|
|
return v
|
|
|
|
|
|
class CreateDept(DeptBase):
|
|
pass
|
|
|
|
|
|
class UpdateDept(DeptBase):
|
|
pass
|
|
|
|
|
|
class GetAllDept(DeptBase):
|
|
id: int
|
|
level: int
|
|
del_flag: bool
|
|
create_user: int
|
|
update_user: int = None
|
|
created_time: datetime
|
|
updated_time: datetime | None = None
|
|
|
|
class Config:
|
|
orm_mode = True
|