feat(message): add message center module (Phase 5)
Implement the complete message center with: - Database migrations for message_templates, messages, message_subscriptions tables - erp-message crate with entities, DTOs, services, handlers - Message CRUD, send, read/unread tracking, soft delete - Template management with variable interpolation - Subscription preferences with DND support - Frontend: messages page, notification panel, unread count badge - Server integration with module registration and routing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
41
crates/erp-message/src/error.rs
Normal file
41
crates/erp-message/src/error.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use erp_core::error::AppError;
|
||||
|
||||
/// 消息中心模块错误类型。
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum MessageError {
|
||||
#[error("验证失败: {0}")]
|
||||
Validation(String),
|
||||
|
||||
#[error("未找到: {0}")]
|
||||
NotFound(String),
|
||||
|
||||
#[error("模板编码已存在: {0}")]
|
||||
DuplicateTemplateCode(String),
|
||||
|
||||
#[error("渲染失败: {0}")]
|
||||
TemplateRenderError(String),
|
||||
}
|
||||
|
||||
impl From<MessageError> for AppError {
|
||||
fn from(err: MessageError) -> Self {
|
||||
match err {
|
||||
MessageError::Validation(msg) => AppError::Validation(msg),
|
||||
MessageError::NotFound(msg) => AppError::NotFound(msg),
|
||||
MessageError::DuplicateTemplateCode(msg) => AppError::Conflict(msg),
|
||||
MessageError::TemplateRenderError(msg) => AppError::Internal(msg),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<sea_orm::TransactionError<MessageError>> for MessageError {
|
||||
fn from(err: sea_orm::TransactionError<MessageError>) -> Self {
|
||||
match err {
|
||||
sea_orm::TransactionError::Connection(db_err) => {
|
||||
MessageError::Validation(db_err.to_string())
|
||||
}
|
||||
sea_orm::TransactionError::Transaction(msg_err) => msg_err,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type MessageResult<T> = Result<T, MessageError>;
|
||||
Reference in New Issue
Block a user