feat(plugin): PATCH 部分更新端点 — jsonb_set 字段合并
This commit is contained in:
@@ -9,7 +9,7 @@ use erp_core::types::{ApiResponse, PaginatedResponse, TenantContext};
|
||||
|
||||
use crate::data_dto::{
|
||||
AggregateItem, AggregateQueryParams, CountQueryParams, CreatePluginDataReq,
|
||||
PluginDataListParams, PluginDataResp, UpdatePluginDataReq,
|
||||
PatchPluginDataReq, PluginDataListParams, PluginDataResp, UpdatePluginDataReq,
|
||||
};
|
||||
use crate::data_service::{PluginDataService, resolve_manifest_id};
|
||||
use crate::state::PluginState;
|
||||
@@ -253,6 +253,39 @@ where
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
patch,
|
||||
path = "/api/v1/plugins/{plugin_id}/{entity}/{id}",
|
||||
request_body = PatchPluginDataReq,
|
||||
responses(
|
||||
(status = 200, description = "部分更新成功", body = ApiResponse<PluginDataResp>),
|
||||
),
|
||||
security(("bearer_auth" = [])),
|
||||
tag = "插件数据"
|
||||
)]
|
||||
/// PATCH /api/v1/plugins/{plugin_id}/{entity}/{id} — 部分更新(jsonb_set 合并字段)
|
||||
pub async fn patch_plugin_data<S>(
|
||||
State(state): State<PluginState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
Path((plugin_id, entity, id)): Path<(Uuid, String, Uuid)>,
|
||||
Json(req): Json<PatchPluginDataReq>,
|
||||
) -> Result<Json<ApiResponse<PluginDataResp>>, AppError>
|
||||
where
|
||||
PluginState: FromRef<S>,
|
||||
S: Clone + Send + Sync + 'static,
|
||||
{
|
||||
let manifest_id = resolve_manifest_id(plugin_id, ctx.tenant_id, &state.db).await?;
|
||||
let fine_perm = compute_permission_code(&manifest_id, &entity, "update");
|
||||
require_permission(&ctx, &fine_perm)?;
|
||||
|
||||
let result = PluginDataService::partial_update(
|
||||
plugin_id, &entity, id, ctx.tenant_id, ctx.user_id,
|
||||
req.data, req.version, &state.db,
|
||||
).await?;
|
||||
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/api/v1/plugins/{plugin_id}/{entity}/{id}",
|
||||
|
||||
Reference in New Issue
Block a user