feat(phase-3): 后管无侵权只读页——私有鉴权闸+readCompanyIdOrOwn 公司隔离+分页钳制;前端自绘表格页与路由/操作提示/五护栏同轮记账
后端:AdminAppearancePatentCleanItemsController(GET /api/admin/appearance-patent-clean-items,requireCleanItemsAccess 照去重页形状)+ AppearancePatentCleanItemQueryService(page≤10000/size≤100 钳制防 (page-1)*page_size 溢出)+两 VO;PageDefaults 第五种 page_size=10 显式登记。前端:AppearancePatentCleanItemsPage(自绘 table+OldPagination,companyScoped)+api/filter/model 拆件;routes/company-scope/operation-guides 收口。护栏:company-tab-wiring 24 处发送口、date-range-order 分母 21 实例/9 对、date-guard EXEMPT、ChunkRow 无侵权白名单四件(LlmClient 仍是唯一结论值来源)、SourceScan 52 支、G2 WIRED_PAGE_KEYS 第七支。判据修正:columnKey→getColumnKey 对齐代码库命名。
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
/** 外观专利无侵权数据列表查询模型(v1.3 AC-5):解析 AppearancePatentCleanItemPageVo(camel),纯逻辑。
|
||||
* 行值是同步服务从 chunk payload 原样落的,读侧只搬运不加工(与后端 toVo 同一口径)。 */
|
||||
import { unwrap } from '../../api/envelope.ts'
|
||||
|
||||
export interface AppearancePatentCleanItem {
|
||||
id: number
|
||||
resultId: number | null
|
||||
taskId: number | null
|
||||
userId: number | null
|
||||
companyId: number | null
|
||||
rowNo: number | null
|
||||
asin: string
|
||||
country: string
|
||||
sku: string
|
||||
brand: string
|
||||
price: string
|
||||
title: string
|
||||
imageUrl: string
|
||||
itemUrl: string
|
||||
conclusion: string
|
||||
titleReason: string
|
||||
appearanceReason: string
|
||||
patentReason: string
|
||||
sourceFilename: string
|
||||
syncedAt?: string
|
||||
}
|
||||
|
||||
export interface AppearancePatentCleanPageResult {
|
||||
items: AppearancePatentCleanItem[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
/** 前端首屏默认容量:与后端 PageDefaults.CLEAN_ITEMS_PAGE_SIZE(蓝图 §3.2 默认 10)同值。 */
|
||||
export const APPEARANCE_PATENT_CLEAN_DEFAULT_SIZE = 10
|
||||
|
||||
export function emptyAppearancePatentCleanPage(): AppearancePatentCleanPageResult {
|
||||
return { items: [], total: 0, page: 1, pageSize: APPEARANCE_PATENT_CLEAN_DEFAULT_SIZE }
|
||||
}
|
||||
|
||||
function text(value: unknown): string {
|
||||
return typeof value === 'string' ? value.trim() : ''
|
||||
}
|
||||
|
||||
function numberOrNull(value: unknown): number | null {
|
||||
return typeof value === 'number' && Number.isFinite(value) ? Math.floor(value) : null
|
||||
}
|
||||
|
||||
/** 解析单行明细;缺 id 视为无效。camel 为正、snake 容错(与去重页模型同形)。 */
|
||||
export function toAppearancePatentCleanItem(raw: unknown): AppearancePatentCleanItem | null {
|
||||
if (!raw || typeof raw !== 'object') return null
|
||||
const record = raw as Record<string, unknown>
|
||||
const id = numberOrNull(record.id)
|
||||
if (id === null) return null
|
||||
return {
|
||||
id,
|
||||
resultId: numberOrNull(record.resultId ?? record.result_id),
|
||||
taskId: numberOrNull(record.taskId ?? record.task_id),
|
||||
userId: numberOrNull(record.userId ?? record.user_id),
|
||||
companyId: numberOrNull(record.companyId ?? record.company_id),
|
||||
rowNo: numberOrNull(record.rowNo ?? record.row_no),
|
||||
asin: text(record.asin),
|
||||
country: text(record.country),
|
||||
sku: text(record.sku),
|
||||
brand: text(record.brand),
|
||||
price: text(record.price),
|
||||
title: text(record.title),
|
||||
imageUrl: text(record.imageUrl ?? record.image_url),
|
||||
itemUrl: text(record.itemUrl ?? record.item_url),
|
||||
conclusion: text(record.conclusion),
|
||||
titleReason: text(record.titleReason ?? record.title_reason),
|
||||
appearanceReason: text(record.appearanceReason ?? record.appearance_reason),
|
||||
patentReason: text(record.patentReason ?? record.patent_reason),
|
||||
sourceFilename: text(record.sourceFilename ?? record.source_filename),
|
||||
syncedAt: text(record.syncedAt ?? record.synced_at) || undefined,
|
||||
}
|
||||
}
|
||||
|
||||
/** 归一化分页负载(信封或已解包 VO)为前端结果;缺省字段回默认。无 keyset 游标(蓝图 Out of Scope)。 */
|
||||
export function parseAppearancePatentCleanPage(payload: unknown): AppearancePatentCleanPageResult {
|
||||
const out = emptyAppearancePatentCleanPage()
|
||||
const core = unwrap<unknown>(payload)
|
||||
if (!core || typeof core !== 'object') return out
|
||||
const record = core as Record<string, unknown>
|
||||
if (Array.isArray(record.items)) {
|
||||
out.items = record.items
|
||||
.map((raw) => toAppearancePatentCleanItem(raw))
|
||||
.filter((item): item is AppearancePatentCleanItem => item !== null)
|
||||
}
|
||||
if (typeof record.total === 'number') out.total = Math.floor(record.total)
|
||||
if (typeof record.page === 'number' && record.page >= 1) out.page = Math.floor(record.page)
|
||||
const rawSize = record.pageSize ?? record.page_size
|
||||
if (typeof rawSize === 'number' && rawSize >= 1) out.pageSize = Math.floor(rawSize)
|
||||
return out
|
||||
}
|
||||
|
||||
/** 结论单元格的悬停全文:三因齐给,空因不下发(读侧不加工的展示面出口)。 */
|
||||
export function cleanItemReasonTooltip(item: AppearancePatentCleanItem): string {
|
||||
const parts: string[] = []
|
||||
if (item.titleReason) parts.push(`标题:${item.titleReason}`)
|
||||
if (item.appearanceReason) parts.push(`外观:${item.appearanceReason}`)
|
||||
if (item.patentReason) parts.push(`专利:${item.patentReason}`)
|
||||
return parts.join('\n')
|
||||
}
|
||||
Reference in New Issue
Block a user