66 lines
2.1 KiB
Markdown
66 lines
2.1 KiB
Markdown
|
|
---
|
||
|
|
tags: []
|
||
|
|
date created: 星期日, 十二月 7日 2025, 1:31:36 下午
|
||
|
|
date modified: 星期日, 十二月 7日 2025, 1:32:46 下午
|
||
|
|
---
|
||
|
|
|
||
|
|
```mermaid
|
||
|
|
erDiagram
|
||
|
|
users ||--o{ user_roles : "assigns"
|
||
|
|
roles ||--o{ user_roles : "assigned to"
|
||
|
|
roles ||--o{ role_permissions : "grants"
|
||
|
|
permissions ||--o{ role_permissions : "granted to"
|
||
|
|
|
||
|
|
users {
|
||
|
|
bigint id PK "主键 (BigSerial)"
|
||
|
|
string username "用户名 (唯一)"
|
||
|
|
string password_hash "哈希密码 (Argon2/Bcrypt)"
|
||
|
|
string email "邮箱 (可选,唯一)"
|
||
|
|
string nickname "昵称"
|
||
|
|
string avatar_url "头像URL"
|
||
|
|
text bio "简介"
|
||
|
|
string status "状态 (active/inactive/banned)"
|
||
|
|
timestamptz created_at "创建时间"
|
||
|
|
timestamptz updated_at "更新时间"
|
||
|
|
timestamptz deleted_at "软删除时间"
|
||
|
|
}
|
||
|
|
|
||
|
|
roles {
|
||
|
|
bigint id PK "主键 (BigSerial)"
|
||
|
|
string code "角色代码 (admin/editor/user)"
|
||
|
|
string name "角色名称"
|
||
|
|
text description "角色描述"
|
||
|
|
boolean is_system "系统角色(不可删除)"
|
||
|
|
timestamptz created_at "创建时间"
|
||
|
|
timestamptz updated_at "更新时间"
|
||
|
|
timestamptz deleted_at "软删除时间"
|
||
|
|
}
|
||
|
|
|
||
|
|
permissions {
|
||
|
|
bigint id PK "主键 (BigSerial)"
|
||
|
|
string code "权限代码 (module:action:scope)"
|
||
|
|
string name "权限名称"
|
||
|
|
text description "权限描述"
|
||
|
|
string category "权限分类"
|
||
|
|
timestamptz created_at "创建时间"
|
||
|
|
timestamptz updated_at "更新时间"
|
||
|
|
timestamptz deleted_at "软删除时间"
|
||
|
|
}
|
||
|
|
|
||
|
|
user_roles {
|
||
|
|
bigint id PK "主键 (BigSerial)"
|
||
|
|
bigint user_id FK "用户ID"
|
||
|
|
bigint role_id FK "角色ID"
|
||
|
|
timestamptz created_at "关联时间"
|
||
|
|
timestamptz updated_at "更新时间"
|
||
|
|
}
|
||
|
|
|
||
|
|
role_permissions {
|
||
|
|
bigint id PK "主键 (BigSerial)"
|
||
|
|
bigint role_id FK "角色ID"
|
||
|
|
bigint permission_id FK "权限ID"
|
||
|
|
timestamptz created_at "关联时间"
|
||
|
|
timestamptz updated_at "更新时间"
|
||
|
|
}
|
||
|
|
```
|