Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
后端:修改用户model
  • Loading branch information
4linuxfun committed Jan 4, 2024
commit f5c4c96f2e01dfc9bb0f5154fbb10972b08d82c9
14 changes: 4 additions & 10 deletions server/models/internal/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@


class UserWithOutPasswd(SQLModel):
name: str = Field(max_length=20, sa_column_kwargs={'unique': True, 'comment': '用户名'})
enable: bool = Field(default=True, sa_column=Column(Boolean, comment='可用'))
avatar: Optional[str] = Field(max_length=100, sa_column_kwargs={'comment': '头像'})
email: Optional[str] = Field(max_length=20, sa_column_kwargs={'comment': '邮箱'})
name: Union[str, None] = Field(max_length=20, default=None, sa_column_kwargs={'unique': True, 'comment': '用户名'})
enable: Union[bool, None] = Field(default=True, sa_column=Column(Boolean, comment='可用'))
avatar: Union[str, None] = Field(max_length=100, default=None, sa_column_kwargs={'comment': '头像'})
email: Union[str, None] = Field(max_length=20, default=None, sa_column_kwargs={'comment': '邮箱'})


class UserBase(UserWithOutPasswd):
Expand Down Expand Up @@ -70,9 +70,3 @@ class UserLogin(SQLModel):
class LoginResponse(SQLModel):
uid: int
token: str


class UserSearch(SQLModel):
name: Union[str, None]
enable: Union[int, None]
email: Union[str, None]
4 changes: 2 additions & 2 deletions server/routers/internal/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ...common.database import get_session
from ...models.internal import User, Role
from ...models.internal.user import UserCreateWithRoles, UserReadWithRoles, UserUpdateWithRoles, UserUpdatePassword, \
UserWithOutPasswd, UserSearch
UserWithOutPasswd
from ...schemas.internal.pagination import Pagination
from ... import crud

Expand Down Expand Up @@ -61,7 +61,7 @@ async def get_user_info(uid: int, session: Session = Depends(get_session)):


@router.post('/users/search', summary="获取用户列表")
async def get_all_user(search: Pagination[UserSearch],
async def get_all_user(search: Pagination[UserWithOutPasswd],
session: Session = Depends(get_session)):
"""
获取“用户管理”页面的用户列表清单
Expand Down