feat(diary): 添加贴纸包 UpdateStickerPackReq DTO + update service/handler — Task 13
Some checks failed
Main Merge / backend (push) Has been cancelled
Main Merge / frontend (push) Has been cancelled

This commit is contained in:
iven
2026-06-02 23:54:04 +08:00
parent d6dd017155
commit 45530616ee
4 changed files with 130 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ use erp_core::error::AppError;
use erp_core::rbac::require_permission;
use erp_core::types::{ApiResponse, TenantContext};
use crate::dto::{CreateStickerPackReq, CreateStickerReq, StickerPackResp, StickerResp, TemplateResp};
use crate::dto::{CreateStickerPackReq, CreateStickerReq, StickerPackResp, StickerResp, TemplateResp, UpdateStickerPackReq};
use crate::service::sticker_service::StickerService;
use crate::state::DiaryState;
@@ -127,6 +127,54 @@ where
Ok(Json(ApiResponse::ok(resp)))
}
#[utoipa::path(
put,
path = "/api/v1/diary/sticker-packs/{pack_id}",
params(("pack_id" = Uuid, Path, description = "贴纸包ID")),
request_body = UpdateStickerPackReq,
responses(
(status = 200, description = "更新成功", body = ApiResponse<StickerPackResp>),
(status = 400, description = "验证失败"),
(status = 401, description = "未授权"),
(status = 403, description = "权限不足"),
(status = 404, description = "贴纸包不存在"),
),
security(("bearer_auth" = [])),
tag = "贴纸管理"
)]
/// PUT /api/v1/diary/sticker-packs/:pack_id
///
/// 更新贴纸包(部分更新)。需要 `diary.class.manage` 权限。
pub async fn update_sticker_pack<S>(
State(state): State<DiaryState>,
Extension(ctx): Extension<TenantContext>,
Path(pack_id): Path<Uuid>,
Json(req): Json<UpdateStickerPackReq>,
) -> Result<Json<ApiResponse<StickerPackResp>>, AppError>
where
DiaryState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
require_permission(&ctx, "diary.class.manage")?;
if let Some(ref name) = req.name {
if name.trim().is_empty() {
return Err(AppError::Validation("贴纸包名称不能为空".to_string()));
}
}
let resp = StickerService::update_sticker_pack(
ctx.tenant_id,
pack_id,
ctx.user_id,
&req,
&state.db,
)
.await?;
Ok(Json(ApiResponse::ok(resp)))
}
#[utoipa::path(
delete,
path = "/api/v1/diary/sticker-packs/{pack_id}",