fix(admin-web): fix nested data access in pendingActionService
API returns nested structure: { success, data: { code, message, data: {...} } }
After apiClient interceptor unwraps response.data, we still need to access
.data.data to get the actual business data.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
ed463d67ab
commit
06d3489b49
|
|
@ -17,24 +17,30 @@ import type {
|
|||
|
||||
/**
|
||||
* 待办操作管理服务
|
||||
* 注意:apiClient 响应拦截器已解包 response.data,直接返回数据
|
||||
*
|
||||
* API 响应结构(经过 apiClient 拦截器解包后):
|
||||
* { success: true, data: { code: "OK", message: "success", data: {...} } }
|
||||
*
|
||||
* 需要访问 .data.data 获取实际业务数据
|
||||
*/
|
||||
export const pendingActionService = {
|
||||
/**
|
||||
* 查询待办操作列表
|
||||
*/
|
||||
async getList(params: QueryPendingActionsParams = {}): Promise<PendingActionListResponse> {
|
||||
// apiClient 拦截器已返回 response.data,这里直接返回
|
||||
const data = await apiClient.get(API_ENDPOINTS.PENDING_ACTIONS.LIST, { params });
|
||||
return (data as { data: PendingActionListResponse }).data;
|
||||
const response = await apiClient.get(API_ENDPOINTS.PENDING_ACTIONS.LIST, { params });
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const result = (response as any)?.data?.data;
|
||||
return result ?? { items: [], total: 0, page: 1, limit: 20 };
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取单个待办操作详情
|
||||
*/
|
||||
async getDetail(id: string): Promise<PendingAction> {
|
||||
const data = await apiClient.get(API_ENDPOINTS.PENDING_ACTIONS.DETAIL(id));
|
||||
return (data as { data: PendingAction }).data;
|
||||
const response = await apiClient.get(API_ENDPOINTS.PENDING_ACTIONS.DETAIL(id));
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (response as any)?.data?.data;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -42,7 +48,8 @@ export const pendingActionService = {
|
|||
*/
|
||||
async create(data: CreatePendingActionRequest): Promise<PendingAction> {
|
||||
const response = await apiClient.post(API_ENDPOINTS.PENDING_ACTIONS.CREATE, data);
|
||||
return (response as { data: PendingAction }).data;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (response as any)?.data?.data;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -50,7 +57,8 @@ export const pendingActionService = {
|
|||
*/
|
||||
async batchCreate(data: BatchCreatePendingActionRequest): Promise<BatchCreateResult> {
|
||||
const response = await apiClient.post(API_ENDPOINTS.PENDING_ACTIONS.BATCH_CREATE, data);
|
||||
return (response as { data: BatchCreateResult }).data;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (response as any)?.data?.data;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -58,7 +66,8 @@ export const pendingActionService = {
|
|||
*/
|
||||
async update(id: string, data: UpdatePendingActionRequest): Promise<PendingAction> {
|
||||
const response = await apiClient.put(API_ENDPOINTS.PENDING_ACTIONS.UPDATE(id), data);
|
||||
return (response as { data: PendingAction }).data;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (response as any)?.data?.data;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -66,7 +75,8 @@ export const pendingActionService = {
|
|||
*/
|
||||
async cancel(id: string): Promise<PendingAction> {
|
||||
const response = await apiClient.post(API_ENDPOINTS.PENDING_ACTIONS.CANCEL(id));
|
||||
return (response as { data: PendingAction }).data;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (response as any)?.data?.data;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue