fix(jd): 京东数据库摘除公司 tab(2026-11-16 用户定案「删除掉公司 tab 参考品牌数据库」=品牌库 2026-10-06 先例同形:摘的不只是 tab)——前端 admin_jd_database 退出 COMPANY_SCOPED_PAGES 注册表(定案注释+「公司维度不得回流」SHARED 清单钉住)+routes companyScoped:false+页面卸 companyTab watch 与两处 companyId 发送口(列表 params/类目下拉 fetchJdProductCategories 无参化,JdProductAssignPane 取数同形);后端读侧同窗摘:XML productConds 与 selectProductCategories 的公司维谓词删除(行 company_id 列保留=同步来源标记,JdSchemaContractTest 契约不动)、JdProductMapper.countProducts/selectProductPage 8 参、selectProductCategories() 无参、JdProductQueryService.page 10 参+Filter 去 companyId、AdminJdProductController.page 10 参数+categories(request) 去 superAdminScopedCompanyId 与 DataReadScope 注入、JdCollectController.categories() 调用方同步。判据:vue-tsc rc=0;node --test 9 文件 56/56(wiring SEND_POINTS 27→25、分组 21→19、watch 分母 12→11;menu-route 钉 companyScoped=false;jd-page 钉退出注册表);vitest mount 28/28(删「切公司 Tab 重取」用例,companyId 发送口全改 not.toHaveProperty);mvn -o test-compile rc=0;mvn -o test jd 模块全绿(AdminJdProductControllerTest 20/20:结构判据改「读侧零公司维度_公司tab口径整批摘除」反向钉 company_id/superAdminScopedCompanyId/DataReadScope 不得回潜,行为样本改 requireJdAccess 正门装 200 信封)

