mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: user init & refactors
This commit is contained in:
parent
b4dcc14749
commit
a50fc67104
25 changed files with 356 additions and 358 deletions
30
apps/api/src/db/roles.py
Normal file
30
apps/api/src/db/roles.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from enum import Enum
|
||||
from typing import Optional
|
||||
from sqlalchemy import JSON, Column
|
||||
from sqlmodel import Field, SQLModel
|
||||
|
||||
|
||||
class RoleTypeEnum(str, Enum):
|
||||
ORGANIZATION = "ORGANIZATION"
|
||||
ORGANIZATION_API_TOKEN = "ORGANIZATION_API_TOKEN"
|
||||
GLOBAL = "GLOBAL"
|
||||
|
||||
|
||||
class RoleBase(SQLModel):
|
||||
name: str
|
||||
description: Optional[str] = ""
|
||||
rights: dict = Field(default={}, sa_column=Column(JSON))
|
||||
|
||||
|
||||
class Role(RoleBase, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
org_id: int = Field(default=None, foreign_key="organization.id")
|
||||
role_type: RoleTypeEnum = RoleTypeEnum.GLOBAL
|
||||
role_uuid: str
|
||||
creation_date: str
|
||||
update_date: str
|
||||
|
||||
|
||||
class RoleCreate(RoleBase):
|
||||
org_id: int = Field(default=None, foreign_key="organization.id")
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue