feat(config): add missing dictionary item CRUD, setting delete, and numbering delete routes

- Dictionary items: POST/PUT/DELETE endpoints under /config/dictionaries/{dict_id}/items
- Settings: DELETE /config/settings/{key}
- Numbering rules: DELETE /config/numbering-rules/{id}
- Fix workflow Entities: add deleted_at and version_field to process_definition,
  add standard fields to token and process_variable entities
- Update seed data for expanded permissions
This commit is contained in:
iven
2026-04-11 12:52:29 +08:00
parent 82986e988d
commit 184034ff6b
11 changed files with 223 additions and 14 deletions

View File

@@ -8,7 +8,6 @@ use validator::Validate;
/// BPMN 节点类型
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum NodeType {
StartEvent,
EndEvent,
@@ -20,7 +19,6 @@ pub enum NodeType {
/// 流程图节点定义
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct NodeDef {
pub id: String,
#[serde(rename = "type")]
@@ -38,7 +36,6 @@ pub struct NodeDef {
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct NodePosition {
pub x: f64,
pub y: f64,
@@ -46,7 +43,6 @@ pub struct NodePosition {
/// 流程图连线定义
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct EdgeDef {
pub id: String,
pub source: String,
@@ -61,7 +57,6 @@ pub struct EdgeDef {
/// 完整流程图
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct FlowDiagram {
pub nodes: Vec<NodeDef>,
pub edges: Vec<EdgeDef>,
@@ -98,8 +93,9 @@ pub struct CreateProcessDefinitionReq {
pub edges: Vec<EdgeDef>,
}
#[derive(Debug, Deserialize, ToSchema)]
#[derive(Debug, Deserialize, Validate, ToSchema)]
pub struct UpdateProcessDefinitionReq {
#[validate(length(max = 200, message = "流程名称过长"))]
pub name: Option<String>,
pub category: Option<String>,
pub description: Option<String>,
@@ -126,7 +122,7 @@ pub struct ProcessInstanceResp {
pub active_tokens: Vec<TokenResp>,
}
#[derive(Debug, Deserialize, ToSchema)]
#[derive(Debug, Deserialize, Validate, ToSchema)]
pub struct StartInstanceReq {
pub definition_id: Uuid,
pub business_key: Option<String>,
@@ -175,13 +171,14 @@ pub struct TaskResp {
pub business_key: Option<String>,
}
#[derive(Debug, Deserialize, ToSchema)]
#[derive(Debug, Deserialize, Validate, ToSchema)]
pub struct CompleteTaskReq {
#[validate(length(min = 1, max = 50, message = "审批结果不能为空"))]
pub outcome: String,
pub form_data: Option<serde_json::Value>,
}
#[derive(Debug, Deserialize, ToSchema)]
#[derive(Debug, Deserialize, Validate, ToSchema)]
pub struct DelegateTaskReq {
pub delegate_to: Uuid,
}
@@ -203,8 +200,9 @@ pub struct ProcessVariableResp {
pub value_date: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Deserialize, ToSchema)]
#[derive(Debug, Clone, Deserialize, Validate, ToSchema)]
pub struct SetVariableReq {
#[validate(length(min = 1, max = 100, message = "变量名不能为空"))]
pub name: String,
pub var_type: Option<String>,
pub value: serde_json::Value,

View File

@@ -23,6 +23,7 @@ pub struct Model {
pub updated_by: Uuid,
#[serde(skip_serializing_if = "Option::is_none")]
pub deleted_at: Option<DateTimeUtc>,
pub version_field: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View File

@@ -18,6 +18,13 @@ pub struct Model {
pub value_boolean: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub value_date: Option<DateTimeUtc>,
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)]

View File

@@ -11,6 +11,12 @@ pub struct Model {
pub node_id: String,
pub status: String,
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,
#[serde(skip_serializing_if = "Option::is_none")]
pub consumed_at: Option<DateTimeUtc>,
}

View File

@@ -112,3 +112,19 @@ where
InstanceService::terminate(id, ctx.tenant_id, ctx.user_id, &state.db).await?;
Ok(Json(ApiResponse::ok(())))
}
/// POST /api/v1/workflow/instances/{id}/resume
pub async fn resume_instance<S>(
State(state): State<WorkflowState>,
Extension(ctx): Extension<TenantContext>,
Path(id): Path<Uuid>,
) -> Result<Json<ApiResponse<()>>, AppError>
where
WorkflowState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
require_permission(&ctx, "workflow:update")?;
InstanceService::resume(id, ctx.tenant_id, ctx.user_id, &state.db).await?;
Ok(Json(ApiResponse::ok(())))
}