Skip to content

Commit

Permalink
更新依赖,优化sqlmodel模型
Browse files Browse the repository at this point in the history
  • Loading branch information
amisadmin committed Dec 17, 2023
1 parent 324bff5 commit 66f33e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions fastapi_user_auth/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
class BaseUser(PkMixin, CUDTimeMixin, UsernameMixin, PasswordMixin, EmailMixin):
__tablename__ = "auth_user"
is_active: bool = Field(default=True, title=_("Is Active"))
nickname: str = Field("", title=_("Nickname"), max_length=40)
avatar: str = Field(
nickname: Optional[str] = Field("", title=_("Nickname"), max_length=40)
avatar: Optional[str] = Field(
"",
title=_("Avatar"),
max_length=255,
Expand Down
10 changes: 6 additions & 4 deletions fastapi_user_auth/mixins/models.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
from datetime import datetime
from typing import Optional

from fastapi_amis_admin.models.fields import Field
from fastapi_amis_admin.models import Field, SQLModel
from fastapi_amis_admin.utils.translation import i18n as _
from pydantic import EmailStr, SecretStr
from sqlalchemy import func
from sqlmodel import AutoString
from sqlmodelx import SQLModel

from fastapi_user_auth.utils.sqltypes import SecretStrType


class PkMixin(SQLModel):
id: Optional[int] = Field(default=None, title="ID", primary_key=True, nullable=False)
id: Optional[int] = Field(
default=None, title="ID", primary_key=True, nullable=False, sa_column_kwargs={"autoincrement": True}
)


class CreateTimeMixin(SQLModel):
create_time: datetime = Field(default_factory=datetime.now, title=_("Create Time"))
create_time: datetime = Field(default_factory=datetime.now, title=_("Create Time"), index=True)


class UpdateTimeMixin(SQLModel):
update_time: Optional[datetime] = Field(
default_factory=datetime.now,
title=_("Update Time"),
index=True,
sa_column_kwargs={"onupdate": func.now(), "server_default": func.now()},
)

Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ classifiers = [
"Programming Language :: Python :: 3.11",
]
dependencies = [
"fastapi-amis-admin>=0.6.0,<0.8.0",
"fastapi-amis-admin>=0.7.0a2,<0.8.0",
"email-validator>=1.3.1,<3.0.0",
"passlib>=1.7.4",
"bcrypt>=4.0.0",
"bcrypt>=4.0.0,<4.1.0",
"casbin>=1.29.0",
]

Expand All @@ -65,7 +65,7 @@ test = [
"pre-commit>=2.20.0",
"httpx>=0.23.3",
"pydantic-settings>=2.0.0",
"fastapi-amis-admin>=0.7.0a1",
"fastapi-amis-admin>=0.7.0a2",
]

# pytest
Expand Down

0 comments on commit 66f33e9

Please sign in to comment.