feat(core): implement optimistic locking across all entities
Add VersionMismatch error variant and check_version() helper to erp-core. All 13 mutable entities now enforce version checking on update/delete: - erp-auth: user, role, organization, department, position - erp-config: dictionary, dictionary_item, menu, setting, numbering_rule - erp-workflow: process_definition, process_instance, task - erp-message: message, message_subscription Update DTOs to expose version in responses and require version in update requests. HTTP 409 Conflict returned on version mismatch.
This commit is contained in:
@@ -14,6 +14,9 @@ pub enum ConfigError {
|
||||
|
||||
#[error("编号序列耗尽: {0}")]
|
||||
NumberingExhausted(String),
|
||||
|
||||
#[error("版本冲突: 数据已被其他操作修改,请刷新后重试")]
|
||||
VersionMismatch,
|
||||
}
|
||||
|
||||
impl From<sea_orm::TransactionError<ConfigError>> for ConfigError {
|
||||
@@ -34,6 +37,7 @@ impl From<ConfigError> for AppError {
|
||||
ConfigError::NotFound(s) => AppError::NotFound(s),
|
||||
ConfigError::DuplicateKey(s) => AppError::Conflict(s),
|
||||
ConfigError::NumberingExhausted(s) => AppError::Internal(s),
|
||||
ConfigError::VersionMismatch => AppError::VersionMismatch,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user