实体: - journal_entry: 日记核心表 (心情/天气/标签/版本) - journal_element: 日记元素 (文字/图片/贴纸/手写/胶带) - handwriting_stroke: 手写笔画 (独立大字段表) - school_class: 班级 (6位码/过期控制) - class_member: 班级成员 (复合PK) - topic_assignment: 主题布置 - comment: 老师点评 - sticker_pack + sticker: 贴纸包和贴纸 - template: 日记模板 - achievement + user_achievement: 成就系统 - parent_child_binding: 家长-孩子绑定 (PIPL) - teacher_profile: 老师档案 - user_settings: 用户设置 迁移 (000170-000184): - 15 个建表迁移 + 索引 + RLS 策略 + 种子数据 - 所有表含 tenant_id 多租户隔离 - 软删除 + 乐观锁版本号 - 外键级联删除 - 暖记权限注册到基座 permissions 表 验证: cargo check 通过, 425 个测试全通过
53 lines
1.5 KiB
Rust
53 lines
1.5 KiB
Rust
// 主题布置 — 老师发布日记主题,学生提交对应日记
|
|
|
|
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
|
#[sea_orm(table_name = "topic_assignments")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub id: Uuid,
|
|
pub tenant_id: Uuid,
|
|
/// 所属班级
|
|
pub class_id: Uuid,
|
|
/// 布置主题的老师
|
|
pub teacher_id: Uuid,
|
|
/// 主题标题
|
|
pub title: String,
|
|
/// 主题描述/要求
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub description: Option<String>,
|
|
/// 截止日期
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub due_date: Option<chrono::NaiveDate>,
|
|
/// 是否激活
|
|
pub is_active: bool,
|
|
pub created_at: DateTimeUtc,
|
|
pub updated_at: DateTimeUtc,
|
|
pub created_by: Uuid,
|
|
pub updated_by: Uuid,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub deleted_at: Option<DateTimeUtc>,
|
|
pub version: i32,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::school_class::Entity",
|
|
from = "Column::ClassId",
|
|
to = "super::school_class::Column::Id",
|
|
on_delete = "Cascade"
|
|
)]
|
|
SchoolClass,
|
|
}
|
|
|
|
impl Related<super::school_class::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::SchoolClass.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|