-
Notifications
You must be signed in to change notification settings - Fork 693
Expand file tree
/
Copy pathuser.py
More file actions
40 lines (30 loc) · 1.45 KB
/
user.py
File metadata and controls
40 lines (30 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from typing import List, Optional
from sqlalchemy import Column, BigInteger
from sqlalchemy.dialects.postgresql import JSONB
from sqlmodel import SQLModel, Field
from common.core.models import SnowflakeBase
from common.core.security import default_md5_pwd
from common.utils.time import get_timestamp
class BaseUserPO(SQLModel):
account: str = Field(max_length=255, unique=True)
oid: int = Field(nullable=False, sa_type=BigInteger(), default=0)
name: str = Field(max_length=255, unique=True)
password: str = Field(default_factory=default_md5_pwd, max_length=255)
email: str = Field(max_length=255)
status: int = Field(default=0, nullable=False)
origin: int = Field(nullable=False, default=0)
create_time: int = Field(default_factory=get_timestamp, sa_type=BigInteger(), nullable=False)
language: str = Field(max_length=255, default="zh-CN")
#system_variables: List = Field(sa_column=Column(JSONB, nullable=True))
system_variables: Optional[List] = Field(
default=None,
sa_column=Column(JSONB, nullable=True)
)
class UserModel(SnowflakeBase, BaseUserPO, table=True):
__tablename__ = "sys_user"
class UserPlatformBase(SQLModel):
uid: int = Field(nullable=False, sa_type=BigInteger())
origin: int = Field(nullable=False, default=0)
platform_uid: str = Field(max_length=255, nullable=False)
class UserPlatformModel(SnowflakeBase, UserPlatformBase, table=True):
__tablename__ = "sys_user_platform"