后端: - 添加 articles 表迁移 + Entity + Service + Handler - 健康数据趋势 API (get_mini_trend) 注册路由 - article CRUD (list/get) + DTO 前端 (11个新页面 + 5个服务): - 预约挂号: 列表/创建向导/详情页 - 报告管理: 列表/详情页 - 随访管理: 任务列表/记录详情页 - 资讯文章: 文章详情页 - 个人中心: 就诊人管理/新增/我的报告/我的随访/用药提醒/设置 - 更新 app.config.ts 注册全部路由 - 更新 profile/article 页面为真实功能
105 lines
3.6 KiB
Rust
105 lines
3.6 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(Article::Table)
|
|
.if_not_exists()
|
|
.col(ColumnDef::new(Article::Id).uuid().not_null().primary_key())
|
|
.col(ColumnDef::new(Article::TenantId).uuid().not_null())
|
|
.col(ColumnDef::new(Article::Title).string_len(200).not_null())
|
|
.col(ColumnDef::new(Article::Summary).text().null())
|
|
.col(ColumnDef::new(Article::Content).text().not_null())
|
|
.col(ColumnDef::new(Article::CoverImage).string_len(500).null())
|
|
.col(ColumnDef::new(Article::Category).string_len(50).null())
|
|
.col(ColumnDef::new(Article::Author).string_len(100).null())
|
|
.col(ColumnDef::new(Article::PublishedAt).timestamp_with_time_zone().null())
|
|
.col(
|
|
ColumnDef::new(Article::CreatedAt)
|
|
.timestamp_with_time_zone()
|
|
.not_null()
|
|
.default(Expr::current_timestamp()),
|
|
)
|
|
.col(
|
|
ColumnDef::new(Article::UpdatedAt)
|
|
.timestamp_with_time_zone()
|
|
.not_null()
|
|
.default(Expr::current_timestamp()),
|
|
)
|
|
.col(ColumnDef::new(Article::CreatedBy).uuid().null())
|
|
.col(ColumnDef::new(Article::UpdatedBy).uuid().null())
|
|
.col(ColumnDef::new(Article::DeletedAt).timestamp_with_time_zone().null())
|
|
.col(
|
|
ColumnDef::new(Article::Version)
|
|
.integer()
|
|
.not_null()
|
|
.default(1),
|
|
)
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
|
|
manager
|
|
.create_index(
|
|
Index::create()
|
|
.if_not_exists()
|
|
.name("idx_article_tenant_category")
|
|
.table(Article::Table)
|
|
.col(Article::TenantId)
|
|
.col(Article::Category)
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
|
|
manager
|
|
.create_index(
|
|
Index::create()
|
|
.if_not_exists()
|
|
.name("idx_article_tenant_published")
|
|
.table(Article::Table)
|
|
.col(Article::TenantId)
|
|
.col(Article::PublishedAt)
|
|
.to_owned(),
|
|
)
|
|
.await
|
|
}
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.drop_index(Index::drop().name("idx_article_tenant_published").to_owned())
|
|
.await?;
|
|
manager
|
|
.drop_index(Index::drop().name("idx_article_tenant_category").to_owned())
|
|
.await?;
|
|
manager
|
|
.drop_table(Table::drop().table(Article::Table).to_owned())
|
|
.await
|
|
}
|
|
}
|
|
|
|
#[derive(DeriveIden)]
|
|
enum Article {
|
|
Table,
|
|
Id,
|
|
TenantId,
|
|
Title,
|
|
Summary,
|
|
Content,
|
|
CoverImage,
|
|
Category,
|
|
Author,
|
|
PublishedAt,
|
|
CreatedAt,
|
|
UpdatedAt,
|
|
CreatedBy,
|
|
UpdatedBy,
|
|
DeletedAt,
|
|
Version,
|
|
}
|