This commit is contained in:
2026-11-16 12:05:18 +08:00
parent 3bccc97698
commit 7b853a605e
16 changed files with 240 additions and 295 deletions
@@ -63,9 +63,9 @@ export const COMPANY_SCOPED_PAGES: readonly CompanyScopedPage[] = [
// 外观专利无侵权数据(2026-11-10 v1.3):出表成功自动同步的只读明细,归属物化在行 company_id 列
// (V189,同店铺密钥形状)⇒ 后端正门 readCompanyIdOrOwn(超管显式传才收窄,非超管强制本公司)。
{ menuKey: 'admin_appearance_patent_clean_items', apiFiles: ['src/pages/patent/appearance-patent-clean-api.ts'], pageFiles: ['src/pages/patent/AppearancePatentCleanItemsPage.vue'] },
// 京东数据库(2026-11-14 v1.4;2026-11-15 公共化改口径):京麦店铺商品采集落库的只读镜像,
// 行 company_id 只剩"哪家公司客户端同步的"来源标记。数据公共(用户定案「不区分公司、属于
// 公共的」):详情/编辑/删除/分组管理不带公司维度;留在注册表里的理由是超管的公司 tab 筛选
// (=筛选管理员)仍作用于只读列表与类目下拉两个发送口,非超管没有这个筛选、看同一份全量。
{ menuKey: 'admin_jd_database', apiFiles: ['src/pages/jd/jd-product-api.ts'], pageFiles: ['src/pages/jd/JdDatabasePage.vue'] },
// 京东数据库(2026-11-14 v1.4)已于 2026-11-16 退出注册表(用户定案「删除掉公司 tab,参考品牌
// 数据库」=品牌库 2026-10-06 先例同形):数据全平台公共(行 company_id 只剩"哪家公司客户端
// 同步的"来源标记),摘的不只是 tab——页面/api 的 company_id 发送口与后端读侧 company_id 谓词
// (superAdminScopedCompanyId)同窗一起摘。反向钉在 tests/company-tab-wiring.test.ts 的
// 「公司维度不得回流」清单里,再加回来必须先推翻这条定案。
]
@@ -3,7 +3,10 @@
* 公共的」,分类同亚马逊口径全平台一份),筛选行(商品编码/标题关键字/分类/分类状态/
* 类目/同步起止 date 对)+查询/重置/店铺分类 + 自绘明细表(勾选列+点行开详情抽屉)
* + 删除(单行/批量,先删桶对象、全成功才删库行,确认弹窗点名数量)+ OldPagination。
* 公司维度只剩超管的公司 tab(=筛选管理员,非超管没有这个筛选、看到同一份公共全量);
* 公司维度 2026-11-16 整页摘除(用户定案「删除掉公司 tab,参考品牌数据库」=品牌库
* 2026-10-06 先例同形):页面不再消费公司 tab store、列表/类目下拉不再下传 company_id
* (后端读侧 company_id 谓词同窗摘,行 company_id 列仍作同步来源标记留在详情里);
* 每个管理员看到同一份公共全量。反向钉在 company-tab-wiring「公司维度不得回流」清单。
* 列表按京麦商品列表样式(2026-11-15 用户口径):分类前置为第 1 列;商品信息列=京麦同款
* 合并布局(主图+图下信息分+标题两行+商品编码/货号+SKU 数标签,编码带一键复制);类目/上架
* 时间/京东创建/修改时间仍收详情抽屉基本信息(B104「详情显示全部属性」口径不变)。
@@ -18,11 +21,11 @@
* 下线(jd_created_at/jd_updated_at 仍收详情抽屉),列表时间列只剩同步时间收尾;
* ⑤ 工具栏加「移除分类」批量按钮(batch-assign-group 的 groupId=null 口径,勾选里只算已分类行)。
* 骨架像素复刻「外观专利数据库」页(panel-box + LoadFailureBar + 自绘 table + 旧式分页);
* 超管切公司 tab = 清筛选重取(watch 体照外观专利页逐字形状);日期对护栏:起侧 max=止侧、
* 止侧 min=起侧、两侧 @change 用 orderedPair 把倒挂交换回来(clampJdSyncedRange 照 clampDatePair)。
* 日期对护栏:起侧 max=止侧、止侧 min=起侧、两侧 @change 用 orderedPair 把倒挂交换回来
* (clampJdSyncedRange 照 clampDatePair)。
* 日期初值故意留空:同步数据是累计集,默认当天会让首屏只剩今天同步的行
* (date-filter-default-today 护栏 EXEMPT 口径,外观专利页同款)。 */
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { computed, onMounted, reactive, ref } from 'vue'
import {
batchAssignJdProductGroup,
deleteJdProducts,
@@ -41,15 +44,12 @@ import JdProductEditDrawer from './JdProductEditDrawer.vue'
import JdProductGroupDialog from './JdProductGroupDialog.vue'
import JdCategoryCascader from './JdCategoryCascader.vue'
import OldPagination from '@/components/OldPagination.vue'
import { useCompanyTabStore } from '@/stores/company-tab'
import { showAdminFeedback } from '@/components/admin-feedback-ui'
import { openAdminConfirm } from '@/components/admin-confirm'
import { loadFailureMessage } from '@/components/load-failure-model'
import LoadFailureBar from '@/components/LoadFailureBar.vue'
import { formatDateTime, orderedPair } from '@/utils/datetime'
const companyTab = useCompanyTabStore()
const loading = ref(false)
const loadFailure = ref('')
const rows = ref<JdProductItem[]>([])
@@ -60,8 +60,7 @@ const filter = reactive(createJdProductFilterState())
/** 分组下拉选项:分组全平台一份(公共),进页取一次即可;选项失败不拦列表,只回空下拉
* (可见「全部分组」)。 */
const groupOptions = ref<JdProductGroup[]>([])
/** 类目下拉选项(京麦末级类目):与当前行集同源(超管切公司 tab 时按 tab 收窄重取、
* 普通行集全量);失败静默回空。 */
/** 类目下拉选项(京麦末级类目):与当前行集同源(公共库全量);失败静默回空。 */
const categoryOptions = ref<JdProductCategoryOption[]>([])
/** 分组管理弹窗与详情抽屉。 */
const groupDialogVisible = ref(false)
@@ -108,7 +107,7 @@ async function loadGroupOptions(): Promise<void> {
/** 类目选项同分组口径:失败静默回空下拉(可见「全部类目」),不拦首屏行集。 */
async function loadCategoryOptions(): Promise<void> {
try {
categoryOptions.value = await fetchJdProductCategories(companyTab.requestCompanyId)
categoryOptions.value = await fetchJdProductCategories()
} catch {
categoryOptions.value = []
}
@@ -135,7 +134,6 @@ async function load(): Promise<void> {
groupScope: filter.groupScope,
syncedFrom: filter.syncedFrom,
syncedTo: filter.syncedTo,
companyId: companyTab.requestCompanyId,
})
rows.value = result.items
total.value = result.total
@@ -204,7 +202,7 @@ async function copyText(text: string): Promise<void> {
// ---------------- 删除(先删桶、全成功才删库行,语义在后端 JdProductDeleteService) ----------------
/** 本页勾选集(按行 id)。切页/切公司/重取后勾选清空——上一页勾的行不自动带到下一页。 */
/** 本页勾选集(按行 id)。切页/重取后勾选清空——上一页勾的行不自动带到下一页。 */
const selectedIds = ref<Set<number>>(new Set())
const deleting = ref(false)
@@ -278,11 +276,6 @@ async function removeSelectedGroup(): Promise<void> {
}
}
// 超管切公司 tab = 重新取数:编码/关键字/类目/日期是按行集筛的自由值,在另一家的
// 行集里筛不出东西,必须一起清(分组与分类状态全平台一份,groupId/groupScope 与公司维度
// 正交、不清);类目选项与行集同源,按新 tab 重取;分组选项是全局的、进页取一次即可。
watch(() => companyTab.activeId, () => { filter.productCode = ''; filter.titleKeyword = ''; filter.category = ''; filter.syncedFrom = ''; filter.syncedTo = ''; page.value = 1; void loadCategoryOptions(); void load() })
onMounted(() => {
void loadGroupOptions()
void loadCategoryOptions()
@@ -4,8 +4,8 @@
* +勾选行 →「归入所选分类」/「移出分类」。归类走批量端点
* POST /api/admin/jd-products/batch-assign-group:后端与单行编辑同口径置 manual_locked=1
* (归类即人工干预,采集 upsert/覆盖清理不再碰该行,分类永不丢;代价是该行价格/库存随锁
* 停更——弹窗提示语点名这个后果)。取数复用 fetchJdProductList(不带公司维度,
* company-tab-wiring 只认两个公司维度发送口);「未分类」走 ungrouped 参数。
* 停更——弹窗提示语点名这个后果)。取数复用 fetchJdProductList(不带公司维度,全平台一份);
* 「未分类」走 ungrouped 参数。
* 归类目标(selectedGroup)由左栏(父件)点亮下发;弹窗壳 v-if 整树重建 ⇒ 每次打开即本件
* 重挂载、onMounted 自取首屏行集。成功后 emit('changed') 让父件刷新分类商品数并上抛页面;
* 业务失败把后端中文文案展示在本面板红条内。 */
@@ -54,7 +54,6 @@ async function loadProducts(): Promise<void> {
titleKeyword: keyword.value.trim(),
groupId: scope.value === 'current' && props.selectedGroup ? String(props.selectedGroup.id) : '',
ungrouped: scope.value === 'ungrouped',
companyId: null,
})
products.value = result.items
productTotal.value = result.total
@@ -1,10 +1,10 @@
/** 京东数据库查询适配(v1.4 Phase 5):GET /api/admin/jd-products + 删除(DELETE /{id} +
* POST /batch-delete)+ 分组端点 /api/admin/jd-product-groups。
* 公司口径(2026-11-15 用户定案「京东数据库不区分公司、属于公共的」):公共库只有两个
* 公司维度出口——只读列表与类目下拉把公司 tab 的值下传(仅超管生效=筛选管理员);
* 详情/编辑/删除/分组管理全平台一份,不收 company_id(后端写侧也没有公司维度)。
* 取值口形状由 company-tab-wiring 护栏钉住。导出发送口已随 2026-11-15 客户口径
* 「导出也不用」从前端下线(后端 /export 端点保留)。 */
* 公司口径(2026-11-16 用户定案「删除掉公司 tab,参考品牌数据库」):全页零公司维度——
* 只读列表与类目下拉的 company_id 发送口已随公司 tab 摘除(后端读侧谓词同窗撤,重上时
* 从 git 历史找回),详情/编辑/删除/分组管理本就不带;行 company_id 列仍是同步来源标记、
* 随详情下发。反向钉在 company-tab-wiring「公司维度不得回流」清单。
* 导出发送口已随 2026-11-15 客户口径「导出也不用」从前端下线(后端 /export 端点保留)。 */
import { http } from '@/api/http'
import { errorTextOf, unwrap } from '../../api/envelope.ts'
import {
@@ -36,8 +36,7 @@ export async function fetchJdProductList(
params.page,
params.pageSize,
)
if (params.companyId != null) query.company_id = params.companyId
// 未分类范围(店铺分类弹窗「未分类」页签):与 company_id 一样由发送口直传,构造器不认识它。
// 未分类范围(店铺分类弹窗「未分类」页签):由发送口直传,构造器不认识它。
if (params.ungrouped) query.ungrouped = true
const { data } = await http.get<unknown>(JD_PRODUCT_ENDPOINT, { params: query })
return parseJdProductPage(data)
@@ -189,12 +188,8 @@ export interface JdProductCategoryOption {
productCount: number
}
export async function fetchJdProductCategories(
companyId: number | null,
): Promise<JdProductCategoryOption[]> {
const query: Record<string, number> = {}
if (companyId != null) query.company_id = companyId
const { data } = await http.get<unknown>(`${JD_PRODUCT_ENDPOINT}/categories`, { params: query })
export async function fetchJdProductCategories(): Promise<JdProductCategoryOption[]> {
const { data } = await http.get<unknown>(`${JD_PRODUCT_ENDPOINT}/categories`)
const core = unwrap<unknown>(data)
if (!Array.isArray(core)) return []
const out: JdProductCategoryOption[] = []
@@ -9,8 +9,8 @@
* 后端 `sale_status` 参数与 `/export` 端点保留(无 UI 入口),重上时从 git 历史找回取值口。
* 分页钳制(铁律 15):page < 1 归 1、上限 10_000(后端 CR-18 同值),(page-1)*page_size
* 最大 999_900,Number.MAX_SAFE_INTEGER 也不会把乘积顶出安全整数。纯逻辑,node --test 直测。
* 公司维不在这里:归一化构造器不认识 company_id(同外观专利 filter 惯例),由 api 发送口从
* 原始入参自己下传——取值口由 company-tab-wiring 护栏的发送行钉看守。
* 公司维已整页摘除(2026-11-16 用户定案「删除掉公司 tab,参考品牌数据库」):归一化构造器
* 与入参类型都不认识 company_id——读侧发送口已随公司 tab 撤下(品牌库 2026-10-06 先例同形)。
* 日期默认空字符串:同步台账是累计数据,默认当天会让首屏只剩今天同步的行
* (date-filter-default-today 护栏 EXEMPT 口径,外观专利页同款)。 */
import { validIsoDateOrUndefined } from '../asin/asin-filter.ts'
@@ -70,11 +70,9 @@ export interface JdProductQuery {
grouped?: boolean
synced_from?: string
synced_to?: string
/** 公司 tab:白名单构造不点名它,字段只为 api 发送口的 `query.company_id = params.companyId` 存在。 */
company_id?: number
}
/** api 模块的入参:筛选态 + 分页 + 公司值(camel)。 */
/** api 模块的入参:筛选态 + 分页(公共库无公司维度)。 */
export interface JdProductListParams {
page: number
pageSize: number
@@ -88,7 +86,6 @@ export interface JdProductListParams {
ungrouped?: boolean
syncedFrom?: string
syncedTo?: string
companyId?: number | null
}
/** 过滤态 → 过滤面参数(snake_case,仅下发非空字段)。 */
+2 -1
View File
@@ -45,7 +45,8 @@ export const adminPages: AdminPageDef[] = [
{ path: 'asin-center/categories', menuKey: 'admin_product_categories', title: '商品类目', companyScoped: false, load: () => import('@/pages/asin/ProductCategoryPage.vue') },
{ path: 'asin-center/skip-price', menuKey: 'admin_skip_price_asin', title: '最低价ASIN', companyScoped: true, load: () => import('@/pages/asin/SkipPricePage.vue') },
{ path: 'patent-center/clean-items', menuKey: 'admin_appearance_patent_clean_items', title: '外观专利数据库', companyScoped: true, load: () => import('@/pages/patent/AppearancePatentCleanItemsPage.vue') },
{ path: 'jd-center/database', menuKey: 'admin_jd_database', title: '京东数据库', companyScoped: true, load: () => import('@/pages/jd/JdDatabasePage.vue') },
// 京东数据库 2026-11-16 退出公司 tab(参考品牌数据库先例):数据全平台公共,不按公司取数。
{ path: 'jd-center/database', menuKey: 'admin_jd_database', title: '京东数据库', companyScoped: false, load: () => import('@/pages/jd/JdDatabasePage.vue') },
]
export function routeOf(page: AdminPageDef): RouteRecordRaw {
@@ -111,7 +111,10 @@ test('V196 新增的京东数据库菜单 key 必须在路由注册表登记', (
assert.ok(page, 'routes.ts 必须有 admin_jd_database 页面,否则菜单点进去 404')
assert.equal(page.path, menu.routePath, '库里的 route_path 应与注册表路径一致')
assert.equal(page.title, menu.name, '页面标题应与菜单名一致')
assert.equal(page.companyScoped, true, '京东数据库按公司 tab 取数')
// 2026-11-16 用户定案「删除掉公司 tab,参考品牌数据库」:数据全平台公共(行 company_id
// 只剩同步来源标记),页面退出公司 tab 注册表、取数口不带 company_id ⇒ meta 必须 false
// (true 会画出 tab 而取数不带参=点了没反应;同品牌数据库 admin_invalid_asin_data 的形状)。
assert.equal(page.companyScoped, false, '京东数据库全平台公共,不画公司 tab(V196 当时的按公司隔离口径已被推翻)')
// 每公司一套树(公司 1 模板行 + 其余公司复制),挂数据管理组、排序 68(V190 外观专利占 67)。
assert.ok(sql.includes("grp.`column_key` = 'admin_group_data'"), 'V196 必须把京东数据库挂到数据管理组')
@@ -77,6 +77,7 @@ function escapeRegExp(text: string): string {
* + 批次 6(控制方 2026-10-06 点名「菜单权限也加字段来区分」)3 处:菜单目录 / 新建菜单 / 用户管理里的授权树
* + 批次 7(2026-11-10 v1.3 外观专利无侵权数据)2 处:只读列表 + 导出(2026-11-11 客户需求「数据得导出来」)。
* 批次 2 原 12 处里的品牌库 1 处 + 商品类目 4 处,随 2026-10-06「这两页退回全平台共享」一并摘掉。
* 批次 8 原 2 处(京东数据库列表/类目)随 2026-11-16「删除掉公司 tab,参考品牌数据库」一并摘掉。
*
* <p>`window` 的取法:本轮实扫的 own(到自己那行的距离)+ ≥150 余量,且当同文件还有下一个同名发送口时必须
* `window < next`。own/next 不写死在这里——下面「窗口与真文件对平」那条用例逐处从真文件重算,
@@ -132,15 +133,9 @@ const SEND_POINTS: ReadonlyArray<SendPoint> = [
// 500 够得着自己、够不到隔壁(对平用例逐处从真文件重算,注释过期即红)。
{ menuKey: 'admin_appearance_patent_clean_items', file: 'src/pages/patent/appearance-patent-clean-api.ts', fn: 'fetchAppearancePatentCleanList', line: 'if (params.companyId != null) query.company_id = params.companyId', window: 500, title: 'GET /appearance-patent-clean-items 无侵权只读列表' },
{ menuKey: 'admin_appearance_patent_clean_items', file: 'src/pages/patent/appearance-patent-clean-api.ts', fn: 'exportAppearancePatentCleanList', line: 'if (params.companyId != null) query.company_id = params.companyId', window: 500, title: 'GET /appearance-patent-clean-items/export 导出(2026-11-11 客户需求「数据得导出来」,与列表共用同一过滤面)' },
// ↓ 批次 8(2026-11-14 v1.4 京东数据库;2026-11-15 公共化改口径):京麦店铺商品采集落库的
// 只读镜像,行 company_id 只剩"哪家公司客户端同步的"来源标记。2026-11-15 用户定案
// 「京东数据库不区分公司、属于公共的」「分组和亚马逊功能一样」⇒ 详情/编辑/删除/分组管理
// 的 6 个 company_id 发送口整批撤下(后端写侧同窗摘掉公司谓词,重上时从 git 历史找回);
// 留下的两个公司维度出口=只读列表与类目下拉(仅超管生效=筛选管理员,普通管理员没有
// 这个筛选)。导出发送口已随 2026-11-15 客户口径「导出也不用」从前端下线(后端 /export
// 端点保留,前端发送口撤,重上时从 git 历史找回发送行再登记——同批次 7 主管两口的先例)。
{ menuKey: 'admin_jd_database', file: 'src/pages/jd/jd-product-api.ts', fn: 'fetchJdProductList', line: 'if (params.companyId != null) query.company_id = params.companyId', window: 500, title: 'GET /jd-products 京东数据库只读列表(超管公司 tab 筛选=筛选管理员)' },
{ menuKey: 'admin_jd_database', file: 'src/pages/jd/jd-product-api.ts', fn: 'fetchJdProductCategories', line: 'if (companyId != null) query.company_id = companyId', window: 500, title: 'GET /jd-products/categories 类目下拉(选项集与超管当前 tab 行集同源)' },
// 批次 8(2026-11-14 v1.4 京东数据库)的两条发送口(列表/类目下拉)已于 2026-11-16 随
// 「删除掉公司 tab,参考品牌数据库」整批摘下(后端读侧谓词同窗撤,重上时从 git 历史找回);
// 「不得回流」由文件末尾「公司维度不得回流」清单看守(admin_jd_database 已入列)。
]
/** 任务看板那 5 处(1b ④ 那条用例按文件筛它们,沿用旧名字不漂;表只有一份,不会漂出两个口径)。 */
@@ -264,8 +259,8 @@ const COMPANY_ID_SOURCE_PINS: Readonly<Record<string, readonly CompanyIdPin[]>>
admin_columns: pinsFor('admin_columns'),
// 批次 7(v1.3 无侵权只读页):同样由 SEND_POINTS 现算——只有一个发送口(列表)。
admin_appearance_patent_clean_items: pinsFor('admin_appearance_patent_clean_items'),
// 批次 8(v1.4 京东数据库):列表一口(导出发送口 2026-11-15 随客户口径下线),由 SEND_POINTS 现算。
admin_jd_database: pinsFor('admin_jd_database'),
// 批次 8(v1.4 京东数据库)2026-11-16 随「删除掉公司 tab」整页摘除:登记表条目一并撤下,
// 「不得回流」改由文件末尾「公司维度不得回流」清单看守(同品牌库/商品类目的先例形状)。
}
/** 严格判据的分母由本轮实扫得出(修完不许恒绿也不许恒红):求值了几条 shape、其中几条通过。 */
@@ -366,9 +361,11 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
// 这条只防"整表被摘空/被改窄",逐处脱管由下面两条(对平闸门 + 窗口对平)负责。
// 2026-11-15 京东数据库公共化(用户定案「不区分公司、属于公共的」):批次 8 的详情/删除/
// 分组列表/删分组/编辑 5 条 company_id 发送口随公司谓词整批撤下(后端写侧同窗摘),批次 8
// 只剩列表/类目两条(超管筛选管理员)⇒ 32 → 27。
assert.ok(SEND_POINTS.length >= 27,
`发送口表只剩 ${SEND_POINTS.length} 条(批次 1+2+3+4+5+6 实扫 21 条 + 批次 7 v1.3 无侵权列表/导出 2 条 + 主管聚合 1 条 + 按主管删除 1 条 + 批次 8 v1.4 京东数据库列表/类目 2 条(详情/删除/分组/删分组/编辑 5 口随 2026-11-15 公共化撤、导出口随客户口径下线)= 27 条)⇒ 有人把钉从表里摘了,取值口看守成空`)
// 只剩列表/类目两条 ⇒ 32 → 27。
// 2026-11-16 京东数据库摘公司 tab(用户定案「删除掉公司 tab,参考品牌数据库」):最后两条
// 发送口(列表/类目下拉)与后端读侧谓词同窗摘掉,页面退出注册表 ⇒ 27 → 25。
assert.ok(SEND_POINTS.length >= 25,
`发送口表只剩 ${SEND_POINTS.length} 条(批次 1+2+3+4+5+6 实扫 21 条 + 批次 7 v1.3 无侵权列表/导出 2 条 + 主管聚合 1 条 + 按主管删除 1 条 = 25 条;京东数据库两条 2026-11-16 随「删除掉公司 tab」摘、导出口 2026-11-15 随客户口径摘)⇒ 有人把钉从表里摘了,取值口看守成空`)
for (const p of SEND_POINTS) {
const shape = pointShape(p)
const compliant = pointCompliant(p)
@@ -400,8 +397,8 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
if (hit) hit.pinned += 1
else grouped.set(key, { file: p.file, line: p.line, pinned: 1 })
}
assert.equal(grouped.size, 21,
`发送口表按 (文件, 整行) 应聚成 21 组(32 处发送口,批次 7 的列表/导出/主管聚合/按主管删除、批次 8 的京东详情/删除/分组/类目/删分组/编辑逐字同行各走同一组;京东导出口 2026-11-15 随客户口径下线),现在却有 ${grouped.size} 组 —— 表被改形状了,对平判据失去分母`)
assert.equal(grouped.size, 19,
`发送口表按 (文件, 整行) 应聚成 19 组(25 处发送口,批次 7 的列表/导出/主管聚合/按主管删除逐字同行各走同一组;京东数据库两组 2026-11-16 随「删除掉公司 tab」摘),现在却有 ${grouped.size} 组 —— 表被改形状了,对平判据失去分母`)
for (const g of grouped.values()) {
const actual = occurrences(stripComments(read(g.file)), g.line)
assert.equal(g.pinned, actual,
@@ -757,21 +754,9 @@ const WATCH_BODY_PINS: ReadonlyArray<{
{ file: 'src/pages/patent/appearance-patent-clean-api.ts', shapes: [/company_id\s*=\s*params\.companyId\b/] },
],
},
// ↓ 批次 8(2026-11-14 v1.4 京东数据库;2026-11-15 公共化改口径):商品编码/标题是
// 按行集筛的自由文本,类目选项集与超管当前 tab 的行集同源 ⇒ 上一家的筛选值与 category
// 在新一家的行集/选项集里不存在,切 tab 必清且类目选项重取;页码回 1 同外观专利页。
// 分组 2026-11-15 起全平台一份(公共),groupId 与公司维度正交——不清、选项也不随 tab 重取。
// 店铺筛选 2026-11-15 客户口径「店铺不需要」下线(watch 体不再清 shopName,参数面无它)。
{
file: 'src/pages/jd/JdDatabasePage.vue',
token: "filter.productCode = ''; filter.titleKeyword = ''; filter.category = ''; filter.syncedFrom = ''; filter.syncedTo = ''; page.value = 1; void loadCategoryOptions(); void load()",
why: '商品编码/标题是按行集筛的自由文本,上一家的值在新一家的行里不存在 ⇒ 切 tab 后首屏被筛成「暂无商品」,'
+ '而输入框还显示着上一家填的值;类目选项集与超管当前 tab 的行集同源,上一家选的 category 在新一家的选项里不存在,'
+ '同罪必清且选项重取;页码回 1 是因为新一家的行数更少,末尾的 void load() 才让切 tab 真的换数据',
premise: [
{ file: 'src/pages/jd/jd-product-api.ts', shapes: [/company_id\s*=\s*params\.companyId\b/] },
],
},
// 批次 8(2026-11-14 v1.4 京东数据库页)那条 watch 看守已于 2026-11-16 随「删除掉公司 tab,
// 参考品牌数据库」一并摘下——页面不再 watch companyTab.activeId、不再消费公司 tab store,
// 「不得回流」改由文件末尾「公司维度不得回流」清单看守。
]
/** 取「`watch(() => companyTab.activeId, () => { … })`」这一条语句的原文;匹配不出返回 null(由调用方判探针失效)。 */
@@ -780,9 +765,9 @@ function watchStatement(source: string): string | null {
return m ? m[0] : null
}
test('切公司的 watch 体:每对 (file, token) 都要在该页 watch 体内出现(批次 1 两页 + 批次 2 三页 + 批次 3 两页 + 批次 4 一页 + 批次 5 一页 + 批次 6 一页 + 批次 7 一页 + 批次 8 一页)', () => {
test('切公司的 watch 体:每对 (file, token) 都要在该页 watch 体内出现(批次 1 两页 + 批次 2 三页 + 批次 3 两页 + 批次 4 一页 + 批次 5 一页 + 批次 6 一页 + 批次 7 一页)', () => {
assert.ok(WATCH_BODY_PINS.length >= 11,
`watch 体看守只剩 ${WATCH_BODY_PINS.length} 对(批次 1 的店铺管理/任务看板 + 批次 2 的去重库/查询ASIN/最低价ASIN + 批次 3 的撞款监控/店铺数据记录 + 批次 4 的用户管理 + 批次 5 的店铺密钥 + 批次 6 的菜单管理 + 批次 7 v1.3 无侵权只读页 + 批次 8 v1.4 京东数据库页共 12 对)`
`watch 体看守只剩 ${WATCH_BODY_PINS.length} 对(批次 1 的店铺管理/任务看板 + 批次 2 的去重库/查询ASIN/最低价ASIN + 批次 3 的撞款监控/店铺数据记录 + 批次 4 的用户管理 + 批次 5 的店铺密钥 + 批次 6 的菜单管理 + 批次 7 v1.3 无侵权只读页共 11 对;批次 8 京东数据库页那条 2026-11-16 随「删除掉公司 tab」摘下)`
+ '⇒ 这一族又退回"只钉少数几页",被摘掉那一页的"切公司不清筛选项"再次没人看守')
const pinnedFiles = new Set(WATCH_BODY_PINS.map((pin) => pin.file))
for (const pin of WATCH_BODY_PINS) {
@@ -984,26 +969,30 @@ test('渲染范围:tab 条只画在按公司取数的页上,公司管理那
})
/**
* 2026-10-06 控制方定案:品牌数据库、商品类目「做成所有公司共享的,不区分」。
* 控制方/用户定案的「全平台共享、不区分公司」页清单:
* - 品牌数据库、商品类目(2026-10-06 控制方定案「做成所有公司共享的,不区分」);
* - 京东数据库(2026-11-16 用户定案「删除掉公司 tab,参考品牌数据库」)。
*
* <p>上面那几条正向判据全是从 {@code COMPANY_SCOPED_PAGES} 派生的,页一退出注册表就自动不再求值 ⇒
* 「退出」这件事本身没有看守:谁把 {@code company_id} 重新塞回这三个取数口,全仓用例一支都不会红,
* 而后端唯一键已经退回全局(V151),带公司参数的读会把共享库筛窄成「只看这一家」,
* 「退出」这件事本身没有看守:谁把 {@code company_id} 重新塞回这些取数口,全仓用例一支都不会红,
* 而后端唯一键已经退回全局(V151)/读侧谓词已摘(京东),带公司参数的读会把共享库筛窄成「只看这一家」,
* 写侧则把一张全平台共享的表按家拆开——两边都是静默改口径,不是报错。所以这一支必须存在。</p>
*
* <p>判据只认「剥完注释的代码」:这三份文件现在各自留有一句说明共享口径的注释,
* 注释里的 {@code company_id} 三个字面字符不是接线(全局约束 6)。正样本用摘掉之前那三行原文,
* <p>判据只认「剥完注释的代码」:这些文件各自留有一句说明共享口径的注释,
* 注释里的 {@code company_id} 三个字面字符不是接线(全局约束 6)。正样本用摘掉之前那些行原文,
* 所以下面的 false 是测出来的,不是「正则本来就抓不到」。</p>
*/
const SHARED_PAGE_KEYS = ['admin_invalid_asin_data', 'admin_product_categories'] as const
const SHARED_PAGE_KEYS = ['admin_invalid_asin_data', 'admin_product_categories', 'admin_jd_database'] as const
const SHARED_API_FILES = [
'src/pages/invalidasin/invalid-asin-api.ts',
'src/pages/asin/product-category-api.ts',
'src/pages/asin/product-category-export.ts',
'src/pages/jd/jd-product-api.ts',
] as const
const SHARED_PAGE_FILES = [
'src/pages/asin/AsinInvalidPage.vue',
'src/pages/asin/ProductCategoryPage.vue',
'src/pages/jd/JdDatabasePage.vue',
] as const
/** 公司参数的两种写法:下传用的 snake、形参/字段用的 camel。 */
@@ -1016,7 +1005,7 @@ const FORMER_SEND_LINES = [
'if (companyId != null) params.push(`company_id=${companyId}`)',
]
test('公司维度不得回流:品牌库与商品类目已定案全平台共享,取数口与页面都不许再带公司参数', () => {
test('公司维度不得回流:品牌库/商品类目/京东数据库已定案全平台共享,取数口与页面都不许再带公司参数', () => {
// 判据自证(全局约束 15:反向钉不许独自成立)——改动前那三行必须抓得到,否则下面的 false 是空判据。
for (const line of FORMER_SEND_LINES) {
assert.ok(COMPANY_PARAM_TOKEN.test(line), `反向钉判据连原来的发送口「${line}」都匹配不出 ⇒ 这一族恒绿`)
@@ -1031,7 +1020,7 @@ test('公司维度不得回流:品牌库与商品类目已定案全平台共
for (const key of SHARED_PAGE_KEYS) {
assert.equal(COMPANY_SCOPED_PAGES.some((p) => p.menuKey === key), false,
`${key} 又回到 COMPANY_SCOPED_PAGES:2026-10-06 已定案这两页全平台共享,不区分公司`)
`${key} 又回到 COMPANY_SCOPED_PAGES:已定案全平台共享、不区分公司(品牌库/商品类目 2026-10-06、京东数据库 2026-11-16)`)
const page = adminPages.find((p) => p.menuKey === key)
assert.ok(page, `${key} 在路由注册表里找不到:菜单名改了,反向钉对不上页`)
assert.equal(page.companyScoped, false,
@@ -22,12 +22,14 @@ import {
const MENU_KEY = 'admin_jd_database'
const ROUTE = 'jd-center/database'
test('routes 注册表出现京东数据库页面且公司隔离', () => {
test('routes 注册表出现京东数据库页面且退出公司 tab(2026-11-16 参考品牌数据库定案)', () => {
const page = adminPages.find((item) => item.menuKey === MENU_KEY)
assert.ok(page, `routes.ts 缺 menuKey=${MENU_KEY} 的注册行`)
assert.equal(page.path, ROUTE, 'route_path 必须与 V196 菜单一侧一致')
assert.equal(page.title, '京东数据库', '菜单标题以「京东数据库」为准')
assert.equal(page.companyScoped, true, '京东数据库按公司隔离(AC-6)')
// 数据全平台公共(2026-11-15「不区分公司」→ 2026-11-16「删除掉公司 tab,参考品牌数据库」):
// meta.companyScoped 必须 false——true 会画出公司 tab,而取数口已不带 company_id(点了没反应)。
assert.equal(page.companyScoped, false, '京东数据库全平台公共,不画公司 tab(AC-6 已被 11-15/11-16 口径推翻)')
})
/** 详情面的 SKU 矩阵解析(V198):后端下发 camelCase,snake 容错;坏行不炸整块。 */
@@ -3,7 +3,8 @@
*
* 形态:panel-box + 筛选行(商品编码/标题关键字/分类/分类状态/类目/同步起止 date 对)+
* 查询/重置/店铺分类 + 自绘明细表(点行开详情抽屉)+ OldPagination;
* 公司 tab 切换=清筛选重取(company-tab-wiring 同口径)。
* 公司维度 2026-11-16 整页摘除(「删除掉公司 tab,参考品牌数据库」):页面不消费公司 tab
* store、列表/类目下拉不带 company_id(反向钉在 company-tab-wiring「公司维度不得回流」)。
* 商品状态筛选/列与导出按钮已随 2026-11-15 客户口径从前端下线(后端端点保留);
* 店铺筛选与店铺列同日客户口径「店铺不需要」下线(后端 shop_name 参数同窗撤,店铺仍收详情抽屉)。
* 不用 readFileSync(source-pin-ratchet 对台账外新文件带读点即红),全部走真实挂载断言。
@@ -17,7 +18,6 @@ import { createPinia, setActivePinia, type Pinia } from 'pinia'
import JdDatabasePage from '@/pages/jd/JdDatabasePage.vue'
import JdProductGroupDialog from '@/pages/jd/JdProductGroupDialog.vue'
import { useAdminSessionStore } from '@/stores/admin-session'
import { useCompanyTabStore } from '@/stores/company-tab'
const jdApi = vi.hoisted(() => ({
JD_PRODUCT_ENDPOINT: '/api/admin/jd-products',
@@ -79,7 +79,6 @@ beforeEach(() => {
pinia = createPinia()
setActivePinia(pinia)
useAdminSessionStore().user = { id: 1, username: 'root', role: 'super_admin' }
useCompanyTabStore().setActiveId(1)
jdApi.fetchJdProductGroups.mockResolvedValue([])
jdApi.fetchJdProductCategories.mockResolvedValue([])
confirmMock.mockResolvedValue(true)
@@ -94,13 +93,14 @@ async function mountWith(payload: unknown): Promise<VueWrapper<Element>> {
}
describe('京东数据库页(v1.4 Phase 5)', () => {
it('挂载后按首屏分页参数取列表(pageSize 默认 20、带公司 tab),行数=本页条数', async () => {
it('挂载后按首屏分页参数取列表(pageSize 默认 20、不带公司维度),行数=本页条数', async () => {
const wrapper = await mountWith({ items: [item(1), item(2), item(3)], total: 42, page: 1, pageSize: 20 })
expect(jdApi.fetchJdProductList).toHaveBeenCalledTimes(1)
const firstCall = jdApi.fetchJdProductList.mock.calls[0][0]
expect(firstCall.page).toBe(1)
expect(firstCall.pageSize).toBe(20)
expect(firstCall.companyId).toBe(1)
// 公司维度 2026-11-16 整页摘除:入参层不再有 companyId 键(单参 toHaveProperty 才是「键不存在」的真判据)。
expect(firstCall).not.toHaveProperty('companyId')
expect(wrapper.findAll('tbody tr')).toHaveLength(3)
expect(wrapper.find('.jd-summary').text()).toContain('共 42 条京东商品')
})
@@ -242,12 +242,12 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
syncedFrom: '2026-11-01',
syncedTo: '2026-11-09',
page: 1,
companyId: 1,
})
// 单参 toHaveProperty 才是「键不存在」的真判据(第二参会稀释成值断言):
// 页面 load() 入参已不带这两个键(店铺/商品状态筛选下线)。
// 页面 load() 入参已不带这三个键(店铺/商品状态筛选下线、公司维度 2026-11-16 摘除)。
expect(last).not.toHaveProperty('shopName')
expect(last).not.toHaveProperty('saleStatus')
expect(last).not.toHaveProperty('companyId')
})
it('分组下拉选中即查', async () => { jdApi.fetchJdProductGroups.mockResolvedValue([
@@ -269,13 +269,13 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ groupId: '7', page: 1 })
})
it('类目京麦同款级联面板:一/二级静态导航展开,第三栏=已落库末级全集+行数,点末级即查回第一页', async () => {
it('类目京麦同款级联面板(2026-11-16 真树重做):授权一级 3 个逐级下钻,点末级即查回第一页', async () => {
jdApi.fetchJdProductCategories.mockResolvedValue([
{ name: '艺考形体服', productCount: 120 },
{ name: '啦啦队服', productCount: 8 },
])
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
expect(jdApi.fetchJdProductCategories).toHaveBeenCalledWith(1)
expect(jdApi.fetchJdProductCategories).toHaveBeenCalledWith()
const trigger = wrapper.find('.cat-trigger')
expect(trigger.text()).toContain('全部类目', '未选时触发框显示占位「全部类目」')
@@ -283,58 +283,74 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
await trigger.trigger('click')
expect(wrapper.find('.cat-panel').exists()).toBe(true)
// 第一栏=静态一级导航(京麦同款顺序,服饰内衣在首)。
// 第一栏=京麦授权一级真树(2026-11-16 真机取证就 3 个:服饰内衣/母婴/运动户外)。
const firstCol = wrapper.findAll('.cat-col')[0]
expect(firstCol.text()).toContain('服饰内衣')
expect(firstCol.text()).toContain('母婴')
expect(firstCol.text()).toContain('运动户外')
// hover 一级展开第二栏(服饰内衣的静态二级=京麦面板样本同款)。
await firstCol.findAll('.cat-row')[0].trigger('mouseenter')
const cols = wrapper.findAll('.cat-col')
expect(cols).toHaveLength(3, '点亮有静态子级的一级后第二栏出现(第三栏常驻)')
// 点一级展开第二栏(非末级行点击=下钻)。
await firstCol.findAll('.cat-row').find((row) => row.text().includes('服饰内衣'))!.trigger('click')
let cols = wrapper.findAll('.cat-col')
expect(cols).toHaveLength(2, '点亮一级后第二栏出现(树内逐级下钻)')
expect(cols[1].text()).toContain('服饰配件')
expect(cols[1].text()).toContain('女装')
// 第三栏=已落库末级全集+行数(与二级不联动——采集链无层级归属,组件头注释如实声明)。
expect(cols[2].text()).toContain('艺考形体服')
expect(cols[2].text()).toContain('120')
expect(cols[2].text()).toContain('啦啦队服')
// 点二级展开第三栏(京麦同款三级末级,取证快照:服饰配件 13 个)。
await cols[1].findAll('.cat-row').find((row) => row.text().includes('服饰配件'))!.trigger('click')
cols = wrapper.findAll('.cat-col')
expect(cols).toHaveLength(3, '三级栏出现(末级行不再下钻)')
expect(cols[2].text()).toContain('腰带/腰链')
// 点末级=选中即查(等值过滤口径不变)、面板收起、触发框显示已选名。
const leafRows = cols[2].findAll('.cat-row')
await leafRows.find((row) => row.text().includes('啦啦队服'))!.trigger('click')
// 点末级=选中即查(按 category_path 等值过滤口径不变)、面板收起、触发框显示已选名。
await cols[2].findAll('.cat-row').find((row) => row.text().includes('腰带/腰链'))!.trigger('click')
await flushPromises()
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ category: '啦啦队服', page: 1 })
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ category: '腰带/腰链', page: 1 })
expect(wrapper.find('.cat-panel').exists()).toBe(false, '选中后面板收起')
expect(wrapper.find('.cat-trigger').text()).toContain('啦啦队服')
expect(wrapper.find('.cat-trigger').text()).toContain('腰带/腰链')
})
it('类目级联搜索与清选:搜索词过滤第三栏;「全部类目」行/触发框 × 都能清选重查', async () => {
it('类目级联搜索与清选(2026-11-16 真树重做):树内末级命中+树外兜底段;「全部类目」行/触发框 × 都能清选重查', async () => {
jdApi.fetchJdProductCategories.mockResolvedValue([
{ name: '艺考形体服', productCount: 120 },
{ name: '啦啦队服', productCount: 8 },
{ name: '已下架历史类目', productCount: 3 },
])
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
await wrapper.find('.cat-trigger').trigger('click')
const leafCol = wrapper.findAll('.cat-col').at(-1)!
await leafCol.find('.cat-search').setValue('艺考')
const visibleRows = leafCol.findAll('.cat-row').filter((row) => row.text().includes('艺考'))
expect(visibleRows).toHaveLength(1, '搜索词过滤后只剩匹配项')
expect(leafCol.text()).not.toContain('啦啦队服', '不匹配的末级被搜索词滤掉')
// 搜索态:树内末级按名称/路径命中(艺考形体服在树内=女装支末级)。
await wrapper.findAll('.cat-col')[0].find('.cat-search').setValue('艺考')
const searchCol = wrapper.find('.cat-col-search')
const visibleRows = searchCol.findAll('.cat-row')
expect(visibleRows).toHaveLength(1, '搜索「艺考」只命中树内末级「艺考形体服」')
expect(searchCol.text()).toContain('艺考形体服')
expect(searchCol.text()).not.toContain('已下架历史类目', '不匹配项不出现')
await visibleRows[0].trigger('click')
await flushPromises()
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ category: '艺考形体服', page: 1 })
// 清空搜索后点「全部类目」= 清选重查(category 入参回空串、query 层不下发,回第一页)。
await leafCol.find('.cat-search').setValue('')
// 树外兜底:已落库但京麦树里已没有的名字(历史行)从兜底段搜出可选。
await wrapper.find('.cat-trigger').trigger('click')
await wrapper.findAll('.cat-col')[0].find('.cat-search').setValue('已下架历史')
const fallbackCol = wrapper.find('.cat-col-search')
expect(fallbackCol.text()).toContain('已落库类目(树外历史)')
expect(fallbackCol.text()).toContain('已下架历史类目')
await fallbackCol.findAll('.cat-row').find((row) => row.text().includes('已下架历史类目'))!.trigger('click')
await flushPromises()
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ category: '已下架历史类目' })
// 点「全部类目」行=清选重查(category 入参回空串、query 层不下发,回第一页)。
await wrapper.find('.cat-trigger').trigger('click')
const callsBefore = jdApi.fetchJdProductList.mock.calls.length
await leafCol.find('.cat-row-all').trigger('click')
await wrapper.find('.cat-row-all').trigger('click')
await flushPromises()
expect(jdApi.fetchJdProductList.mock.calls.length).toBe(callsBefore + 1, '清选也要重查')
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0].category).toBe('')
// 触发框已选时出 × 清除按钮:点了同样清选。
await wrapper.find('.cat-trigger').trigger('click')
await wrapper.findAll('.cat-col').at(-1)!.findAll('.cat-row').find((row) => row.text().includes('啦啦队服'))!.trigger('click')
await wrapper.findAll('.cat-col')[0].find('.cat-search').setValue('艺考')
await wrapper.find('.cat-col-search').findAll('.cat-row')[0].trigger('click')
await flushPromises()
expect(wrapper.find('.cat-trigger').text()).toContain('啦啦队服')
expect(wrapper.find('.cat-trigger').text()).toContain('艺考形体服')
const callsBeforeClear = jdApi.fetchJdProductList.mock.calls.length
await wrapper.find('.cat-clear').trigger('click')
await flushPromises()
@@ -627,7 +643,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(jdApi.fetchJdProductGroups).toHaveBeenLastCalledWith()
// 右栏取数复用 fetchJdProductList:不带公司维度(公共库),默认「全部」范围不带 ungrouped=true。
const dialogCall = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(dialogCall.companyId).toBeNull()
expect(dialogCall).not.toHaveProperty('companyId')
expect(dialogCall.ungrouped).toBe(false)
// 模拟分类管理里删了一个分类:emit changed → 页面刷新分类下拉与列表(回第一页)
@@ -635,7 +651,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
await flushPromises()
await flushPromises()
expect(jdApi.fetchJdProductList.mock.calls.length).toBeGreaterThan(callsBefore)
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ page: 1, companyId: 1 })
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ page: 1 })
})
it('店铺分类弹窗:左侧点亮分类→勾选商品→「归入所选分类」按(ids, 目标分类 id)调批量归类', async () => {
@@ -688,7 +704,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
await wrapper.findAll('.scope-tabs button').find((b) => b.text() === '未分类')!.trigger('click')
await flushPromises()
expect(jdApi.fetchJdProductList.mock.calls.length).toBe(listCallsBefore + 1, '切「未分类」必须立刻重取')
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ ungrouped: true, companyId: null })
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ ungrouped: true })
await wrapper.findAll('tbody input[type="checkbox"]')[0].setValue(true)
jdApi.batchAssignJdProductGroup.mockResolvedValue(1)
@@ -698,34 +714,6 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(jdApi.batchAssignJdProductGroup).toHaveBeenCalledWith([1], null)
})
it('切公司 Tab 重取并清掉上一家的筛选(company-tab-wiring 同口径;分组公共不清)', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([{ id: 7, name: '甲组', sortOrder: 0, productCount: 3 }])
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
const textInputs = wrapper.findAll('.form-group input[type="text"]')
await textInputs[0].setValue('JD-1001')
await textInputs[1].setValue('保温杯')
await wrapper.find('select').setValue('7')
const callsBefore = jdApi.fetchJdProductList.mock.calls.length
useCompanyTabStore().setActiveId(2)
await flushPromises()
await flushPromises()
expect(jdApi.fetchJdProductList.mock.calls.length).toBeGreaterThan(callsBefore)
const last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(last.companyId).toBe(2)
expect(last.productCode).toBe('', '切公司必须清掉上一家的商品编码')
expect(last.titleKeyword).toBe('', '切公司必须清掉上一家的标题关键字')
expect(last.groupId).toBe('7', '分组全平台一份(公共),groupId 与公司维度正交——切 tab 不清')
expect(last.category).toBe('', '切公司必须清掉上一家选的类目(入参回空串、query 层不下发)')
expect(last).not.toHaveProperty('shopName', '店铺筛选已下线:页面入参层不再传该键')
expect(last.page).toBe(1)
// 分组选项是全局的:切 tab 不重取(首屏那一次之后就不再增长),且任何一次拉取都不带公司维度。
for (const call of jdApi.fetchJdProductGroups.mock.calls) {
expect(call).toEqual([], '分组选项是全局的,任何一次拉取都不带公司维度')
}
})
it('空态与加载失败条(失败给重试,不把整页打死)', async () => {
const empty = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
const tip = empty.find('.empty-tip')
@@ -6,7 +6,6 @@ import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.common.model.entity.AdminUserEntity;
import com.nanri.aiimage.common.security.AdminAuthSupport;
import com.nanri.aiimage.common.security.DeviceSessionPolicy;
import com.nanri.aiimage.common.service.DataReadScope;
import com.nanri.aiimage.modules.jd.model.dto.JdProductBatchAssignGroupRequest;
import com.nanri.aiimage.modules.jd.model.dto.JdProductBatchDeleteRequest;
import com.nanri.aiimage.modules.jd.model.dto.JdProductUpdateRequest;
@@ -60,13 +59,13 @@ import java.util.List;
* 非超管菜单权限(column_key/route_path 双匹配)。菜单行由 V196 只插 columns 不预授权
* ⇒ 默认仅 super_admin 可见可访问,其余角色由超管在权限页手工勾授后才放行。</p>
*
* <p><b>公司口径(2026-11-15 用户定案「京东数据库不区分公司、属于公共的」)</b>:行上的
* company_id 只剩「哪家公司客户端同步的」来源标记,不再构成可见性边界——读侧全公共;
* 唯一保留的公司维度是<b>站点超管</b>的公司 tab 筛选({@code superAdminScopedCompanyId}:
* 超管显式传 company_id 才收窄,非超管传什么都不收),也就是「管理员没有这个筛选、
* 超管可以筛选管理员」。详情与写侧(编辑/删除)没有公司维度:任何拿到本页菜单权限的
* 管理员对全部公共行可编辑可删除(同商品类目「谁都能改」的 2026-10-06 定案形状),
* 请求里的 company_id 传参已随公共化从写侧端点摘除。</p>
* <p><b>公司口径(2026-11-16 用户定案「删除掉公司 tab,参考品牌数据库」)</b>:读侧零公司
* 维度——company_id 请求参数与 {@code superAdminScopedCompanyId} 谓词已随公共化收尾整批
* 摘除(2026-11-15 定案「京东数据库不区分公司、属于公共的」的最后一截),行上的 company_id
* 只剩「哪家公司客户端同步的」来源标记,不构成可见性边界;每个拿到本页菜单权限的管理员
* (含站点超管)看到同一份全量公共库。详情与写侧(编辑/删除)同样没有公司维度:
* 对全部公共行可编辑可删除(同商品类目「谁都能改」的 2026-10-06 定案形状),写侧端点的
* company_id 传参已随 2026-11-15 公共化摘除。</p>
*
* <p>导出端点已随 2026-11-15 客户口径「导出也不用」整段下线(控制器/服务/mapper 参数一起删);
* {@code sale_status} 查询参数同窗撤掉(商品状态筛选框已从前端下线)。店铺筛选参数
@@ -77,7 +76,7 @@ import java.util.List;
@RequiredArgsConstructor
@Slf4j
@RequestMapping("/api/admin/jd-products")
@Tag(name = "京东数据库", description = "后管京东店铺商品库:分页查询、详情、编辑与删除。数据全平台公共,仅超管可按公司(同步来源)筛选。")
@Tag(name = "京东数据库", description = "后管京东店铺商品库:分页查询、详情、编辑与删除。数据全平台公共,无公司维度。")
public class AdminJdProductController {
private static final String COLUMN_KEY = "admin_jd_database";
@@ -88,11 +87,10 @@ public class AdminJdProductController {
private final JdProductUpdateService jdProductUpdateService;
private final AdminAuthSupport adminAuthSupport;
private final PermissionMenuService permissionMenuService;
private final DataReadScope dataReadScope;
@GetMapping
@Operation(summary = "分页查询京东数据库商品", description = "公共库分页查询同步落表的京东商品;"
+ "company_id 只对站点超管生效(显式传才收窄=按同步来源公司筛),非超管传什么都不收(全量)。")
+ "全平台公共、无公司维度(2026-11-16 摘公司 tab:公司维参数与超管筛选谓词已整批摘除)。")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "查询成功", content = @Content(schema = @Schema(implementation = JdProductPageVo.class)))
})
@@ -111,29 +109,19 @@ public class AdminJdProductController {
@RequestParam(name = "synced_from", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime syncedFrom,
@Parameter(description = "同步结束时间(包含,ISO datetime)")
@RequestParam(name = "synced_to", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime syncedTo,
@Parameter(description = "公司 ID") @RequestParam(name = "company_id", required = false) Long companyId,
HttpServletRequest request) {
RequestOperator operator = requireJdAccess(request);
AdminUserEntity user = operator.user();
// 公司维度只剩超管的公司 tab 筛选(superAdminScopedCompanyId):超管显式传才收窄,
// 非超管传什么都不收——公共库对每一家管理员都是同一份全量。
Long scopedCompanyId = dataReadScope.superAdminScopedCompanyId(user, companyId);
return ApiResponse.success(jdProductQueryService.page(page, pageSize, scopedCompanyId,
requireJdAccess(request);
return ApiResponse.success(jdProductQueryService.page(page, pageSize,
productCode, titleKeyword, category, groupId, ungrouped, grouped, syncedFrom, syncedTo));
}
@GetMapping("/categories")
@Operation(summary = "类目筛选下拉数据源", description = "已落库行 DISTINCT 的 category_path"
+ "(京麦末级类目名)+ 行数,按类目名排序;company_id 只对站点超管生效(显式传才收窄="
+ "选项集与超管当前公司 tab 的行集同源),非超管传什么都不收(全量)。")
public ApiResponse<List<JdProductCategoryVo>> categories(
@Parameter(description = "公司 ID") @RequestParam(name = "company_id", required = false) Long companyId,
HttpServletRequest request) {
RequestOperator operator = requireJdAccess(request);
AdminUserEntity user = operator.user();
// 类目下拉与列表同走超管筛选口径:选项集永远和当前请求能看到的行集同源。
Long scopedCompanyId = dataReadScope.superAdminScopedCompanyId(user, companyId);
return ApiResponse.success(jdProductQueryService.categories(scopedCompanyId));
+ "(京麦末级类目名)+ 行数,按类目名排序;全平台公共去重、无公司维度"
+ "(与用户端采集建单侧同一出口同一口径)。")
public ApiResponse<List<JdProductCategoryVo>> categories(HttpServletRequest request) {
requireJdAccess(request);
return ApiResponse.success(jdProductQueryService.categories());
}
@GetMapping("/{id}")
@@ -71,12 +71,12 @@ public class JdCollectController {
@GetMapping("/categories")
@Operation(summary = "采集类目下拉数据源", description = "建单页类目多选面板的选项集:公共库已落库行"
+ " DISTINCT 的 category_path(京麦末级类目名)+ 行数,按类目名排序。与后管京东数据库"
+ "同一条 SQL(JdProductQueryService.categories),公共库无公司维度——传 null 全量口径。"
+ "同一条 SQL(JdProductQueryService.categories),公共库无公司维度、全平台去重。"
+ "边界:从未采集过的店铺/新类目不在集内(先全店采一次即有),页面选项空态不阻塞建单。")
public ApiResponse<List<JdProductCategoryVo>> categories(HttpServletRequest httpRequest) {
// 登录用户即可读(公共库口径):解析不出会话身份就 401(fail-closed,与建单同口径)。
adminAuthSupport.requireOwnershipUserId(httpRequest, null);
return ApiResponse.success(jdProductQueryService.categories(null));
return ApiResponse.success(jdProductQueryService.categories());
}
@GetMapping("/groups")
@@ -42,14 +42,14 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
/**
* 后管只读页总数(Phase 5,v1.4):与 {@link #selectProductPage} 同一过滤面
* (公司/商品编码/标题关键词/类目/分组/未分类/已分类/同步起止,全部 SQL 侧下推,
* 铁律 20)。{@code companyId}/{@code groupId} 为空或 ≤0=不过滤该面;
* (商品编码/标题关键词/类目/分组/未分类/已分类/同步起止,全部 SQL 侧下推,
* 铁律 20)。公司维过滤已随 2026-11-16「删除掉公司 tab,参考品牌数据库」撤掉
* (数据全平台公共);{@code groupId} 为空或 ≤0=不过滤该面;
* {@code ungrouped=true}=只看未分类行(group_id IS NULL,店铺分类弹窗「未分类」范围);
* {@code grouped=true}=只看已分类行(group_id IS NOT NULL,页面筛选行「分类状态」档)。
* 店铺名过滤参数已随 2026-11-15 客户口径「店铺不需要」同窗撤掉(DB 列与详情/回传链不动)。
*/
long countProducts(@Param("companyId") Long companyId,
@Param("productCode") String productCode,
long countProducts(@Param("productCode") String productCode,
@Param("titleKeyword") String titleKeyword,
@Param("category") String category,
@Param("groupId") Long groupId,
@@ -90,8 +90,7 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
* <p>{@code offset}/{@code limit} 必须是服务侧钳制后的值——page 钳制防
* {@code (page-1)*page_size} 溢出(铁律 15),mapper 不做第二次换算,避免两处各算各的。</p>
*/
List<JdProductEntity> selectProductPage(@Param("companyId") Long companyId,
@Param("productCode") String productCode,
List<JdProductEntity> selectProductPage(@Param("productCode") String productCode,
@Param("titleKeyword") String titleKeyword,
@Param("category") String category,
@Param("groupId") Long groupId,
@@ -104,8 +103,8 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
/**
* 类目筛选下拉数据源(2026-11-15 用户口径「京麦的类目也要同步过来后台」):
* 本公司已落库行的 DISTINCT {@code category_path}(=京麦末级类目名)+ 行数。
* {@code companyId} 为空(超管不选公司)=跨公司全量去重。
* 已落库行的 DISTINCT {@code category_path}(=京麦末级类目名)+ 行数,全平台公共去重
* (2026-11-16 起与用户端采集建单侧同口径,无公司维过滤)。
*/
List<JdProductCategoryVo> selectProductCategories(@Param("companyId") Long companyId);
List<JdProductCategoryVo> selectProductCategories();
}
@@ -35,10 +35,10 @@ import java.util.Map;
* 先例:{@code page} 上限 {@link #MAX_PAGE}、{@code page_size} 上限 {@link #MAX_PAGE_SIZE},
* {@code page=Long.MAX_VALUE} 不会把乘积顶成负数生成 {@code LIMIT -N} 的 500 错。</p>
*
* <p><b>公司口径(2026-11-15 公共化)</b>:{@code scopedCompanyId} 由控制器经
* {@code DataReadScope#superAdminScopedCompanyId} 算好传入——只有站点超管显式传 company_id
* (公司 tab 筛选)才是正数,其余请求(含全部非超管)恒为 {@code null} = 全量;详情没有
* 公司维度,按 id 直取。</p>
* <p><b>公司口径(2026-11-16「删除掉公司 tab,参考品牌数据库」)</b>:读侧零公司维度——
* 公司 tab 与 {@code superAdminScopedCompanyId} 谓词已随公共化收尾整批摘除,每个管理员
* (含站点超管)看到同一份全量公共库;行上的 {@code company_id} 列仍是"哪家公司客户端
* 同步的"来源标记,随详情下发但不构成可见性边界。详情本就按 id 直取。</p>
*
* <p><b>详情 attr_json 解析(AC-7 未识别属性不丢弃)</b>:客户端实拍契约
* {@code {"tabs":[{"tab":"...","attrs":[{key,label,value}]}],"images":[...],"productCode":"..."}}——
@@ -75,12 +75,13 @@ public class JdProductQueryService {
/**
* 分页查询商品行({@code synced_at} 倒序)。
*
* <p>过滤面:公司(物化列 eq)、商品编码 contains、标题关键词 contains、
* 类目 eq、分组 eq、未分类(group_id IS NULL,店铺分类弹窗「未分类」范围)、
* <p>过滤面:商品编码 contains、标题关键词 contains、类目 eq、分组 eq、
* 未分类(group_id IS NULL,店铺分类弹窗「未分类」范围)、
* 已分类(group_id IS NOT NULL,页面筛选行「分类状态」档,2026-11-15 客户口径
* 「查询已分类的跟未分类,分类好的可以不显示」)、同步起止(datetime 闭区间)。</p>
* 「查询已分类的跟未分类,分类好的可以不显示」)、同步起止(datetime 闭区间)。
* 公司维过滤已随 2026-11-16 摘公司 tab 整批撤掉(全平台公共)。</p>
*/
public JdProductPageVo page(Long page, Long pageSize, Long scopedCompanyId,
public JdProductPageVo page(Long page, Long pageSize,
String productCode, String titleKeyword, String category, Long groupId, Boolean ungrouped,
Boolean grouped, LocalDateTime syncedFrom, LocalDateTime syncedTo) {
if (syncedFrom != null && syncedTo != null && syncedFrom.isAfter(syncedTo)) {
@@ -89,13 +90,13 @@ public class JdProductQueryService {
long safePage = page == null || page < 1 ? 1 : Math.min(page, MAX_PAGE);
long safeSize = pageSize == null ? PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT
: Math.min(Math.max(pageSize, 1), MAX_PAGE_SIZE);
Filter filter = filter(scopedCompanyId, productCode, titleKeyword, category,
Filter filter = filter(productCode, titleKeyword, category,
groupId, ungrouped, grouped, syncedFrom, syncedTo);
long total = jdProductMapper.countProducts(filter.companyId(), filter.productCode(),
long total = jdProductMapper.countProducts(filter.productCode(),
filter.titleKeyword(), filter.category(), filter.groupId(), filter.ungrouped(),
filter.grouped(), filter.syncedFrom(), filter.syncedTo());
List<JdProductEntity> rows = total <= 0 ? List.of()
: jdProductMapper.selectProductPage(filter.companyId(), filter.productCode(),
: jdProductMapper.selectProductPage(filter.productCode(),
filter.titleKeyword(), filter.category(), filter.groupId(), filter.ungrouped(),
filter.grouped(), filter.syncedFrom(), filter.syncedTo(),
(safePage - 1) * safeSize, (int) safeSize);
@@ -112,12 +113,11 @@ public class JdProductQueryService {
/**
* 类目筛选下拉数据源(2026-11-15 用户口径「京麦的类目也要同步过来后台」):
* 已落库行 distinct 的 {@code category_path}(=京麦末级类目名,契约 §2.3 E3)
* + 各自行数,按类目名排序。公司口径与分页同门(控制器经 {@code superAdminScopedCompanyId} 传入,
* {@code null} = 全量公共选项集)。
* + 各自行数,按类目名排序。全平台公共去重(2026-11-16 起与用户端采集建单侧
* 同一出口同一口径,无公司维过滤)。
*/
public List<JdProductCategoryVo> categories(Long scopedCompanyId) {
Long companyId = scopedCompanyId != null && scopedCompanyId > 0 ? scopedCompanyId : null;
return jdProductMapper.selectProductCategories(companyId);
public List<JdProductCategoryVo> categories() {
return jdProductMapper.selectProductCategories();
}
/**
@@ -173,23 +173,22 @@ public class JdProductQueryService {
// ---------------------------------------------------------------- 过滤面
/** 服务侧过滤面归一:companyId/groupId ≤0 按没选处理,文本 trim 后空串归 null。 */
private record Filter(Long companyId, String productCode, String titleKeyword,
/** 服务侧过滤面归一:groupId ≤0 按没选处理,文本 trim 后空串归 null(无公司维,2026-11-16 摘)。 */
private record Filter(String productCode, String titleKeyword,
String category, Long groupId, Boolean ungrouped, Boolean grouped,
LocalDateTime syncedFrom, LocalDateTime syncedTo) {
}
private static Filter filter(Long scopedCompanyId, String productCode, String titleKeyword,
private static Filter filter(String productCode, String titleKeyword,
String category, Long groupId, Boolean ungrouped, Boolean grouped,
LocalDateTime syncedFrom, LocalDateTime syncedTo) {
Long companyId = scopedCompanyId != null && scopedCompanyId > 0 ? scopedCompanyId : null;
Long safeGroupId = groupId != null && groupId > 0 ? groupId : null;
// 未分类与其它过滤面同口径:没显式要(true)=null=不进 IS NULL 分支。
Boolean safeUngrouped = Boolean.TRUE.equals(ungrouped) ? Boolean.TRUE : null;
// 已分类同口径:true=只看 group_id IS NOT NULL 的行;与未分类同选时 SQL 侧两谓词相与=空集
// (前端下拉是单选,正常到不了这个组合)。
Boolean safeGrouped = Boolean.TRUE.equals(grouped) ? Boolean.TRUE : null;
return new Filter(companyId, trimToNull(productCode), trimToNull(titleKeyword),
return new Filter(trimToNull(productCode), trimToNull(titleKeyword),
trimToNull(category), safeGroupId, safeUngrouped, safeGrouped, syncedFrom, syncedTo);
}
@@ -100,16 +100,16 @@
)
</select>
<!-- 后管只读页(Phase 5,v1.4)过滤面:公司(物化列 eq)、商品编码/标题关键词
(contains LIKE)、类目 eq、分组 eq、未分类(group_id IS NULL,店铺分类弹窗
「未分类」范围)、已分类(group_id IS NOT NULL,页面筛选行「分类状态」档,
2026-11-15 客户口径「查询已分类的跟未分类,分类好的可以不显示」)、
同步起止(datetime 闭区间)。
<!-- 后管只读页(Phase 5,v1.4)过滤面:商品编码/标题关键词(contains LIKE)、类目 eq、
分组 eq、未分类(group_id IS NULL,店铺分类弹窗「未分类」范围)、已分类
(group_id IS NOT NULL,页面筛选行「分类状态」档,2026-11-15 客户口径
「查询已分类的跟未分类,分类好的可以不显示」)、同步起止(datetime 闭区间)。
公司维过滤随 2026-11-16「删除掉公司 tab,参考品牌数据库」撤掉(数据全平台公共;
行 company_id 列仍是同步来源标记,不构成可见性边界)。
sale_status 筛选随 2026-11-15 客户口径撤掉;店铺名过滤同日客户口径「店铺不需要」
同窗撤掉(前端筛选框与列下线;DB 列本身与详情/回传链不动)。
全部走 #{} 占位符;offset/limit 必须是服务侧钳制后的值(铁律 15),mapper 不做第二次换算。 -->
<sql id="productConds">
<if test="companyId != null and companyId &gt; 0">AND p.company_id = #{companyId}</if>
<if test="productCode != null and productCode != ''">AND p.product_code LIKE CONCAT('%', #{productCode}, '%')</if>
<if test="titleKeyword != null and titleKeyword != ''">AND p.title LIKE CONCAT('%', #{titleKeyword}, '%')</if>
<if test="category != null and category != ''">AND p.category_path = #{category}</if>
@@ -142,14 +142,13 @@
LIMIT #{offset}, #{limit}
</select>
<!-- 类目筛选下拉数据源(2026-11-15 用户口径「京麦的类目也要同步过来后台」):本公司已落库行
的 DISTINCT category_path(=京麦末级类目名,契约 §2.3 E3)+ 行数。
空类目行不进下拉;companyId 为空(超管不选公司=全量)时跨公司去重。 -->
<!-- 类目筛选下拉数据源(2026-11-15 用户口径「京麦的类目也要同步过来后台」):已落库行
的 DISTINCT category_path(=京麦末级类目名,契约 §2.3 E3)+ 行数,全平台公共去重
(2026-11-16 起公司与后管两侧同口径,无公司维过滤)。空类目行不进下拉。 -->
<select id="selectProductCategories" resultType="com.nanri.aiimage.modules.jd.model.vo.JdProductCategoryVo">
SELECT p.category_path AS name, COUNT(*) AS productCount
FROM biz_jd_product p
WHERE p.category_path IS NOT NULL AND p.category_path != ''
<if test="companyId != null">AND p.company_id = #{companyId}</if>
GROUP BY p.category_path
ORDER BY p.category_path
</select>
@@ -5,7 +5,6 @@ import com.nanri.aiimage.common.api.PageDefaults;
import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.common.model.entity.AdminUserEntity;
import com.nanri.aiimage.common.security.AdminAuthSupport;
import com.nanri.aiimage.common.service.DataReadScope;
import com.nanri.aiimage.modules.jd.mapper.JdProductImageMapper;
import com.nanri.aiimage.modules.jd.mapper.JdProductMapper;
import com.nanri.aiimage.modules.jd.model.dto.JdProductBatchDeleteRequest;
@@ -48,16 +47,16 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
/**
* v1.4 Phase 5:后管「京东数据库」只读接口(列表/详情)与分组管理入口。
*
* <p>结构判据(照 {@code AdminAppearancePatentCleanItemsControllerTest} 双形态):
* 端点只读、鉴权 seam、公司口径(读侧只剩超管筛选 superAdminScopedCompanyId,公共库不走
* readCompanyIdOrOwn)、snake 参数带默认值、SQL 只落 XML;
* 行为样本:mock HttpServletRequest 把 company 参数交给 superAdminScopedCompanyId 并装进 200 信封、
* 端点只读、鉴权 seam、公司口径(2026-11-16 用户定案「删除掉公司 tab,参考品牌数据库」=
* 品牌库 2026-10-06 先例同形:company_id 请求参数与 superAdminScopedCompanyId 谓词整批摘除,
* 读侧零公司维度、反向钉住防回潜)、snake 参数带默认值、SQL 只落 XML;
* 行为样本:mock HttpServletRequest 走 requireJdAccess 鉴权正门并把结果装进 200 信封、
* 分页钳制 offset/limit(page=Long.MAX_VALUE 不得负,铁律 15)、详情 attr_json
* tabs→attrGroups 解析与非法形状兜底(AC-7)。
* 导出端点与 sale_status 筛选参数已随 2026-11-15 客户口径整段下线(反向钉住防回潜)。</p>
@@ -114,23 +113,30 @@ class AdminJdProductControllerTest {
}
@Test
void 公司口径只剩超管筛选_公共库不走readCompanyIdOrOwn() throws IOException {
void 读侧零公司维度_公司tab口径整批摘除() throws IOException {
String source = stripComments(Files.readString(CONTROLLER));
assertTrue(source.contains("DataReadScope"), "公司维度唯一出口是 DataReadScope");
assertTrue(source.contains("superAdminScopedCompanyId"),
"读侧(列表/类目)必须走 superAdminScopedCompanyId:只有站点超管显式传 company_id 才收窄"
+ "(公司 tab 筛选管理员),其余请求全量(2026-11-15 用户定案「京东数据库不区分公司、属于公共的」)");
// 2026-11-16 用户定案「删除掉公司 tab,参考品牌数据库」=品牌库 2026-10-06 先例同形:
// 摘的不只是 tab——company_id 参数与 superAdminScopedCompanyId 谓词一起撤,
// 数据全平台公共(行 company_id 列仍是同步来源标记,不构成可见性边界)。
assertFalse(source.contains("company_id"),
"company_id 请求参数必须已删除,不得回潜(2026-11-16 随公司 tab 整批摘除)");
assertFalse(source.contains("superAdminScopedCompanyId"),
"superAdminScopedCompanyId 谓词必须已删除:第五道门(超管显式收窄)对京东只读面不再生效");
assertFalse(source.contains("readCompanyIdOrOwn"),
"不得走 readCompanyIdOrOwn:它对非超管强制本公司,公共库对每一家管理员都是同一份全量");
"不得走 readCompanyIdOrOwn:全平台公共数据对每一家管理员都是同一份全量,无公司可见性边界");
assertFalse(source.contains("DataReadScope"),
"DataReadScope 不得再注入京东只读控制器(公司收口已随 2026-11-16 摘除)");
}
@Test
void 分页参数snake且带默认值() throws IOException {
String source = stripComments(Files.readString(CONTROLLER));
for (String param : List.of("page_size", "product_code", "title_keyword",
"group_id", "ungrouped", "grouped", "synced_from", "synced_to", "company_id")) {
"group_id", "ungrouped", "grouped", "synced_from", "synced_to")) {
assertTrue(source.contains(param), "查询参数必须 snake_case:" + param);
}
// company_id 参数已随 2026-11-16「删除掉公司 tab」整批摘除(读侧零公司维度支另有反向钉)。
assertFalse(source.contains("company_id"), "company_id 请求参数必须已删除,不得回潜");
// 商品状态筛选框已随 2026-11-15 客户口径从前端下线 ⇒ 服务端同名参数一起撤(反向钉住防回潜)。
assertFalse(source.contains("\"sale_status\""), "sale_status 筛选参数必须已删除,不得回潜");
// 店铺筛选同日客户口径「店铺不需要」下线 ⇒ shop_name 参数同窗撤(反向钉住防回潜)。
@@ -177,64 +183,58 @@ class AdminJdProductControllerTest {
// ===================== 行为样本 =====================
@Test
void 控制器把公司参数交给superAdminScopedCompanyId并把结果装进200信封() {
void 控制器列表走requireJdAccess正门并把查询结果装进200信封() {
JdProductQueryService queryService = mock(JdProductQueryService.class);
AdminAuthSupport authSupport = mock(AdminAuthSupport.class);
PermissionMenuService permissionMenuService = mock(PermissionMenuService.class);
DataReadScope dataReadScope = mock(DataReadScope.class);
AdminJdProductController controller = new AdminJdProductController(
queryService, mock(JdProductDeleteService.class), mock(JdProductUpdateService.class), authSupport,
permissionMenuService, dataReadScope);
permissionMenuService);
AdminUserEntity operator = new AdminUserEntity();
operator.setId(7L);
HttpServletRequest request = mock(HttpServletRequest.class);
when(authSupport.requireUser(request)).thenReturn(operator);
when(authSupport.currentRole(operator)).thenReturn("super_admin");
// 超管显式传 company_id=5 ⇒ 超管筛选把 5 交出来(不传时给 null=全量,同一行为样本家族)。
when(dataReadScope.superAdminScopedCompanyId(operator, 5L)).thenReturn(5L);
JdProductPageVo pageVo = new JdProductPageVo();
pageVo.setItems(List.of());
pageVo.setTotal(0L);
pageVo.setPage(1L);
pageVo.setPageSize((long) PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT);
when(queryService.page(1L, 20L, 5L, null, null, null, null, null, null, null, null)).thenReturn(pageVo);
when(queryService.page(1L, 20L, null, null, null, null, null, null, null, null)).thenReturn(pageVo);
// 2026-11-16 起请求面没有 company_id:任何授权身份看到的都是同一份全量。
ApiResponse<JdProductPageVo> response = controller.page(1L, 20L, null, null, null, null, null,
null, null, null, 5L, request);
null, null, null, request);
verify(dataReadScope).superAdminScopedCompanyId(operator, 5L);
verify(queryService).page(1L, 20L, 5L, null, null, null, null, null, null, null, null);
verify(queryService).page(1L, 20L, null, null, null, null, null, null, null, null);
assertEquals(Boolean.TRUE, response.isSuccess(), "拒绝走 403 业务码,放行必须是 success 信封(B80-03)");
assertEquals(pageVo, response.getData());
}
@Test
void 类目下拉端点走同一超管筛选口径并回选项集() {
void 类目下拉端点走同一鉴权正门并回全平台选项集() {
JdProductQueryService queryService = mock(JdProductQueryService.class);
AdminAuthSupport authSupport = mock(AdminAuthSupport.class);
DataReadScope dataReadScope = mock(DataReadScope.class);
AdminJdProductController controller = new AdminJdProductController(
queryService, mock(JdProductDeleteService.class), mock(JdProductUpdateService.class), authSupport,
mock(PermissionMenuService.class), dataReadScope);
mock(PermissionMenuService.class));
AdminUserEntity operator = new AdminUserEntity();
operator.setId(7L);
HttpServletRequest request = mock(HttpServletRequest.class);
when(authSupport.requireUser(request)).thenReturn(operator);
when(authSupport.currentRole(operator)).thenReturn("super_admin");
when(dataReadScope.superAdminScopedCompanyId(operator, 5L)).thenReturn(5L);
JdProductCategoryVo row = new JdProductCategoryVo();
row.setName("艺考形体服");
row.setProductCount(85L);
when(queryService.categories(5L)).thenReturn(List.of(row));
when(queryService.categories()).thenReturn(List.of(row));
ApiResponse<List<JdProductCategoryVo>> response = controller.categories(5L, request);
ApiResponse<List<JdProductCategoryVo>> response = controller.categories(request);
verify(dataReadScope).superAdminScopedCompanyId(operator, 5L);
verify(queryService).categories(5L);
verify(queryService).categories();
assertEquals(Boolean.TRUE, response.isSuccess(), "类目下拉与列表同一鉴权正门(200 信封)");
assertEquals("艺考形体服", response.getData().get(0).getName(), "选项=已落库行的末级类目名");
assertEquals("艺考形体服", response.getData().get(0).getName(), "选项=已落库行的末级类目名(全平台去重)");
assertEquals(85L, response.getData().get(0).getProductCount());
}
@@ -242,10 +242,9 @@ class AdminJdProductControllerTest {
void 控制器详情走同一鉴权正门并回详情且不问公司() {
JdProductQueryService queryService = mock(JdProductQueryService.class);
AdminAuthSupport authSupport = mock(AdminAuthSupport.class);
DataReadScope dataReadScope = mock(DataReadScope.class);
AdminJdProductController controller = new AdminJdProductController(
queryService, mock(JdProductDeleteService.class), mock(JdProductUpdateService.class), authSupport,
mock(PermissionMenuService.class), dataReadScope);
mock(PermissionMenuService.class));
AdminUserEntity operator = new AdminUserEntity();
operator.setId(7L);
@@ -258,8 +257,7 @@ class AdminJdProductControllerTest {
ApiResponse<JdProductDetailVo> response = controller.detail(11L, request);
// 公共库详情没有公司维度:DataReadScope 不参与(防有人把公司收口接回来)。
verifyNoInteractions(dataReadScope);
// 公共库详情没有公司维度(DataReadScope 反向钉在结构判据支,2026-11-16 已整批摘除)。
verify(queryService).detail(11L);
assertEquals(Boolean.TRUE, response.isSuccess());
assertEquals(detailVo, response.getData());
@@ -270,10 +268,9 @@ class AdminJdProductControllerTest {
JdProductQueryService queryService = mock(JdProductQueryService.class);
JdProductDeleteService deleteService = mock(JdProductDeleteService.class);
AdminAuthSupport authSupport = mock(AdminAuthSupport.class);
DataReadScope dataReadScope = mock(DataReadScope.class);
AdminJdProductController controller = new AdminJdProductController(
queryService, deleteService, mock(JdProductUpdateService.class), authSupport,
mock(PermissionMenuService.class), dataReadScope);
mock(PermissionMenuService.class));
AdminUserEntity operator = new AdminUserEntity();
operator.setId(7L);
@@ -288,8 +285,7 @@ class AdminJdProductControllerTest {
ApiResponse<JdProductDeleteVo> response = controller.delete(11L, request);
// 公共库写侧没有公司维度:不收 company_id、DataReadScope 不参与。
verifyNoInteractions(dataReadScope);
// 公共库写侧没有公司维度(结构判据支反向钉 company_id/DataReadScope 不得回流)。
verify(deleteService).delete(List.of(11L));
assertEquals(Boolean.TRUE, response.isSuccess());
assertEquals(9, response.getData().getObjectsDeleted());
@@ -300,10 +296,9 @@ class AdminJdProductControllerTest {
JdProductQueryService queryService = mock(JdProductQueryService.class);
JdProductDeleteService deleteService = mock(JdProductDeleteService.class);
AdminAuthSupport authSupport = mock(AdminAuthSupport.class);
DataReadScope dataReadScope = mock(DataReadScope.class);
AdminJdProductController controller = new AdminJdProductController(
queryService, deleteService, mock(JdProductUpdateService.class), authSupport,
mock(PermissionMenuService.class), dataReadScope);
mock(PermissionMenuService.class));
AdminUserEntity operator = new AdminUserEntity();
operator.setId(7L);
@@ -326,23 +321,23 @@ class AdminJdProductControllerTest {
JdProductQueryService service = new JdProductQueryService(mapper, mock(JdProductImageMapper.class),
mock(com.nanri.aiimage.modules.jd.mapper.JdProductSkuMapper.class),
mock(com.nanri.aiimage.modules.jd.mapper.JdProductGroupMapper.class));
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(1L);
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(1L);
// page=0 / size=null ⇒ 归一为第 1 页、默认 20 条;offset = 0。
service.page(0L, null, null, null, null, null, null, null, null, null, null);
service.page(0L, null, null, null, null, null, null, null, null, null);
ArgumentCaptor<Long> offset = ArgumentCaptor.forClass(Long.class);
ArgumentCaptor<Integer> limit = ArgumentCaptor.forClass(Integer.class);
verify(mapper).selectProductPage(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(),
isNull(), isNull(), isNull(), offset.capture(), limit.capture());
isNull(), isNull(), offset.capture(), limit.capture());
assertEquals(0L, offset.getValue());
assertEquals(PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT, limit.getValue());
// page=Long.MAX_VALUE / size=500 ⇒ 钳到 10_000 页、100 条;乘积 999_900 不得变负(铁律 15)。
service.page(Long.MAX_VALUE, 500L, null, null, null, null, null, null, null, null, null);
service.page(Long.MAX_VALUE, 500L, null, null, null, null, null, null, null, null);
ArgumentCaptor<Long> offsetMax = ArgumentCaptor.forClass(Long.class);
ArgumentCaptor<Integer> limitMax = ArgumentCaptor.forClass(Integer.class);
verify(mapper, times(2)).selectProductPage(any(), any(), any(), any(), any(), any(),
any(), any(), any(), offsetMax.capture(), limitMax.capture());
any(), any(), offsetMax.capture(), limitMax.capture());
assertEquals(999_900L, offsetMax.getValue(), "(page-1)*page_size 最大 999_900,钳制后不得溢出变负");
assertEquals(100, limitMax.getValue());
}
@@ -356,9 +351,9 @@ class AdminJdProductControllerTest {
LocalDateTime from = LocalDateTime.of(2026, 11, 14, 12, 0);
LocalDateTime to = LocalDateTime.of(2026, 11, 14, 8, 0);
BusinessException ex = assertThrows(BusinessException.class,
() -> service.page(1L, 20L, null, null, null, null, null, null, null, from, to));
() -> service.page(1L, 20L, null, null, null, null, null, null, from, to));
assertTrue(ex.getMessage().contains("开始时间不能晚于结束时间"), "倒挂时间按业务异常拒绝");
verify(mapper, never()).countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any());
verify(mapper, never()).countProducts(any(), any(), any(), any(), any(), any(), any(), any());
}
@Test
@@ -367,37 +362,37 @@ class AdminJdProductControllerTest {
JdProductQueryService service = new JdProductQueryService(mapper, mock(JdProductImageMapper.class),
mock(com.nanri.aiimage.modules.jd.mapper.JdProductSkuMapper.class),
mock(com.nanri.aiimage.modules.jd.mapper.JdProductGroupMapper.class));
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(0L);
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(0L);
// 超管显式传 5 ⇒ 按公司 5 筛(收窄);groupId ≤0 按没选分组处理;文本两侧空白剥掉。
// groupId ≤0 按没选分组处理;文本两侧空白剥掉。
// 类目(京麦末级类目名)走同一过滤面:传值原样直传、空白归 null。
service.page(1L, 20L, 5L, " SKU-1 ", " 连衣裙 ", " 艺考形体服 ", 0L, null, null, null, null);
verify(mapper).countProducts(eq(5L), eq("SKU-1"), eq("连衣裙"),
service.page(1L, 20L, " SKU-1 ", " 连衣裙 ", " 艺考形体服 ", 0L, null, null, null, null);
verify(mapper).countProducts(eq("SKU-1"), eq("连衣裙"),
eq("艺考形体服"), isNull(), isNull(), isNull(), isNull(), isNull());
// 全量(scopedCompanyId=null)⇒ companyId 不过滤。
service.page(1L, 20L, null, null, null, null, null, null, null, null, null);
// 全量口径(2026-11-16 起读侧无公司维)⇒ 过滤面全 null。
service.page(1L, 20L, null, null, null, null, null, null, null, null);
verify(mapper).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
isNull(), isNull(), isNull(), isNull());
isNull(), isNull(), isNull());
// 未分类范围(店铺分类弹窗「未分类」页签):ungrouped=true 原样下推到 SQL 侧。
service.page(1L, 20L, null, null, null, null, null, Boolean.TRUE, null, null, null);
verify(mapper).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
eq(Boolean.TRUE), isNull(), isNull(), isNull());
service.page(1L, 20L, null, null, null, null, Boolean.TRUE, null, null, null);
verify(mapper).countProducts(isNull(), isNull(), isNull(), isNull(), eq(Boolean.TRUE),
isNull(), isNull(), isNull());
// ungrouped=false / 缺省按不过滤处理(Filter 归一成 null,不进 IS NULL 分支);
// 与②「全量」那发同形状,累计 2 次。
service.page(1L, 20L, null, null, null, null, null, Boolean.FALSE, null, null, null);
service.page(1L, 20L, null, null, null, null, Boolean.FALSE, null, null, null);
verify(mapper, times(2)).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
isNull(), isNull(), isNull(), isNull());
isNull(), isNull(), isNull());
// 已分类档(页面筛选行「分类状态」=已分类,2026-11-15 客户口径「分类好的可以不显示」反选):
// grouped=true 原样下推到 SQL 侧(group_id IS NOT NULL),ungrouped 不动。
service.page(1L, 20L, null, null, null, null, null, null, Boolean.TRUE, null, null);
service.page(1L, 20L, null, null, null, null, null, Boolean.TRUE, null, null);
verify(mapper).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
isNull(), eq(Boolean.TRUE), isNull(), isNull());
eq(Boolean.TRUE), isNull(), isNull());
// grouped=false / 缺省同口径归一成 null(不进 IS NOT NULL 分支);与②「全量」累计 3 次。
service.page(1L, 20L, null, null, null, null, null, null, Boolean.FALSE, null, null);
service.page(1L, 20L, null, null, null, null, null, Boolean.FALSE, null, null);
verify(mapper, times(3)).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
isNull(), isNull(), isNull(), isNull());
isNull(), isNull(), isNull());
}
@Test
@@ -405,10 +400,9 @@ class AdminJdProductControllerTest {
JdProductQueryService queryService = mock(JdProductQueryService.class);
JdProductUpdateService updateService = mock(JdProductUpdateService.class);
AdminAuthSupport authSupport = mock(AdminAuthSupport.class);
DataReadScope dataReadScope = mock(DataReadScope.class);
AdminJdProductController controller = new AdminJdProductController(
queryService, mock(JdProductDeleteService.class), updateService, authSupport,
mock(PermissionMenuService.class), dataReadScope);
mock(PermissionMenuService.class));
AdminUserEntity operator = new AdminUserEntity();
operator.setId(7L);
@@ -423,8 +417,7 @@ class AdminJdProductControllerTest {
body.setGroupId(3L);
ApiResponse<Integer> response = controller.batchAssignGroup(body, request);
// 公共库写侧没有公司维度:不收 company_id、DataReadScope 不参与。
verifyNoInteractions(dataReadScope);
// 公共库写侧没有公司维度(结构判据支反向钉 company_id/DataReadScope 不得回流)。
verify(updateService).assignGroup(List.of(11L, 12L), 3L);
assertEquals(Boolean.TRUE, response.isSuccess(), "放行必须是 success 信封(B80-03)");
assertEquals(2, response.getData(), "回执=实际更新的行数");
@@ -598,8 +591,8 @@ class AdminJdProductControllerTest {
grouped.setGroupId(3L);
JdProductEntity missing = productEntity(2L);
missing.setGroupId(99L);
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(2L);
when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), any(), any(), any(),
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(2L);
when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), any(), any(),
anyLong(), anyInt())).thenReturn(List.of(grouped, missing));
com.nanri.aiimage.modules.jd.model.entity.JdProductGroupEntity group =
new com.nanri.aiimage.modules.jd.model.entity.JdProductGroupEntity();
@@ -607,7 +600,7 @@ class AdminJdProductControllerTest {
group.setName("秋冬款");
when(groupMapper.selectBatchIds(any())).thenReturn(List.of(group));
JdProductPageVo vo = service.page(1L, 20L, 5L, null, null, null, null, null, null, null, null);
JdProductPageVo vo = service.page(1L, 20L, null, null, null, null, null, null, null, null);
assertEquals("秋冬款", vo.getItems().get(0).getGroupName(), "行集 group_id 一次取齐分组名(无逐行查询)");
assertNull(vo.getItems().get(1).getGroupName(), "分组已删=不猜名字(铁律 30),前端展示 -");