6d835e947e
三家公司的密钥挤在一页上,而"筛选"是拿当前页那 10 行在前端筛的:total 不动, 第 2 家的令牌要翻到它所在页才筛得出来。操作列给 160px 装不下三颗按钮, 最后一颗(删除)被 td 的 overflow:hidden + table-layout:fixed 整颗裁掉—— DOM 里在、事件也在,就是看不见点不到,这就是"没有删除功能"的真相。 - GET /api/admin/shop-keys 新增 keyword / token / whitelist_status,在公司读范围之内 由服务端筛。keyword 那组 OR 必须括起来:不括就被后续 AND 短路成 「备注名命中 OR (账号命中 AND 本公司)」,第 2 家的 tab 能读到第 1 家的令牌。 - create 的归属改为过读门(认当前 tab),不再只认操作者会话那一家。 读认 tab、写认会话=两把尺子:admin 是 super_admin 且 company_id=1, 他在别家 tab 点新增会"提示已新增、行却落进米椿花名下",再点一次就撞令牌唯一键。 这一条推翻 10-06 定案,controller 的反向钉子(create 不许碰读门)同步换成 「tab 必须过门 + 不许把请求原值直传下去」。 - 操作列 160→270px,.ops-cell 补 flex-wrap: wrap,把"超宽=静默消失"退化成"多占一行"; 同族结构隐患一次扫过 8 个页面(宽度够不够是像素账,会不会消失是结构账)。 - 护栏:ops-cell-must-wrap 钉跨页结构,shop-key-filter-params 钉参数下发与列宽; source-pin 棘轮补第二把尺子 reads=全文读点(体内+体外), pins 降而 reads 不同步降=把 readSource 挪出用例体冒充改进,当场红。 验证:将要提交的树(HEAD + 本批白名单)在独立 worktree 实跑——前端 1762 例 0 红、 vue-tsc rc=0、Java 41 例 0 红且 959 主源 + 498 测试源全量编译过(证明不依赖并行会话 未提交的符号);主树全量 1766 例 0 红。变异自证三支全杀:摘掉一页的 flex-wrap ⇒ 恰好 1 红点名该页;把体内读盘挪进 helper ⇒ 棘轮 1 红且文案点名"不算改进"; 归属退回按会话、controller 绕门直传原值 ⇒ 各自红。
206 lines
7.4 KiB
TypeScript
206 lines
7.4 KiB
TypeScript
/** 店铺中心共享 DTO(任务 81):店铺密钥/店铺摘要/明文凭据/分组与分页类型;
|
||
* 纯逻辑、无框架依赖,与 Java shopkey 模块的 camelCase 接口契约对齐。 */
|
||
|
||
export const SHOP_PAGE_DEFAULT_SIZE = 15
|
||
export const SHOP_PAGE_MIN_PAGE = 1
|
||
export const SHOP_PAGE_MAX_SIZE = 100
|
||
|
||
/** 敏感字符串品牌:紫鸟令牌、店铺密码等明文只允许经 toSensitiveString 标记,禁止直接进入通用日志/上报。 */
|
||
export type SensitiveString = string & { readonly __sensitiveBrand: unique symbol }
|
||
|
||
export function toSensitiveString(value: string): SensitiveString {
|
||
return value as SensitiveString
|
||
}
|
||
|
||
/** 紫鸟 IP 白名单状态。取值清单住在这里(DTO 层),model 的归一与筛选下拉共用同一份,
|
||
* 否则"下拉里有的、后端说非法"和"药丸渲染出的态、筛不出来"会各错一次。 */
|
||
export type IpWhitelistStatus = 'UNKNOWN' | 'ALLOWED' | 'BLOCKED'
|
||
export const IP_WHITELIST_VALUES: readonly IpWhitelistStatus[] = ['UNKNOWN', 'ALLOWED', 'BLOCKED']
|
||
|
||
/** 店铺密钥行(GET /api/admin/shop-keys data.items;Java ShopKeyItemVo)。 */
|
||
export interface ShopKeyItem {
|
||
id: number
|
||
remarkName: string
|
||
ziniaoAccountName: string
|
||
/** 紫鸟令牌:敏感字段,列表展示必须掩码。 */
|
||
ziniaoToken: SensitiveString
|
||
/** 静态代理地址;为空表示直连。用于出口 IP 不在紫鸟白名单的 key。 */
|
||
proxyUrl: string
|
||
ipWhitelistStatus: IpWhitelistStatus
|
||
ipWhitelistCheckedAt?: string
|
||
ipWhitelistMessage?: string
|
||
/** 连续白名单失败次数;达上限后不再自动重试,需人工检测。 */
|
||
ipWhitelistFailCount: number
|
||
createdAt?: string
|
||
updatedAt?: string
|
||
}
|
||
|
||
export interface ShopKeyPageResult {
|
||
items: ShopKeyItem[]
|
||
total: number
|
||
page: number
|
||
pageSize: number
|
||
}
|
||
|
||
/** 店铺行(GET /api/admin/shop-manages data.items;Java ShopManageItemVo,密码只下发掩码)。 */
|
||
export interface ShopSummary {
|
||
id: number
|
||
groupId: number | null
|
||
groupName: string
|
||
shopName: string
|
||
mallName: string
|
||
znUsername: string
|
||
account: string
|
||
passwordMasked?: string
|
||
createdAt?: string
|
||
updatedAt?: string
|
||
}
|
||
|
||
export interface ShopPageResult {
|
||
items: ShopSummary[]
|
||
total: number
|
||
page: number
|
||
pageSize: number
|
||
}
|
||
|
||
/** 店铺明文凭据(GET /api/admin/shop-manages/{id}/credential data;Java ShopManageCredentialVo)。 */
|
||
export interface ShopCredential {
|
||
id: number
|
||
groupId: number | null
|
||
groupName: string
|
||
shopName: string
|
||
mallName: string
|
||
znUsername: string
|
||
account: string
|
||
password: SensitiveString
|
||
}
|
||
|
||
/** 店铺分组下拉项(GET /api/admin/shop-manages/groups data)。 */
|
||
export interface ShopGroupOption {
|
||
id: number
|
||
groupName: string
|
||
memberCount?: number
|
||
leaderUsername?: string
|
||
}
|
||
|
||
/** 店铺密钥列表分页参数(分页 + 三个筛选 + 公司 tab;归一是白名单构造,不点名 companyId)。 */
|
||
export interface ShopKeyListParams {
|
||
page: number
|
||
pageSize: number
|
||
/** 备注名 / 紫鸟账号 模糊词。 */
|
||
keyword?: string
|
||
/** 紫鸟令牌 模糊词。 */
|
||
token?: string
|
||
/** 白名单状态等值筛;空 = 不筛。 */
|
||
whitelistStatus?: IpWhitelistStatus | null
|
||
/** 公司 tab 的值;normalizeKeyListParams 不点名它,只有 api 层能从原始 params 读到。 */
|
||
companyId?: number | null
|
||
}
|
||
|
||
/** 店铺列表分页/筛选参数。 */
|
||
export interface ShopManageListParams {
|
||
page: number
|
||
pageSize: number
|
||
groupId?: number | null
|
||
shopName?: string
|
||
/** 公司 tab 的值;normalizeShopListParams 不点名它,只有 api 层能从原始 params 读到。 */
|
||
companyId?: number | null
|
||
}
|
||
|
||
export interface ShopKeyPageQuery {
|
||
page: number
|
||
pageSize: number
|
||
/** 下划线形:与后端 @RequestParam(name = "keyword"/"token"/"whitelist_status") 逐字对齐。 */
|
||
keyword?: string
|
||
token?: string
|
||
whitelist_status?: string
|
||
/** 下划线形:与后端 @RequestParam(name = "company_id") 逐字对齐。 */
|
||
company_id?: number
|
||
}
|
||
|
||
export interface ShopManagePageQuery {
|
||
page: number
|
||
pageSize: number
|
||
groupId?: number
|
||
shopName?: string
|
||
/** 下划线形:与后端 @RequestParam(name = "company_id") 逐字对齐。 */
|
||
company_id?: number
|
||
}
|
||
|
||
function finiteInt(value: unknown): number | null {
|
||
return typeof value === 'number' && Number.isFinite(value) ? Math.floor(value) : null
|
||
}
|
||
|
||
function positiveIdOrNull(value: unknown): number | null {
|
||
const id = finiteInt(value)
|
||
return id === null || id < 1 ? null : id
|
||
}
|
||
|
||
function trimOrUndefined(value: unknown): string | undefined {
|
||
return typeof value === 'string' && value.trim() ? value.trim() : undefined
|
||
}
|
||
|
||
/** 白名单状态归一:大小写/空白容忍,不在清单里的一律当"不筛"(下拉只可能给清单内的值)。 */
|
||
function statusOrUndefined(value: unknown): IpWhitelistStatus | undefined {
|
||
const textValue = typeof value === 'string' ? value.trim().toUpperCase() : ''
|
||
return IP_WHITELIST_VALUES.includes(textValue as IpWhitelistStatus)
|
||
? (textValue as IpWhitelistStatus)
|
||
: undefined
|
||
}
|
||
|
||
/** 归一化分页:页码下限 1、页大小钳制在 1..100(与 Java 服务端一致)。 */
|
||
function normalizePageCore(raw: { page?: unknown; pageSize?: unknown }): { page: number; pageSize: number } {
|
||
const page = Math.max(finiteInt(raw.page) ?? SHOP_PAGE_MIN_PAGE, SHOP_PAGE_MIN_PAGE)
|
||
const rawSize = finiteInt(raw.pageSize)
|
||
const pageSize =
|
||
rawSize === null || rawSize < SHOP_PAGE_MIN_PAGE
|
||
? SHOP_PAGE_DEFAULT_SIZE
|
||
: Math.min(rawSize, SHOP_PAGE_MAX_SIZE)
|
||
return { page, pageSize }
|
||
}
|
||
|
||
/** 店铺密钥列表分页/筛选归一:空白筛选词与非法状态都归成"不筛",与 toKeyPageQuery 只下发非空一致。 */
|
||
export function normalizeKeyListParams(raw: Partial<ShopKeyListParams>): ShopKeyListParams {
|
||
return {
|
||
...normalizePageCore(raw),
|
||
keyword: trimOrUndefined(raw.keyword),
|
||
token: trimOrUndefined(raw.token),
|
||
whitelistStatus: statusOrUndefined(raw.whitelistStatus),
|
||
}
|
||
}
|
||
|
||
/** 店铺列表分页/筛选归一:负/缺分组 id 视为无筛选,空白店铺名视为无过滤。 */
|
||
export function normalizeShopListParams(raw: Partial<ShopManageListParams>): ShopManageListParams {
|
||
return {
|
||
...normalizePageCore(raw),
|
||
groupId: positiveIdOrNull(raw.groupId),
|
||
shopName: trimOrUndefined(raw.shopName),
|
||
}
|
||
}
|
||
|
||
export function toKeyPageQuery(params: ShopKeyListParams): ShopKeyPageQuery {
|
||
const query: ShopKeyPageQuery = { page: params.page, pageSize: params.pageSize }
|
||
if (params.keyword) query.keyword = params.keyword
|
||
if (params.token) query.token = params.token
|
||
if (params.whitelistStatus) query.whitelist_status = params.whitelistStatus
|
||
return query
|
||
}
|
||
|
||
/** 前端状态 → Java 查询参数(camelCase);仅下发非空可选字段。 */
|
||
export function toShopManagePageQuery(params: ShopManageListParams): ShopManagePageQuery {
|
||
const query: ShopManagePageQuery = { page: params.page, pageSize: params.pageSize }
|
||
if (params.groupId != null) query.groupId = params.groupId
|
||
if (params.shopName) query.shopName = params.shopName
|
||
return query
|
||
}
|
||
|
||
/** 无数据密钥分页缺省值(首屏/加载前占位)。 */
|
||
export function emptyShopKeyPageResult(): ShopKeyPageResult {
|
||
return { items: [], total: 0, page: SHOP_PAGE_MIN_PAGE, pageSize: SHOP_PAGE_DEFAULT_SIZE }
|
||
}
|
||
|
||
/** 无数据店铺分页缺省值(首屏/加载前占位)。 */
|
||
export function emptyShopPageResult(): ShopPageResult {
|
||
return { items: [], total: 0, page: SHOP_PAGE_MIN_PAGE, pageSize: SHOP_PAGE_DEFAULT_SIZE }
|
||
}
|