源码见"fastapi_study_road-learning_system_online_courses: fastapi框架实战之--在线课程学习系统"
在前面我们分析了接口的设计,那么我们接下来做接口的开发。
首先,我们先设计下pydantic用户参数的校验:
"""
-*- encoding=utf-8 -*-
Time: 2024/7/19 16:48
Author: lc
Email: 15101006331@163.com
File: schemas.py
"""
from pydantic import BaseModel, Field
from typing import Optional
from common.constant import SexEnum, RoleEnum
class UserBase(BaseModel):
username: str = Field(min_length=8, max_length=16)
class UserCreate(UserBase):
"""请求验证模型"""
password: str = Field(min_length=8, max_length=16)
role: RoleEnum
job_num: Optional[str] = Field(None, min_length=8, max_length=8)
student_num: Optio

最低0.47元/天 解锁文章
1444

被折叠的 条评论
为什么被折叠?



