from pydantic import BaseModel, Field
from typing import Optional


# 用户相关的原型
class SysUserIn(BaseModel):
    username: Optional[str] = Field(..., description="用户名", max_length=50)
    password: Optional[str] = Field(..., description="密码", max_length=30, min_length=6)
    login_name: Optional[str] = Field(None, description="昵称", max_length=20)


class SysUserLogin(BaseModel):
    username: Optional[str] = Field(..., description="用户名", max_length=50)
    password: Optional[str] = Field(..., description="密码", max_length=30, min_length=6)


class SysUserOut(BaseModel):
    id: Optional[int] = Field(..., description="id")
    username: Optional[str] = Field(..., description="用户名")
    login_name: Optional[str] = Field(None, description="昵称")
    user_status: Optional[str] = Field(None, description="用户状态")

    class Config:
        orm_mode = True


class SysUserUpdatePw(BaseModel):
    id: Optional[int] = Field(..., description="id")
    new_password: Optional[str] = Field(..., description="新密码", max_length=30, min_length=8)
    original_password: Optional[str] = Field(..., description="旧密码", max_length=30, min_length=8)


class SysUserPager(BaseModel):
    username: Optional[str] = Field(None, description="用户名")
    login_name: Optional[str] = Field(None, description="昵称")
    pagerNum: Optional[int] = Field(1, description="当前页码")
    pagerSize: Optional[int] = Field(10, description="每页数量")

    class Config:
        orm_mode = True
