3.1 配置变更通知:
- update_config 增加 EventBus 参数
- 更新成功后发布 plugin.config.updated 事件
- handler 传入 event_bus
3.2 自定义视图:
- plugin_user_views 表迁移 (id/tenant_id/user_id/plugin_id/entity/view_name/view_config/is_default)
- CRUD API: GET/POST /plugins/{id}/{entity}/views, DELETE /plugins/{id}/{entity}/views/{view_id}
- 默认视图互斥逻辑
47 lines
2.0 KiB
Rust
47 lines
2.0 KiB
Rust
use sea_orm_migration::prelude::*;
|
|
|
|
/// 插件用户视图 — 用户自定义的列表视图配置
|
|
#[derive(DeriveMigrationName)]
|
|
pub struct Migration;
|
|
|
|
#[async_trait::async_trait]
|
|
impl MigrationTrait for Migration {
|
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.create_table(
|
|
Table::create()
|
|
.table(Alias::new("plugin_user_views"))
|
|
.if_not_exists()
|
|
.col(
|
|
ColumnDef::new(Alias::new("id"))
|
|
.uuid()
|
|
.not_null()
|
|
.primary_key(),
|
|
)
|
|
.col(ColumnDef::new(Alias::new("tenant_id")).uuid().not_null())
|
|
.col(ColumnDef::new(Alias::new("user_id")).uuid().not_null())
|
|
.col(ColumnDef::new(Alias::new("plugin_id")).string().not_null())
|
|
.col(ColumnDef::new(Alias::new("entity_name")).string().not_null())
|
|
.col(ColumnDef::new(Alias::new("view_name")).string().not_null())
|
|
.col(ColumnDef::new(Alias::new("view_config")).json().not_null())
|
|
.col(ColumnDef::new(Alias::new("is_default")).boolean().not_null().default(false))
|
|
.col(ColumnDef::new(Alias::new("created_at"))
|
|
.timestamp_with_time_zone()
|
|
.not_null()
|
|
.default(Expr::current_timestamp()))
|
|
.col(ColumnDef::new(Alias::new("updated_at"))
|
|
.timestamp_with_time_zone()
|
|
.not_null()
|
|
.default(Expr::current_timestamp()))
|
|
.to_owned(),
|
|
)
|
|
.await
|
|
}
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.drop_table(Table::drop().table(Alias::new("plugin_user_views")).to_owned())
|
|
.await
|
|
}
|
|
}
|