feat(京东数据库): 撤销按公司隔离回归全平台共享采集池+后管商品目录改京东平台类目平铺

客户口径(2026-11-26):「采集的数据可以重复被操作分类,大家一起采集,但分类后的
数据就自己看,所以会有数据副本」「被分类后按组 id 绑定拷贝数据副本,原来的数据
也要留着」。

- 可见口径:商品行全平台共享(2026-11-23 的按公司隔离整批撤销),读侧撤
  companyId 谓词(列表/类目下拉/候选店铺/详情/导出),写侧撤 assertRowsInCompany
  行级公司闸——越权由端点级 requireJdProductWrite(仅平台超管+公司超管)兜住。
  「副本」落在 V203 归属行上:同一商品可多组各一条 owner_group_id,分类列/分类
  筛选各看各的;原商品行一条不删不藏,别组分过类的在本组仍显示未分类、可再分。
- 用户端选品 pageInScope 不再按 companyId 收窄(只认可见分组下的归属行)。
- 后管左栏「商品目录」:授权类目树/内置花屿巷快照退役,改为 /categories 的
  category_path 平铺(末级类目名+商品数),点行=末级名等值过滤;删
  jd-category-tree.ts / jd-shop-category-api.ts 及其测试,JdDatabasePage 不再取树。
- 判据:AdminJdProductControllerTest 34、JdProductMapperSqlTest 5、
  JdGroupShopServiceTest 10、JdProductQueryServiceUserPageTest 7 全绿;
  后管 node --test 1963/vitest 250/vue-tsc rc=0。
