task-93(店铺中心): 实现店铺凭证字段分离

新增 shop-credential-model.ts:凭证明文仅经凭证端点解码且落 SensitiveString,
与列表行(仅掩码)字段分离;shop-manage-api.ts 增加 fetchShopCredential
(GET /api/admin/shop-manages/{id}/credential?shop_name=…)。

TDD: task-93.test.ts 8 用例先 RED 后 GREEN。
This commit is contained in:
2026-09-05 16:48:26 +08:00
parent 813ab5db7b
commit 7fa9b5ccf3
3 changed files with 127 additions and 1 deletions
@@ -1,11 +1,13 @@
/** 店铺列表/分组/新增适配(任务 88/90/91):GET|POST /api/admin/shop-manages + 归一与解析。 */
/** 店铺列表/分组/新增/编辑/凭证适配(任务 88-93):/api/admin/shop-manages 系端点 + 归一与解析。 */
import { http } from '@/api/http'
import { unwrap } from '@/api/envelope'
import { parseShopManagePage, toShopSummary } from './shop-manage-model.ts'
import { parseShopManageGroups } from './shop-group-model.ts'
import { toShopCredential } from './shop-credential-model.ts'
import {
normalizeShopListParams,
toShopManagePageQuery,
type ShopCredential,
type ShopGroupOption,
type ShopManageListParams,
type ShopPageResult,
@@ -61,3 +63,13 @@ export async function submitUpdateShopManage(id: number, form: ShopManageFormVal
}
return item
}
/** 读取店铺明文凭据:GET /api/admin/shop-manages/{id}/credential?shop_name=…;明文仅在内存短时使用。 */
export async function fetchShopCredential(id: number, shopName: string): Promise<ShopCredential> {
const { data } = await http.get<unknown>(`${SHOP_MANAGE_ENDPOINT}/${id}/credential`, { params: { shop_name: shopName } })
const credential = toShopCredential(unwrap<unknown>(data))
if (!credential) {
throw new Error('读取店铺凭证响应异常:未返回有效记录')
}
return credential
}