feat(jd): 店铺分类弹窗新建收成+图标/排序输入下线;京东数据库下线店铺筛选与列(后端 shop_name 参数同窗撤)

This commit is contained in:
2026-11-15 23:58:52 +08:00
parent 6818f9777b
commit 4506253989
12 changed files with 135 additions and 131 deletions
@@ -1,14 +1,15 @@
<script setup lang="ts">
/** 京东数据库页(v1.4 Phase 5):公共的京东商品库(2026-11-15 用户定案「不区分公司、属于
* 公共的」,分类同亚马逊口径全平台一份),筛选行(店铺/商品编码/标题关键字/分类/分类状态/
* 公共的」,分类同亚马逊口径全平台一份),筛选行(商品编码/标题关键字/分类/分类状态/
* 类目/同步起止 date 对)+查询/重置/店铺分类 + 自绘明细表(勾选列+点行开详情抽屉)
* + 删除(单行/批量,先删桶对象、全成功才删库行,确认弹窗点名数量)+ OldPagination。
* 公司维度只剩超管的公司 tab(=筛选管理员,非超管没有这个筛选、看到同一份公共全量);
* 列表按京麦商品列表样式(2026-11-15 用户口径):店铺/分类前置为第 1/2 列;商品信息列=京麦同款
* 列表按京麦商品列表样式(2026-11-15 用户口径):分类前置为第 1 列;商品信息列=京麦同款
* 合并布局(主图+图下信息分+标题两行+商品编码/货号+SKU 数标签,编码带一键复制);类目/上架
* 时间/京东创建/修改时间仍收详情抽屉基本信息(B104「详情显示全部属性」口径不变)。
* 商品状态筛选框/列与导出按钮随 2026-11-15 客户口径「这两个不要/导出也不用」从前端下线
* (后端 sale_status 参数与 /export 端点保留;状态仍收详情抽屉)。
* (后端 sale_status 参数与 /export 端点保留;状态仍收详情抽屉);店铺筛选与店铺列同日
* 客户口径「店铺不需要」下线(后端 shop_name 参数同窗撤;店铺仍收详情抽屉)。
* 骨架像素复刻「外观专利数据库」页(panel-box + LoadFailureBar + 自绘 table + 旧式分页);
* 超管切公司 tab = 清筛选重取(watch 体照外观专利页逐字形状);日期对护栏:起侧 max=止侧、
* 止侧 min=起侧、两侧 @change 用 orderedPair 把倒挂交换回来(clampJdSyncedRange 照 clampDatePair)。
@@ -117,7 +118,6 @@ async function load(): Promise<void> {
const result = await fetchJdProductList({
page: page.value,
pageSize: pageSize.value,
shopName: filter.shopName,
productCode: filter.productCode,
titleKeyword: filter.titleKeyword,
category: filter.category,
@@ -238,10 +238,10 @@ async function removeMany(picked: JdProductItem[], message: string): Promise<voi
}
}
// 超管切公司 tab = 重新取数:店铺/编码/关键字/类目/日期是按行集筛的自由值,在另一家的
// 超管切公司 tab = 重新取数:编码/关键字/类目/日期是按行集筛的自由值,在另一家的
// 行集里筛不出东西,必须一起清(分组与分类状态全平台一份,groupId/groupScope 与公司维度
// 正交、不清);类目选项与行集同源,按新 tab 重取;分组选项是全局的、进页取一次即可。
watch(() => companyTab.activeId, () => { filter.shopName = ''; filter.productCode = ''; filter.titleKeyword = ''; filter.category = ''; filter.syncedFrom = ''; filter.syncedTo = ''; page.value = 1; void loadCategoryOptions(); void load() })
watch(() => companyTab.activeId, () => { filter.productCode = ''; filter.titleKeyword = ''; filter.category = ''; filter.syncedFrom = ''; filter.syncedTo = ''; page.value = 1; void loadCategoryOptions(); void load() })
onMounted(() => {
void loadGroupOptions()
@@ -259,10 +259,6 @@ onMounted(() => {
</div>
<div class="jd-filter-row">
<div class="form-group">
<label>店铺</label>
<input v-model="filter.shopName" type="text" placeholder="输入店铺名" @keyup.enter="apply" />
</div>
<div class="form-group">
<label>商品编码</label>
<input v-model="filter.productCode" type="text" placeholder="输入商品编码" @keyup.enter="apply" />
@@ -333,7 +329,6 @@ onMounted(() => {
<thead>
<tr>
<th style="width: 42px"><input type="checkbox" :checked="allSelected" @change="toggleSelectAll(($event.target as HTMLInputElement).checked)" /></th>
<th style="width: 130px">店铺</th>
<th style="width: 96px">分类</th>
<th>商品信息</th>
<th style="width: 76px">总库存</th>
@@ -349,7 +344,6 @@ onMounted(() => {
<template v-if="rows.length">
<tr v-for="row in rows" :key="row.id" class="jd-row" @click="openDetail(row)">
<td @click.stop><input type="checkbox" :checked="selectedIds.has(row.id)" @change="toggleSelect(row, ($event.target as HTMLInputElement).checked)" /></td>
<td :title="row.shopName || ''">{{ row.shopName || '-' }}</td>
<td :title="row.groupName || ''">{{ row.groupName || '未分类' }}</td>
<td class="jd-info-cell">
<div class="jd-info-wrap">
@@ -392,10 +386,10 @@ onMounted(() => {
</tr>
</template>
<tr v-else-if="loading">
<td colspan="11" class="empty-tip">加载中...</td>
<td colspan="10" class="empty-tip">加载中...</td>
</tr>
<tr v-else>
<td colspan="11" class="empty-tip">暂无京东商品数据</td>
<td colspan="10" class="empty-tip">暂无京东商品数据</td>
</tr>
</tbody>
</table>
@@ -1,6 +1,7 @@
<script setup lang="ts">
/** 京东商品「店铺分类」弹窗(2026-11-15 由「分组管理」小弹窗重做):左右分栏——左栏分类管理
* (新建/改名/删除;分组全平台一份、措辞「分类」),右栏商品人工归类(独立件
* (新建=输入行尾「+」图标,排序数字输入 2026-11-15 客户口径下线、sortOrder 恒 0;
* 改名/删除;分组全平台一份、措辞「分类」),右栏商品人工归类(独立件
* JdProductAssignPane:范围切换+搜索+勾选 →「归入所选分类」/「移出分类」,批量端点
* batch-assign-group 与单行编辑同口径置 manual_locked=1——归类即人工干预,采集不再覆盖/
* 清理该行)。左栏点亮的分类=右栏归类目标;目标被删时右栏自动拉回全量页签。
@@ -30,9 +31,8 @@ const emit = defineEmits<{ (event: 'close'): void; (event: 'changed'): void }>()
const loading = ref(false)
const errorText = ref('')
const groups = ref<JdProductGroup[]>([])
/** 新建:名称 + 排序。 */
/** 新建:只收名称(排序输入 2026-11-15 客户口径下线,sortOrder 恒 0,后端契约不变)。 */
const createName = ref('')
const createSortOrder = ref(0)
const creating = ref(false)
/** 改名:正在编辑的分类 id 与草稿名。 */
const editingId = ref(0)
@@ -73,9 +73,8 @@ async function submitCreate(): Promise<void> {
creating.value = true
errorText.value = ''
try {
await createJdProductGroup({ name, sortOrder: Math.floor(createSortOrder.value) || 0 })
await createJdProductGroup({ name, sortOrder: 0 })
createName.value = ''
createSortOrder.value = 0
await refreshAfterChange()
} catch (error) {
errorText.value = requestErrorMessage(error) || '新建分类失败'
@@ -143,7 +142,6 @@ watch(
if (visible) {
cancelRename()
createName.value = ''
createSortOrder.value = 0
errorText.value = ''
selectedGroupId.value = 0
void loadGroups()
@@ -180,12 +178,16 @@ function onPaneChanged(): void {
placeholder="输入新分类名称"
@keyup.enter="submitCreate"
/>
<div class="group-create-row">
<input v-model.number="createSortOrder" type="number" class="sort-input" aria-label="排序" />
<button class="btn" type="button" :disabled="!canCreate" @click="submitCreate">
{{ creating ? '新建中...' : '新建分类' }}
</button>
</div>
<!-- 新建=输入行尾「+」图标(2026-11-15 客户口径:原第二行文字按钮收成图标上移,
排序数字输入下线——sortOrder 恒 0,后端契约不变)。 -->
<button
class="create-icon-btn"
type="button"
title="新建分类"
aria-label="新建分类"
:disabled="!canCreate"
@click="submitCreate"
>+</button>
</div>
<p v-if="loading" class="pane-tip">加载中...</p>
<ul class="group-list">
@@ -305,11 +307,12 @@ function onPaneChanged(): void {
}
.group-create {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
margin-bottom: 10px;
}
.group-create input {
flex: 1;
min-width: 0;
min-height: 36px;
padding: 6px 12px;
@@ -325,12 +328,23 @@ function onPaneChanged(): void {
background: #ffffff;
border-color: #5f85ad;
}
.group-create-row {
display: flex;
gap: 8px;
/* 新建「+」图标按钮:与输入同行(原第二行文字按钮上移收成图标)。 */
.create-icon-btn {
flex: none;
width: 36px;
min-height: 36px;
padding: 0;
border: 1px solid #4f78a5;
border-radius: 9px;
background: linear-gradient(135deg, #5f85ad, #4f78a5);
color: #ffffff;
font-size: 18px;
line-height: 1;
cursor: pointer;
}
.sort-input {
flex: 0 0 72px !important;
.create-icon-btn:disabled {
cursor: not-allowed;
opacity: 0.6;
}
.group-list {
flex: 1;
@@ -25,7 +25,6 @@ export async function fetchJdProductList(
): Promise<JdProductPageResult> {
const query = toJdProductListParams(
{
shopName: params.shopName ?? '',
productCode: params.productCode ?? '',
titleKeyword: params.titleKeyword ?? '',
category: params.category ?? '',
@@ -1,10 +1,11 @@
/** 京东数据库页筛选纯函数(v1.4 Phase 5):店铺/商品编码/标题关键字/类目/分组/分类状态/同步起止 + snake 分页参数。
* 产出与后端契约 §列表 query 逐字对撞:`page`/`page_size`(默认 20、上限 100)、`shop_name`、
/** 京东数据库页筛选纯函数(v1.4 Phase 5):商品编码/标题关键字/类目/分组/分类状态/同步起止 + snake 分页参数。
* 产出与后端契约 §列表 query 逐字对撞:`page`/`page_size`(默认 20、上限 100)、
* `product_code`、`title_keyword`、`category`(京麦末级类目等值过滤,2026-11-15 增)、
* `group_id`、`grouped`(只看已分类,2026-11-15 客户口径「查询已分类的跟未分类,分类好的
* 可以不显示」增)、`ungrouped`(只看未分类,页面「分类状态」档与店铺分类弹窗共用)、
* `synced_from`/`synced_to`(ISO yyyy-MM-dd;空白不下发)。
* 商品状态筛选与导出(2026-11-15 客户口径「这两个不要/导出也不用」)已从前端下线;
* 店铺筛选同日客户口径「店铺不需要」从前端下线(后端 shop_name 参数同窗撤,DB 列与详情不动)。
* 后端 `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 直测。
@@ -21,8 +22,6 @@ export const JD_PRODUCT_MAX_PAGE_SIZE = 100
export const JD_PRODUCT_MAX_PAGE = 10_000
export interface JdProductFilterState {
/** 店铺名(模糊),空串不限。 */
shopName: string
/** 商品编码,空串不限。 */
productCode: string
/** 标题关键字,空串不限。 */
@@ -41,12 +40,11 @@ export interface JdProductFilterState {
}
export function createJdProductFilterState(): JdProductFilterState {
return { shopName: '', productCode: '', titleKeyword: '', category: '', groupId: '', groupScope: '', syncedFrom: '', syncedTo: '' }
return { productCode: '', titleKeyword: '', category: '', groupId: '', groupScope: '', syncedFrom: '', syncedTo: '' }
}
/** 是否有任一激活筛选条件。 */
export function jdProductFilterActive(state: JdProductFilterState): boolean {
if ((state.shopName || '').trim()) return true
if ((state.productCode || '').trim()) return true
if ((state.titleKeyword || '').trim()) return true
if ((state.category || '').trim()) return true
@@ -60,7 +58,6 @@ export function jdProductFilterActive(state: JdProductFilterState): boolean {
export interface JdProductQuery {
page: number
page_size: number
shop_name?: string
product_code?: string
title_keyword?: string
/** 京麦末级类目等值过滤(后端 JdProductQueryService.Filter.category)。 */
@@ -81,7 +78,6 @@ export interface JdProductQuery {
export interface JdProductListParams {
page: number
pageSize: number
shopName?: string
productCode?: string
titleKeyword?: string
category?: string
@@ -98,8 +94,6 @@ export interface JdProductListParams {
/** 过滤态 → 过滤面参数(snake_case,仅下发非空字段)。 */
function toJdProductFilterQuery(state: JdProductFilterState): Omit<JdProductQuery, 'page' | 'page_size'> {
const query: Omit<JdProductQuery, 'page' | 'page_size'> = {}
const shopName = (state.shopName || '').trim()
if (shopName) query.shop_name = shopName
const productCode = (state.productCode || '').trim()
if (productCode) query.product_code = productCode
const titleKeyword = (state.titleKeyword || '').trim()
@@ -757,14 +757,15 @@ 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 公共化改口径):店铺/商品编码/标题是
// ↓ 批次 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.shopName = ''; filter.productCode = ''; filter.titleKeyword = ''; filter.category = ''; filter.syncedFrom = ''; filter.syncedTo = ''; page.value = 1; void loadCategoryOptions(); void load()",
why: '店铺/商品编码/标题是按行集筛的自由文本,上一家的值在新一家的行里不存在 ⇒ 切 tab 后首屏被筛成「暂无商品」,'
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: [
@@ -6,9 +6,10 @@
*
* 覆盖:
* 1. **snake 参数形状**:toJdProductListParams 产出 `page`/`page_size`(默认 20、上限 100)、
* `shop_name`/`product_code`/`title_keyword`/`group_id`/`synced_from`/`synced_to`
* `product_code`/`title_keyword`/`group_id`/`synced_from`/`synced_to`
* (ISO yyyy-MM-dd;空白不下发;groupId 空串→不带、有值→snake group_id);分页钳制(铁律 15)。
* 商品状态筛选与导出参数口已随 2026-11-15 客户口径下线,不再出现在参数面。
* 商品状态筛选与导出参数口已随 2026-11-15 客户口径下线,不再出现在参数面;
* 店铺筛选同日客户口径「店铺不需要」下线(shop_name 也不在参数面)。
* 2. **详情解析**:parseJdProductDetail 解析 attrGroups/images(camel 为正 snake 容错、缺 url 弃行),
* attrGroups 解析不出时 attrJsonRaw 原文兜底;列表行解析缺 id 弃行。
*
@@ -32,7 +33,6 @@ import {
test('京东列表参数——snake 形状:groupId 空→不带、有值→group_id,日期空白/非法不下发', () => {
const full = toJdProductListParams(
{
shopName: ' 旗舰自营店 ',
productCode: ' JD-10086 ',
titleKeyword: ' 保温杯 ',
groupId: ' 7 ',
@@ -45,20 +45,20 @@ test('京东列表参数——snake 形状:groupId 空→不带、有值→gro
assert.deepEqual(full, {
page: 2,
page_size: 20,
shop_name: '旗舰自营店',
product_code: 'JD-10086',
title_keyword: '保温杯',
group_id: 7,
synced_from: '2026-11-01',
synced_to: '2026-11-09',
})
assert.equal('shop_name' in full, false, '店铺筛选已下线,参数面不再出现 shop_name')
// 全空态只有分页两项;脏值(非数字分组、非法日期)同罪不下发。
const blank = toJdProductListParams(createJdProductFilterState(), 1, 20)
assert.deepEqual(blank, { page: 1, page_size: 20 })
assert.equal('group_id' in blank, false, 'groupId 空串不带 group_id')
const dirty = toJdProductListParams(
{ shopName: ' ', productCode: '', titleKeyword: '', groupId: 'abc', syncedFrom: '2026/11/01', syncedTo: 'not-a-date' },
{ productCode: '', titleKeyword: '', groupId: 'abc', syncedFrom: '2026/11/01', syncedTo: 'not-a-date' },
1,
20,
)
@@ -1,10 +1,11 @@
/**
* 京东数据库页(v1.4 Phase 5)的挂载契约。
*
* 形态:panel-box + 筛选行(店铺/商品编码/标题关键字/分类/同步起止 date 对)+
* 形态:panel-box + 筛选行(商品编码/标题关键字/分类/分类状态/类目/同步起止 date 对)+
* 查询/重置/店铺分类 + 自绘明细表(点行开详情抽屉)+ OldPagination;
* 公司 tab 切换=清筛选重取(company-tab-wiring 同口径)。
* 商品状态筛选/列与导出按钮已随 2026-11-15 客户口径从前端下线(后端端点保留)。
* 商品状态筛选/列与导出按钮已随 2026-11-15 客户口径从前端下线(后端端点保留);
* 店铺筛选与店铺列同日客户口径「店铺不需要」下线(后端 shop_name 参数同窗撤,店铺仍收详情抽屉)。
* 不用 readFileSync(source-pin-ratchet 对台账外新文件带读点即红),全部走真实挂载断言。
*
* 跑法:`npx vitest run tests/mount/jd-database-page.mount.test.ts`
@@ -102,15 +103,14 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(wrapper.find('.jd-summary').text()).toContain('共 42 条京东商品')
})
it('行列字段与顺序对齐京麦(2026-11-15 用户口径):勾选/店铺/分组/商品信息(图+标题+编码+货号+品牌·类目+SKU/信息分)/总库存/价格/上架时间·商品状态/创建/修改/同步/操作(11 列)', async () => {
it('行列字段与顺序对齐京麦(2026-11-15 用户口径):勾选/分组/商品信息(图+标题+编码+货号+品牌·类目+SKU/信息分)/总库存/价格/上架时间·商品状态/创建/修改/同步/操作(10 列;店铺列 2026-11-15 客户口径「店铺不需要」下线)', async () => {
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
const cells = wrapper.findAll('tbody tr')[0].findAll('td')
expect(cells).toHaveLength(11)
expect(cells).toHaveLength(10)
expect(cells[0].find('input[type="checkbox"]').exists()).toBe(true, '第 1 列是勾选框')
expect(cells[1].text()).toBe('旗舰自营店', '第 2 列=店铺(admin 专属,置前)')
expect(cells[2].text()).toBe('甲组', '第 3 列=分组(admin 专属)')
expect(cells[1].text()).toBe('甲组', '第 2 列=分组(admin 专属)')
// 商品信息列=京麦同款合并布局:主图+信息分+标题+商品编码+货号+品牌·类目行+SKU 标签。
const info = cells[3]
const info = cells[2]
expect(info.find('.jd-thumb').exists()).toBe(true, '商品信息列含主图')
expect(info.text()).toContain('304不锈钢保温杯')
expect(info.text()).toContain('JD-1001', '商品编码并入商品信息列')
@@ -119,18 +119,18 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(info.text()).toContain('家居 > 厨具 > 保温杯', '类目随品牌·类目行上列表(京麦同款)')
expect(info.text()).toContain('12个SKU')
expect(info.text()).toContain('信息分 81')
expect(cells[4].text()).toBe('500', '第 4 数据列=总库存(京麦第 2 列)')
expect(cells[5].text()).toBe('12.90 ~ 15.90', '第 5 数据列=价格(京麦第 3 列)')
expect(cells[6].text()).toContain('上架中', '第 6 数据列=上架时间/商品状态(京麦合并列)')
expect(cells[6].find('.jd-sale-dot').exists()).toBe(true, '状态带京麦同款圆点')
expect(cells[7].text()).not.toBe('-', '第 7 数据列=创建时间')
expect(cells[8].text()).not.toBe('-', '第 8 数据列=修改时间')
expect(cells[9].text()).not.toBe('-', '第 9 数据列=同步时间(admin 专属,置末)')
expect(cells[10].text()).toContain('编辑', '第 10 数据列=操作(编辑/删除)')
// 表头字段名与顺序与京麦一致;品牌/类目不再是独立列(收进商品信息)。
expect(cells[3].text()).toBe('500', '第 3 数据列=总库存(京麦第 2 列)')
expect(cells[4].text()).toBe('12.90 ~ 15.90', '第 4 数据列=价格(京麦第 3 列)')
expect(cells[5].text()).toContain('上架中', '第 5 数据列=上架时间/商品状态(京麦合并列)')
expect(cells[5].find('.jd-sale-dot').exists()).toBe(true, '状态带京麦同款圆点')
expect(cells[6].text()).not.toBe('-', '第 6 数据列=创建时间')
expect(cells[7].text()).not.toBe('-', '第 7 数据列=修改时间')
expect(cells[8].text()).not.toBe('-', '第 8 数据列=同步时间(admin 专属,置末)')
expect(cells[9].text()).toContain('编辑', '第 9 数据列=操作(编辑/删除)')
// 表头字段名与顺序与京麦一致;品牌/类目不再是独立列(收进商品信息);店铺列已下线。
const headerText = wrapper.find('thead').text()
for (const gone of ['品牌', '类目']) {
expect(headerText).not.toContain(gone, `${gone}不再是独立列(京麦把它们收进商品信息)`)
for (const gone of ['品牌', '类目', '店铺']) {
expect(headerText).not.toContain(gone, `${gone}不再是独立列(品牌/类目收进商品信息;店铺 2026-11-15 下线)`)
}
for (const head of ['商品信息', '总库存', '价格', '上架时间 / 商品状态', '创建时间', '修改时间', '同步时间']) {
expect(headerText).toContain(head, `表头必须有「${head}」(京麦字段名)`)
@@ -142,7 +142,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
// beforeEach 默认 confirm=true;本例先翻回 false 验「取消不动」。
confirmMock.mockResolvedValue(false)
const opsCell = wrapper.findAll('tbody tr')[0].findAll('td')[10]
const opsCell = wrapper.findAll('tbody tr')[0].findAll('td')[9]
await opsCell.findAll('button').find((b) => b.text() === '删除')!.trigger('click')
await flushPromises()
// 防冒泡:点删除不得顺手打开详情抽屉(抽屉的可视判据=.drawer 出现)。
@@ -152,7 +152,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
// 确认后:deleteJdProducts 按 id 直删(公共库写侧无公司维度,2026-11-15 公共化)。
confirmMock.mockResolvedValue(true)
jdApi.deleteJdProducts.mockResolvedValueOnce({ deleted: 1, imagesDeleted: 0, objectsDeleted: 0, objectsKept: 0, objectsSkipped: 0 })
await wrapper.findAll('tbody tr')[0].findAll('td')[10].findAll('button').find((b) => b.text() === '删除')!.trigger('click')
await wrapper.findAll('tbody tr')[0].findAll('td')[9].findAll('button').find((b) => b.text() === '删除')!.trigger('click')
await flushPromises()
expect(jdApi.deleteJdProducts).toHaveBeenCalledWith([1])
})
@@ -181,7 +181,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
attrJsonRaw: '',
})
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
const opsCell = wrapper.findAll('tbody tr')[0].findAll('td')[10]
const opsCell = wrapper.findAll('tbody tr')[0].findAll('td')[9]
await opsCell.findAll('button').find((b) => b.text() === '编辑')!.trigger('click')
await flushPromises()
await flushPromises()
@@ -217,18 +217,17 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
it('分类读不到的那行展示「未分类」(不猜名字;2026-11-15「分组管理」改「店铺分类」只换措辞)', async () => {
const wrapper = await mountWith({ items: [item(1, { groupId: null, groupName: '' })], total: 1, page: 1, pageSize: 20 })
expect(wrapper.findAll('tbody tr')[0].findAll('td')[2].text()).toBe('未分类')
expect(wrapper.findAll('tbody tr')[0].findAll('td')[1].text()).toBe('未分类')
})
it('筛选生效:店铺/编码/关键字/分组/起止日期,查询回第一页重发', async () => {
it('筛选生效:编码/关键字/分组/起止日期,查询回第一页重发(店铺筛选 2026-11-15 下线)', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([{ id: 7, name: '甲组', sortOrder: 0, productCount: 3 }])
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
const textInputs = wrapper.findAll('.form-group input[type="text"]')
expect(textInputs).toHaveLength(3, '店铺+商品编码+标题关键字三个文本筛选框(商品状态已下线)')
await textInputs[0].setValue('旗舰自营店')
await textInputs[1].setValue('JD-1001')
await textInputs[2].setValue('保温杯')
expect(textInputs).toHaveLength(2, '商品编码+标题关键字两个文本筛选框(店铺/商品状态已下线)')
await textInputs[0].setValue('JD-1001')
await textInputs[1].setValue('保温杯')
await wrapper.find('select').setValue('7')
const dateInputs = wrapper.findAll('input[type="date"]')
await dateInputs[0].setValue('2026-11-01')
@@ -238,7 +237,6 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
const last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(last).toMatchObject({
shopName: '旗舰自营店',
productCode: 'JD-1001',
titleKeyword: '保温杯',
groupId: '7',
@@ -247,6 +245,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
page: 1,
companyId: 1,
})
expect(last).not.toHaveProperty('shopName', '店铺筛选已下线,入参不再带 shopName')
expect(last).not.toHaveProperty('saleStatus', '商品状态筛选已下线,入参不再带 saleStatus')
})
@@ -314,8 +313,8 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
it('重置把筛选面回空并回第一页重取', async () => {
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
const textInputs = wrapper.findAll('.form-group input[type="text"]')
await textInputs[0].setValue('旗舰自营店')
await textInputs[2].setValue('保温杯')
await textInputs[0].setValue('JD-1001')
await textInputs[1].setValue('保温杯')
const callsBefore = jdApi.fetchJdProductList.mock.calls.length
await wrapper.findAll('button').find((b) => b.text() === '重置')!.trigger('click')
@@ -323,7 +322,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(jdApi.fetchJdProductList.mock.calls.length).toBeGreaterThan(callsBefore)
const last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(last).toMatchObject({ shopName: '', titleKeyword: '', page: 1 }, '重置后筛选全空、回第一页')
expect(last).toMatchObject({ productCode: '', titleKeyword: '', page: 1 }, '重置后筛选全空、回第一页')
})
it('翻页与改每页条数都重发请求,改条数回第一页', async () => {
@@ -580,8 +579,8 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
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('旗舰自营店')
await textInputs[2].setValue('保温杯')
await textInputs[0].setValue('JD-1001')
await textInputs[1].setValue('保温杯')
await wrapper.find('select').setValue('7')
const callsBefore = jdApi.fetchJdProductList.mock.calls.length
@@ -592,10 +591,11 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(jdApi.fetchJdProductList.mock.calls.length).toBeGreaterThan(callsBefore)
const last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(last.companyId).toBe(2)
expect(last.shopName).toBe('', '切公司必须清掉上一家的店铺名')
expect(last.productCode).toBe('', '切公司必须清掉上一家的商品编码')
expect(last.titleKeyword).toBe('', '切公司必须清掉上一家的标题关键字')
expect(last.groupId).toBe('7', '分组全平台一份(公共),groupId 与公司维度正交——切 tab 不清')
expect(last).not.toHaveProperty('category', '切公司必须清掉上一家选的类目')
expect(last).not.toHaveProperty('shopName', '店铺筛选已下线,入参不再带 shopName')
expect(last.page).toBe(1)
// 分组选项是全局的:切 tab 不重取(首屏那一次之后就不再增长),且任何一次拉取都不带公司维度。
for (const call of jdApi.fetchJdProductGroups.mock.calls) {
@@ -67,8 +67,9 @@ import java.util.List;
* 请求里的 company_id 传参已随公共化从写侧端点摘除。</p>
*
* <p>导出端点已随 2026-11-15 客户口径「导出也不用」整段下线(控制器/服务/mapper 参数一起删);
* {@code sale_status} 查询参数同窗撤掉(商品状态筛选框已从前端下线)。DB 列
* {@code biz_jd_product.sale_status} 与详情/回传链不动。</p>
* {@code sale_status} 查询参数同窗撤掉(商品状态筛选框已从前端下线)。店铺筛选参数
* {@code shop_name} 同日客户口径「店铺不需要」同窗撤掉(前端筛选框与列下线;DB 列
* {@code biz_jd_product.shop_name} 与详情/回传链不动)。</p>
*/
@RestController
@RequiredArgsConstructor
@@ -96,7 +97,6 @@ public class AdminJdProductController {
public ApiResponse<JdProductPageVo> page(
@Parameter(description = "页码") @RequestParam(name = "page", defaultValue = PageDefaults.FIRST_PAGE) Long page,
@Parameter(description = "每页数量") @RequestParam(name = "page_size", defaultValue = PageDefaults.JD_PRODUCTS_PAGE_SIZE) Long pageSize,
@Parameter(description = "店铺名(包含匹配)") @RequestParam(name = "shop_name", required = false) String shopName,
@Parameter(description = "商品编码(包含匹配)") @RequestParam(name = "product_code", required = false) String productCode,
@Parameter(description = "标题关键词(包含匹配)") @RequestParam(name = "title_keyword", required = false) String titleKeyword,
@Parameter(description = "类目(京麦末级类目名,eq)") @RequestParam(name = "category", required = false) String category,
@@ -116,7 +116,7 @@ public class AdminJdProductController {
// 公司维度只剩超管的公司 tab 筛选(superAdminScopedCompanyId):超管显式传才收窄,
// 非超管传什么都不收——公共库对每一家管理员都是同一份全量。
Long scopedCompanyId = dataReadScope.superAdminScopedCompanyId(user, companyId);
return ApiResponse.success(jdProductQueryService.page(page, pageSize, scopedCompanyId, shopName,
return ApiResponse.success(jdProductQueryService.page(page, pageSize, scopedCompanyId,
productCode, titleKeyword, category, groupId, ungrouped, grouped, syncedFrom, syncedTo));
}
@@ -42,13 +42,13 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
/**
* 后管只读页总数(Phase 5,v1.4):与 {@link #selectProductPage} 同一过滤面
* (公司/店铺名/商品编码/标题关键词/类目/分组/未分类/已分类/同步起止,全部 SQL 侧下推,
* (公司/商品编码/标题关键词/类目/分组/未分类/已分类/同步起止,全部 SQL 侧下推,
* 铁律 20)。{@code companyId}/{@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("shopName") String shopName,
@Param("productCode") String productCode,
@Param("titleKeyword") String titleKeyword,
@Param("category") String category,
@@ -91,7 +91,6 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
* {@code (page-1)*page_size} 溢出(铁律 15),mapper 不做第二次换算,避免两处各算各的。</p>
*/
List<JdProductEntity> selectProductPage(@Param("companyId") Long companyId,
@Param("shopName") String shopName,
@Param("productCode") String productCode,
@Param("titleKeyword") String titleKeyword,
@Param("category") String category,
@@ -47,7 +47,8 @@ import java.util.Map;
* 主表高频列直接从 entity 映射,不走 JSON。</p>
*
* <p>导出(byte[] xlsx)已随 2026-11-15 客户口径「导出也不用」整段下线,控制器端点同窗删;
* {@code sale_status} 过滤参数同窗撤掉(前端筛选框下线),DB 列与详情/回传链不动。</p>
* {@code sale_status} 过滤参数同窗撤掉(前端筛选框下线);店铺筛选参数同日客户口径
* 「店铺不需要」同窗撤掉(DB 列与详情/回传链不动)。</p>
*/
@Slf4j
@Service
@@ -74,12 +75,12 @@ public class JdProductQueryService {
/**
* 分页查询商品行({@code synced_at} 倒序)。
*
* <p>过滤面:公司(物化列 eq)、店铺名 contains、商品编码 contains、标题关键词 contains、
* <p>过滤面:公司(物化列 eq)、商品编码 contains、标题关键词 contains、
* 类目 eq、分组 eq、未分类(group_id IS NULL,店铺分类弹窗「未分类」范围)、
* 已分类(group_id IS NOT NULL,页面筛选行「分类状态」档,2026-11-15 客户口径
* 「查询已分类的跟未分类,分类好的可以不显示」)、同步起止(datetime 闭区间)。</p>
*/
public JdProductPageVo page(Long page, Long pageSize, Long scopedCompanyId, String shopName,
public JdProductPageVo page(Long page, Long pageSize, Long scopedCompanyId,
String productCode, String titleKeyword, String category, Long groupId, Boolean ungrouped,
Boolean grouped, LocalDateTime syncedFrom, LocalDateTime syncedTo) {
if (syncedFrom != null && syncedTo != null && syncedFrom.isAfter(syncedTo)) {
@@ -88,13 +89,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, shopName, productCode, titleKeyword, category,
Filter filter = filter(scopedCompanyId, productCode, titleKeyword, category,
groupId, ungrouped, grouped, syncedFrom, syncedTo);
long total = jdProductMapper.countProducts(filter.companyId(), filter.shopName(), filter.productCode(),
long total = jdProductMapper.countProducts(filter.companyId(), 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.shopName(), filter.productCode(),
: jdProductMapper.selectProductPage(filter.companyId(), filter.productCode(),
filter.titleKeyword(), filter.category(), filter.groupId(), filter.ungrouped(),
filter.grouped(), filter.syncedFrom(), filter.syncedTo(),
(safePage - 1) * safeSize, (int) safeSize);
@@ -173,12 +174,12 @@ public class JdProductQueryService {
// ---------------------------------------------------------------- 过滤面
/** 服务侧过滤面归一:companyId/groupId ≤0 按没选处理,文本 trim 后空串归 null。 */
private record Filter(Long companyId, String shopName, String productCode, String titleKeyword,
private record Filter(Long companyId, String productCode, String titleKeyword,
String category, Long groupId, Boolean ungrouped, Boolean grouped,
LocalDateTime syncedFrom, LocalDateTime syncedTo) {
}
private static Filter filter(Long scopedCompanyId, String shopName, String productCode, String titleKeyword,
private static Filter filter(Long scopedCompanyId, String productCode, String titleKeyword,
String category, Long groupId, Boolean ungrouped, Boolean grouped,
LocalDateTime syncedFrom, LocalDateTime syncedTo) {
Long companyId = scopedCompanyId != null && scopedCompanyId > 0 ? scopedCompanyId : null;
@@ -188,7 +189,7 @@ public class JdProductQueryService {
// 已分类同口径:true=只看 group_id IS NOT NULL 的行;与未分类同选时 SQL 侧两谓词相与=空集
// (前端下拉是单选,正常到不了这个组合)。
Boolean safeGrouped = Boolean.TRUE.equals(grouped) ? Boolean.TRUE : null;
return new Filter(companyId, trimToNull(shopName), trimToNull(productCode), trimToNull(titleKeyword),
return new Filter(companyId, trimToNull(productCode), trimToNull(titleKeyword),
trimToNull(category), safeGroupId, safeUngrouped, safeGrouped, syncedFrom, syncedTo);
}
@@ -100,16 +100,16 @@
)
</select>
<!-- 后管只读页(Phase 5,v1.4)过滤面:公司(物化列 eq)、店铺名/商品编码/标题关键词
<!-- 后管只读页(Phase 5,v1.4)过滤面:公司(物化列 eq)、商品编码/标题关键词
(contains LIKE)、类目 eq、分组 eq、未分类(group_id IS NULL,店铺分类弹窗
「未分类」范围)、已分类(group_id IS NOT NULL,页面筛选行「分类状态」档,
2026-11-15 客户口径「查询已分类的跟未分类,分类好的可以不显示」)、
同步起止(datetime 闭区间)。
sale_status 筛选随 2026-11-15 客户口径撤掉(前端筛选框下线;列本身与详情/回传链不动)。
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="shopName != null and shopName != ''">AND p.shop_name LIKE CONCAT('%', #{shopName}, '%')</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>
@@ -127,12 +127,14 @@ class AdminJdProductControllerTest {
@Test
void 分页参数snake且带默认值() throws IOException {
String source = stripComments(Files.readString(CONTROLLER));
for (String param : List.of("page_size", "shop_name", "product_code", "title_keyword",
for (String param : List.of("page_size", "product_code", "title_keyword",
"group_id", "ungrouped", "grouped", "synced_from", "synced_to", "company_id")) {
assertTrue(source.contains(param), "查询参数必须 snake_case:" + param);
}
// 商品状态筛选框已随 2026-11-15 客户口径从前端下线 ⇒ 服务端同名参数一起撤(反向钉住防回潜)。
assertFalse(source.contains("\"sale_status\""), "sale_status 筛选参数必须已删除,不得回潜");
// 店铺筛选同日客户口径「店铺不需要」下线 ⇒ shop_name 参数同窗撤(反向钉住防回潜)。
assertFalse(source.contains("shop_name"), "shop_name 筛选参数必须已删除,不得回潜(店铺列/详情仍保留)");
assertTrue(source.contains("PageDefaults"), "page/page_size 默认值必须取 PageDefaults"
+ "(page_size 默认 20=PageDefaults.JD_PRODUCTS_PAGE_SIZE);"
+ "page 钳制防 (page-1)*page_size 溢出的行为样本见查询服务钳制支(铁律 15)");
@@ -196,13 +198,13 @@ class AdminJdProductControllerTest {
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, null)).thenReturn(pageVo);
when(queryService.page(1L, 20L, 5L, null, null, null, null, null, null, null, null)).thenReturn(pageVo);
ApiResponse<JdProductPageVo> response = controller.page(1L, 20L, null, null, null, null, null,
null, null, null, null, 5L, request);
null, null, null, 5L, request);
verify(dataReadScope).superAdminScopedCompanyId(operator, 5L);
verify(queryService).page(1L, 20L, 5L, null, null, null, null, null, null, null, null, null);
verify(queryService).page(1L, 20L, 5L, null, null, null, null, null, null, null, null);
assertEquals(Boolean.TRUE, response.isSuccess(), "拒绝走 403 业务码,放行必须是 success 信封(B80-03)");
assertEquals(pageVo, response.getData());
}
@@ -324,23 +326,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(), any())).thenReturn(1L);
when(mapper.countProducts(any(), 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, null);
service.page(0L, null, 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(), isNull(), offset.capture(), limit.capture());
isNull(), 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, null);
service.page(Long.MAX_VALUE, 500L, null, 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(), any(), offsetMax.capture(), limitMax.capture());
any(), any(), any(), offsetMax.capture(), limitMax.capture());
assertEquals(999_900L, offsetMax.getValue(), "(page-1)*page_size 最大 999_900,钳制后不得溢出变负");
assertEquals(100, limitMax.getValue());
}
@@ -354,9 +356,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, null, from, to));
() -> service.page(1L, 20L, null, 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(), any());
verify(mapper, never()).countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any());
}
@Test
@@ -365,37 +367,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(), any())).thenReturn(0L);
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(0L);
// 超管显式传 5 ⇒ 按公司 5 筛(收窄);groupId ≤0 按没选分组处理;文本两侧空白剥掉。
// 类目(京麦末级类目名)走同一过滤面:传值原样直传、空白归 null。
service.page(1L, 20L, 5L, " 店铺甲 ", " SKU-1 ", " 连衣裙 ", " 艺考形体服 ", 0L, null, null, null, null);
verify(mapper).countProducts(eq(5L), eq("店铺甲"), eq("SKU-1"), eq("连衣裙"),
service.page(1L, 20L, 5L, " SKU-1 ", " 连衣裙 ", " 艺考形体服 ", 0L, null, null, null, null);
verify(mapper).countProducts(eq(5L), 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, null);
service.page(1L, 20L, null, null, null, null, null, null, null, null, null);
verify(mapper).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
isNull(), isNull(), isNull(), isNull(), isNull());
isNull(), isNull(), isNull(), isNull());
// 未分类范围(店铺分类弹窗「未分类」页签):ungrouped=true 原样下推到 SQL 侧。
service.page(1L, 20L, null, null, null, null, null, null, Boolean.TRUE, null, null, null);
service.page(1L, 20L, null, null, null, null, null, Boolean.TRUE, null, null, null);
verify(mapper).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
isNull(), eq(Boolean.TRUE), 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, null, Boolean.FALSE, null, null, null);
service.page(1L, 20L, null, 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(), isNull(), isNull());
// 已分类档(页面筛选行「分类状态」=已分类,2026-11-15 客户口径「分类好的可以不显示」反选):
// grouped=true 原样下推到 SQL 侧(group_id IS NOT NULL),ungrouped 不动。
service.page(1L, 20L, null, null, null, null, null, null, null, Boolean.TRUE, null, null);
service.page(1L, 20L, null, null, null, null, null, null, Boolean.TRUE, null, null);
verify(mapper).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
isNull(), isNull(), eq(Boolean.TRUE), isNull(), isNull());
isNull(), eq(Boolean.TRUE), isNull(), isNull());
// grouped=false / 缺省同口径归一成 null(不进 IS NOT NULL 分支);与②「全量」累计 3 次。
service.page(1L, 20L, null, null, null, null, null, null, null, Boolean.FALSE, null, null);
service.page(1L, 20L, null, 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(), isNull(), isNull());
}
@Test
@@ -596,8 +598,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(), any())).thenReturn(2L);
when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(),
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(),
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();
@@ -605,7 +607,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, null);
JdProductPageVo vo = service.page(1L, 20L, 5L, null, null, null, null, null, null, null, null);
assertEquals("秋冬款", vo.getItems().get(0).getGroupName(), "行集 group_id 一次取齐分组名(无逐行查询)");
assertNull(vo.getItems().get(1).getGroupName(), "分组已删=不猜名字(铁律 30),前端展示 -");