This commit is contained in:
2026-11-26 13:08:21 +08:00
parent f88b3d4622
commit bddde97285
25 changed files with 434 additions and 1846 deletions
@@ -57,14 +57,8 @@ const groupApi = vi.hoisted(() => ({
createShopGroup: vi.fn(),
}))
// 京麦授权类目树(V215 真树)读取:默认空回执=页面回落内置快照;真树用例显式变形。
const shopTreeApi = vi.hoisted(() => ({
fetchJdShopCategoryTree: vi.fn(),
}))
vi.mock('@/pages/jd/jd-product-api.ts', () => jdApi)
vi.mock('@/pages/account/shop-group-api.ts', () => groupApi)
vi.mock('@/pages/jd/jd-shop-category-api.ts', () => shopTreeApi)
vi.mock('@/components/admin-confirm', () => ({ openAdminConfirm: confirmMock }))
function item(id: number, over: Record<string, unknown> = {}) {
@@ -114,9 +108,8 @@ function singleGroupScope(editable = true) {
}
}
/** 类目计数夹具:与侧栏组件 mount 测试同源(树内连衣裙支+树外历史名),
* 树内路径以 jd-category-tree 真树为准:连衣裙=服饰内衣/女装/连衣裙、
* 艺考形体服=运动户外/舞蹈体操鞋服/装备/艺考形体服。 */
/** 类目计数夹具:与侧栏组件 mount 测试同源。2026-11-26 起左栏商品目录=后端
* `/categories` 的 `category_path` 平铺(末级类目名+商品数),不再有类目树/路径。 */
const CATEGORY_OPTIONS = [
{ name: '连衣裙', productCount: 7 },
{ name: '艺考形体服', productCount: 5 },
@@ -136,8 +129,6 @@ beforeEach(() => {
jdApi.fetchJdCategoryScope.mockResolvedValue(singleGroupScope())
jdApi.fetchJdProductGroups.mockResolvedValue([])
jdApi.fetchJdProductCategories.mockResolvedValue([])
// 真树默认「服务端还没人上报过」=页面回落内置快照(旧用例形状逐字不变)。
shopTreeApi.fetchJdShopCategoryTree.mockResolvedValue({ nodes: [], shops: [] })
// 店铺名单(v1.7)默认空回执:只有名单用例显式变形。
jdApi.removeJdGroupShop.mockResolvedValue(undefined)
jdApi.renameJdGroupShop.mockResolvedValue(undefined)
@@ -328,49 +319,24 @@ describe('布局:筛选行+工具栏上移顶部通栏(2026-11-21 用户
})
})
describe('侧栏商品目录(类目筛选迁移自级联面板)', () => {
it('授权类目树逐级下钻:一级行点行=选中即查(path 下发),末级点行单名/路径口径与级联面板等价', async () => {
describe('侧栏商品目录(京东平台类目平铺,2026-11-26)', () => {
it('类目行点选=末级类目名等值下发(category+path 空),「全部商品」清选重查', async () => {
jdApi.fetchJdProductCategories.mockResolvedValue(CATEGORY_OPTIONS)
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 50 })
expect(jdApi.fetchJdProductCategories).toHaveBeenCalledWith()
const catalog = wrapper.get('.jd-side-catalog')
// 一级默认展开:二级「女装」首屏可见(侧栏与级联面板的关键差异——非末级也能直接选)。
const women = sideRowBy(catalog, '女装')
expect(women.classes()).toContain('depth-1')
// 一类目一行平铺:末级类目名直接点,不再有「一级/二级下钻」与展开箭头。
expect(catalog.find('.jd-side-arrow').exists()).toBe(false, '平铺列表没有展开箭头')
expect(catalog.findAll('.jd-side-tree .jd-side-row').length).toBeGreaterThan(0)
// 点二级=选中即查(2026-11-18 客户口径「没办法选择一级跟二级类目」的侧栏形状)。
await women.trigger('click')
await flushPromises()
let last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(last).toMatchObject({ category: '女装', categoryPath: ['服饰内衣', '女装'], page: 1 },
'一级/二级点行=带完整路径下发(序列化按子树展开 IN)')
// 展开到末级再点末级:艺考形体服(运动户外支)。
await catalog.get('[aria-label="展开或收起 舞蹈体操鞋服/装备"]').trigger('click')
await flushPromises()
await sideRowBy(catalog, '艺考形体服').trigger('click')
await flushPromises()
last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(last).toMatchObject({
category: '艺考形体服',
categoryPath: ['运动户外', '舞蹈体操鞋服/装备', '艺考形体服'],
page: 1,
}, '末级点行带完整名称路径(同名跨支靠路径区分)')
wrapper.unmount()
})
it('树外类目组(已落库但京麦树里没有的历史名):点行单名等值下发;「全部商品」行清选重查', async () => {
jdApi.fetchJdProductCategories.mockResolvedValue(CATEGORY_OPTIONS)
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 50 })
const catalog = wrapper.get('.jd-side-catalog')
// 授权树外的本店历史行收在单独一组(path 空数组=页面按无路径序列化单名等值)。
const extra = catalog.get('.jd-side-extra')
expect(extra.text()).toContain('授权树外的类目')
await extra.findAll('.jd-side-row').find((row) => row.text().includes('已下架历史类目'))!.trigger('click')
await flushPromises()
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ category: '已下架历史类目', categoryPath: [] })
const leaf = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(leaf).toMatchObject({ category: '艺考形体服', page: 1 },
'末级类目名等值过滤(后端 category_path IN 单元素集合)')
expect('categoryPath' in leaf, '父级路径这一层已退役:api 入参不再有 categoryPath').toBe(false)
expect('categoryNames' in leaf, '子树展开集合同样退役:入参不再有 categoryNames').toBe(false)
// 点「全部商品」行=清选重查(category 回空、query 层不下发,回第一页)。
const callsBefore = jdApi.fetchJdProductList.mock.calls.length
@@ -378,44 +344,30 @@ describe('侧栏商品目录(类目筛选迁移自级联面板)', () => {
await flushPromises()
expect(jdApi.fetchJdProductList.mock.calls.length).toBe(callsBefore + 1, '清选也要重查')
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0].category).toBe('')
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0].categoryPath).toEqual([],
'清选后路径回空数组(api 序列化层对空 category 不下发参数)')
expect('categoryPath' in jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toBe(false)
wrapper.unmount()
})
it('服务端真树≠内置快照:点父级必须把按真树展开的 categoryNames 透传给列表查询(2026-11-25「收纳用品 81 点开 0 条」断链钉)', async () => {
// 真树=家居日用店授权树(收纳用品/收纳盒/收纳篮/收纳架),内置快照(花屿巷服饰)
// 里一个都没有——旧断链形状:页面算好集合但 api 入参丢字段,序列化退回快照展开
// 失败 → 单名等值 IN('收纳用品') → 库里只有叶子名 → 0 条。
shopTreeApi.fetchJdShopCategoryTree.mockResolvedValue({
nodes: [{
name: '收纳用品', value: '9001',
children: [
{ name: '收纳盒', value: '9002' },
{ name: '收纳篮', value: '9003' },
{ name: '收纳架', value: '9004' },
],
}],
shops: [{ shopId: '228346061', shopName: '家居日用数据库店', capturedAt: '2026-11-24 10:00:00', nodeCount: 4 }],
})
it('2026-11-26:商品目录只读京东平台类目,页面不再取授权类目树(/jd-shop-category-tree)', async () => {
jdApi.fetchJdProductCategories.mockResolvedValue([
{ name: '收纳盒', productCount: 23 },
{ name: '收纳篮', productCount: 14 },
{ name: '收纳架', productCount: 44 },
])
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 50 })
// 客户口径「京东分类是百分百有的,京东内分类就不需要」:左栏直接是 category_path
// 平铺,不再有按店铺上报的授权树、也不再有内置花屿巷快照/树外兜底分组。
const catalog = wrapper.get('.jd-side-catalog')
// 徽标同源(真树聚合):父级 81=23+14+44,这条一直是对的,错的是过滤链。
expect(sideRowBy(catalog, '收纳用品').text()).toContain('81')
expect(sideRowBy(catalog, '收纳盒').text()).toContain('23')
expect(catalog.text()).not.toContain('授权树外的类目')
expect(catalog.text()).not.toContain('本店无匹配')
await sideRowBy(catalog, '收纳用品').trigger('click')
await sideRowBy(catalog, '收纳盒').trigger('click')
await flushPromises()
const last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(last).toMatchObject({ category: '收纳用品', categoryPath: ['收纳用品'], page: 1 })
expect(last.categoryNames, '断链修复点:页面按真树展开的子树名集合必须进 api 入参').toBeDefined()
expect([...last.categoryNames].sort()).toEqual(['收纳架', '收纳盒', '收纳篮', '收纳用品'].sort(),
'集合=节点自身+全部后代(与徽标计数同一棵树算出)')
expect(last).toMatchObject({ category: '收纳盒', page: 1 })
expect('categoryNames' in last, '不再有「页面按树展开的集合」这层:平铺行单名等值').toBe(false)
expect('categoryPath' in last, '也不再传类目路径').toBe(false)
wrapper.unmount()
})
})