fix(diary): 添加事务 — create_class/join_class/parent 删除原子化

- create_class: 班级创建 + 老师成员插入包裹在 db.transaction() 中
- join_class: 成员插入 + member_count 更新包裹在事务中
- delete_child_data: PIPL 删除权 — 逐条软删除包裹在事务中(避免部分删除)
- DiaryError: 添加 From<TransactionError<DiaryError>> 支持事务闭包

审计 ID: B-07, B-11, 8a-C03
This commit is contained in:
iven
2026-06-03 01:03:57 +08:00
parent 1750f17f41
commit e0052ea99b
3 changed files with 102 additions and 69 deletions

View File

@@ -106,6 +106,18 @@ impl From<sea_orm::DbErr> for DiaryError {
}
}
/// 支持 db.transaction() 闭包的错误转换
impl From<sea_orm::TransactionError<DiaryError>> for DiaryError {
fn from(err: sea_orm::TransactionError<DiaryError>) -> Self {
match err {
sea_orm::TransactionError::Connection(db_err) => {
DiaryError::Internal(db_err.to_string())
}
sea_orm::TransactionError::Transaction(inner) => inner,
}
}
}
#[cfg(test)]
mod tests {
use super::*;