feat(jd): 京东数据库分组改店铺分类+左右分栏弹窗人工归类
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
/** 京东数据库页(v1.4 Phase 5):公共的京东商品库(2026-11-15 用户定案「不区分公司、属于
|
||||
* 公共的」,分组同亚马逊口径全平台一份),筛选行(店铺/商品编码/标题关键字/分组/类目/
|
||||
* 同步起止 date 对)+查询/重置/管理分组 + 自绘明细表(勾选列+点行开详情抽屉)
|
||||
* 公共的」,分类同亚马逊口径全平台一份),筛选行(店铺/商品编码/标题关键字/分类/类目/
|
||||
* 同步起止 date 对)+查询/重置/店铺分类 + 自绘明细表(勾选列+点行开详情抽屉)
|
||||
* + 删除(单行/批量,先删桶对象、全成功才删库行,确认弹窗点名数量)+ OldPagination。
|
||||
* 公司维度只剩超管的公司 tab(=筛选管理员,非超管没有这个筛选、看到同一份公共全量);
|
||||
* 列表按京麦商品列表样式(2026-11-15 用户口径):店铺/分组前置为第 1/2 列;商品信息列=京麦同款
|
||||
* 列表按京麦商品列表样式(2026-11-15 用户口径):店铺/分类前置为第 1/2 列;商品信息列=京麦同款
|
||||
* 合并布局(主图+图下信息分+标题两行+商品编码/货号+SKU 数标签,编码带一键复制);类目/上架
|
||||
* 时间/京东创建/修改时间仍收详情抽屉基本信息(B104「详情显示全部属性」口径不变)。
|
||||
* 商品状态筛选框/列与导出按钮随 2026-11-15 客户口径「这两个不要/导出也不用」从前端下线
|
||||
@@ -254,7 +254,7 @@ onMounted(() => {
|
||||
<section class="panel-box">
|
||||
<div class="jd-panel-head">
|
||||
<h3>京东数据库</h3>
|
||||
<button class="btn btn-secondary" type="button" @click="groupDialogVisible = true">管理分组</button>
|
||||
<button class="btn btn-secondary" type="button" @click="groupDialogVisible = true">店铺分类</button>
|
||||
</div>
|
||||
|
||||
<div class="jd-filter-row">
|
||||
@@ -271,10 +271,11 @@ onMounted(() => {
|
||||
<input v-model="filter.titleKeyword" type="text" placeholder="输入标题关键字" @keyup.enter="apply" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>分组</label>
|
||||
<!-- 分组选中即查:选完立刻按该分组过滤刷新(回第一页),不必再点查询。 -->
|
||||
<label>分类</label>
|
||||
<!-- 分类选中即查:选完立刻按该分类过滤刷新(回第一页),不必再点查询。
|
||||
(2026-11-15「分组管理」改「店铺分类」:同一 group 实体,只改界面措辞。) -->
|
||||
<select v-model="filter.groupId" @change="apply">
|
||||
<option value="">全部分组</option>
|
||||
<option value="">全部分类</option>
|
||||
<option v-for="group in groupOptions" :key="group.id" :value="String(group.id)">{{ group.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
@@ -321,7 +322,7 @@ onMounted(() => {
|
||||
<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 style="width: 96px">分类</th>
|
||||
<th>商品信息</th>
|
||||
<th style="width: 76px">总库存</th>
|
||||
<th style="width: 120px">价格</th>
|
||||
@@ -337,7 +338,7 @@ onMounted(() => {
|
||||
<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 :title="row.groupName || ''">{{ row.groupName || '未分类' }}</td>
|
||||
<td class="jd-info-cell">
|
||||
<div class="jd-info-wrap">
|
||||
<div class="jd-info-figure">
|
||||
|
||||
@@ -0,0 +1,469 @@
|
||||
<script setup lang="ts">
|
||||
/** 京东店铺分类弹窗右栏:商品人工归类面板(2026-11-15 从 JdProductGroupDialog 拆出,
|
||||
* 独立件也守可读棘轮的 800 行报警线)。范围切换(全部/未分类/当前分类)+标题关键字搜索
|
||||
* +勾选行 →「归入所选分类」/「移出分类」。归类走批量端点
|
||||
* POST /api/admin/jd-products/batch-assign-group:后端与单行编辑同口径置 manual_locked=1
|
||||
* (归类即人工干预,采集 upsert/覆盖清理不再碰该行,分类永不丢;代价是该行价格/库存随锁
|
||||
* 停更——弹窗提示语点名这个后果)。取数复用 fetchJdProductList(不带公司维度,
|
||||
* company-tab-wiring 只认两个公司维度发送口);「未分类」走 ungrouped 参数。
|
||||
* 归类目标(selectedGroup)由左栏(父件)点亮下发;弹窗壳 v-if 整树重建 ⇒ 每次打开即本件
|
||||
* 重挂载、onMounted 自取首屏行集。成功后 emit('changed') 让父件刷新分类商品数并上抛页面;
|
||||
* 业务失败把后端中文文案展示在本面板红条内。 */
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { batchAssignJdProductGroup, fetchJdProductList } from './jd-product-api.ts'
|
||||
import type { JdProductGroup } from './jd-product-api.ts'
|
||||
import type { JdProductItem } from './jd-product-model.ts'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { requestErrorMessage } from '../../api/envelope.ts'
|
||||
|
||||
const props = defineProps<{
|
||||
/** 左栏点亮的分类=归类目标;null=尚未点亮(「归入」按钮置灰)。 */
|
||||
selectedGroup: JdProductGroup | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{ (event: 'changed'): void }>()
|
||||
|
||||
type Scope = 'all' | 'ungrouped' | 'current'
|
||||
const scope = ref<Scope>('all')
|
||||
const keyword = ref('')
|
||||
const PRODUCT_PAGE_SIZE = 20
|
||||
const products = ref<JdProductItem[]>([])
|
||||
const productTotal = ref(0)
|
||||
const productPage = ref(1)
|
||||
const productsLoading = ref(false)
|
||||
const productsError = ref('')
|
||||
/** 本页勾选集(按行 id):切范围/翻页/重取后清空,防「看不见的勾选被一起归类」。 */
|
||||
const selectedProductIds = ref<Set<number>>(new Set())
|
||||
const assigning = ref(false)
|
||||
|
||||
const selectedCount = computed(() => selectedProductIds.value.size)
|
||||
/** 归入所选分类:必须先在左侧点亮一个分类且有勾选行。 */
|
||||
const canAssign = computed(() => !!props.selectedGroup && selectedCount.value > 0 && !assigning.value)
|
||||
const canRemove = computed(() => selectedCount.value > 0 && !assigning.value)
|
||||
const allSelected = computed(() =>
|
||||
products.value.length > 0 && products.value.every((row) => selectedProductIds.value.has(row.id)))
|
||||
|
||||
async function loadProducts(): Promise<void> {
|
||||
productsLoading.value = true
|
||||
productsError.value = ''
|
||||
try {
|
||||
const result = await fetchJdProductList({
|
||||
page: productPage.value,
|
||||
pageSize: PRODUCT_PAGE_SIZE,
|
||||
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
|
||||
if (result.page >= 1) productPage.value = result.page
|
||||
selectedProductIds.value = new Set()
|
||||
} catch (error) {
|
||||
productsError.value = requestErrorMessage(error) || '商品列表加载失败'
|
||||
products.value = []
|
||||
productTotal.value = 0
|
||||
selectedProductIds.value = new Set()
|
||||
} finally {
|
||||
productsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function pickScope(next: Scope): void {
|
||||
if (next === 'current' && !props.selectedGroup) return
|
||||
if (scope.value === next) return
|
||||
scope.value = next
|
||||
productPage.value = 1
|
||||
void loadProducts()
|
||||
}
|
||||
|
||||
function searchProducts(): void {
|
||||
productPage.value = 1
|
||||
void loadProducts()
|
||||
}
|
||||
|
||||
function changeProductPage(next: number): void {
|
||||
if (next < 1 || next === productPage.value) return
|
||||
productPage.value = next
|
||||
void loadProducts()
|
||||
}
|
||||
|
||||
function toggleSelect(row: JdProductItem, checked: boolean): void {
|
||||
const next = new Set(selectedProductIds.value)
|
||||
if (checked) next.add(row.id)
|
||||
else next.delete(row.id)
|
||||
selectedProductIds.value = next
|
||||
}
|
||||
|
||||
function toggleSelectAll(checked: boolean): void {
|
||||
selectedProductIds.value = checked ? new Set(products.value.map((row) => row.id)) : new Set()
|
||||
}
|
||||
|
||||
/** 勾选行 → 归入左栏点亮的分类。成功后分类商品数(父件)与右栏行集都刷新(归类过的行离开「未分类」)。 */
|
||||
async function assignToSelected(): Promise<void> {
|
||||
const target = props.selectedGroup
|
||||
if (!target || !canAssign.value) return
|
||||
assigning.value = true
|
||||
productsError.value = ''
|
||||
try {
|
||||
const updated = await batchAssignJdProductGroup([...selectedProductIds.value], target.id)
|
||||
showAdminFeedback(`已把 ${updated} 个商品归入「${target.name}」`, 'success')
|
||||
emit('changed')
|
||||
await loadProducts()
|
||||
} catch (error) {
|
||||
productsError.value = requestErrorMessage(error) || '归类失败,请稍后重试'
|
||||
} finally {
|
||||
assigning.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 勾选行 → 移出分类(group_id 置 NULL,回到未分类)。 */
|
||||
async function removeFromCategory(): Promise<void> {
|
||||
if (!canRemove.value) return
|
||||
assigning.value = true
|
||||
productsError.value = ''
|
||||
try {
|
||||
const updated = await batchAssignJdProductGroup([...selectedProductIds.value], null)
|
||||
showAdminFeedback(`已把 ${updated} 个商品移出分类`, 'success')
|
||||
emit('changed')
|
||||
await loadProducts()
|
||||
} catch (error) {
|
||||
productsError.value = requestErrorMessage(error) || '移出分类失败,请稍后重试'
|
||||
} finally {
|
||||
assigning.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 目标分类变化(左栏点亮/删除):右栏停在「当前分类」页签时随点亮对象换行集;
|
||||
// 目标被删(null)=「当前分类」没了,拉回全量页签,不留在空集页签里。
|
||||
watch(
|
||||
() => props.selectedGroup,
|
||||
(group) => {
|
||||
if (scope.value !== 'current') return
|
||||
if (group && group.id > 0) {
|
||||
productPage.value = 1
|
||||
void loadProducts()
|
||||
} else {
|
||||
scope.value = 'all'
|
||||
productPage.value = 1
|
||||
void loadProducts()
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
void loadProducts()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="right-pane">
|
||||
<div class="product-toolbar">
|
||||
<div class="scope-tabs">
|
||||
<button type="button" :class="{ on: scope === 'all' }" @click="pickScope('all')">全部</button>
|
||||
<button type="button" :class="{ on: scope === 'ungrouped' }" @click="pickScope('ungrouped')">未分类</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ on: scope === 'current' }"
|
||||
:disabled="!selectedGroup"
|
||||
:title="selectedGroup ? `只看「${selectedGroup.name}」下的商品` : '先在左侧点选一个分类'"
|
||||
@click="pickScope('current')"
|
||||
>当前分类</button>
|
||||
</div>
|
||||
<input v-model="keyword" type="text" class="keyword-input" placeholder="标题关键字" @keyup.enter="searchProducts" />
|
||||
<button class="btn btn-small" type="button" @click="searchProducts">查询</button>
|
||||
</div>
|
||||
<p v-if="productsError" class="pane-error">
|
||||
{{ productsError }}
|
||||
<button class="btn btn-secondary btn-mini" type="button" @click="loadProducts">重试</button>
|
||||
</p>
|
||||
|
||||
<div class="product-list">
|
||||
<table v-if="products.length">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-check"><input type="checkbox" :checked="allSelected" @change="toggleSelectAll(($event.target as HTMLInputElement).checked)" /></th>
|
||||
<th>商品信息</th>
|
||||
<th class="col-group">当前分类</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="row in products" :key="row.id">
|
||||
<td class="col-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selectedProductIds.has(row.id)"
|
||||
@change="toggleSelect(row, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<div class="product-cell">
|
||||
<img v-if="row.mainImageUrl" class="product-thumb" :src="row.mainImageUrl" alt="" loading="lazy" />
|
||||
<span v-else class="product-thumb product-thumb-empty">无图</span>
|
||||
<div class="product-body">
|
||||
<div class="product-title" :title="row.title">{{ row.title || '-' }}</div>
|
||||
<div class="product-meta">商品编码:{{ row.productCode || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="col-group" :title="row.groupName || ''">{{ row.groupName || '未分类' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p v-else-if="productsLoading" class="pane-tip">加载中...</p>
|
||||
<p v-else-if="!productsError" class="pane-tip">没有符合条件的商品</p>
|
||||
</div>
|
||||
|
||||
<div class="product-footer">
|
||||
<span class="pick-summary">已勾选 {{ selectedCount }} 个商品</span>
|
||||
<div class="footer-actions">
|
||||
<button class="btn btn-small" type="button" :disabled="!canAssign" @click="assignToSelected">
|
||||
{{ assigning ? '归类中...' : selectedGroup ? `归入「${selectedGroup.name}」` : '归入所选分类' }}
|
||||
</button>
|
||||
<button class="btn btn-danger btn-small" type="button" :disabled="!canRemove" @click="removeFromCategory">移出分类</button>
|
||||
</div>
|
||||
</div>
|
||||
<OldPagination
|
||||
:total="productTotal"
|
||||
:page="productPage"
|
||||
:page-size="PRODUCT_PAGE_SIZE"
|
||||
:sizes="[PRODUCT_PAGE_SIZE]"
|
||||
:jump="false"
|
||||
@change="changeProductPage"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.right-pane {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-left: 14px;
|
||||
}
|
||||
.product-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.scope-tabs {
|
||||
display: flex;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 9px;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.scope-tabs button {
|
||||
min-height: 34px;
|
||||
padding: 5px 14px;
|
||||
border: 0;
|
||||
border-right: 1px solid #e7eef5;
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.scope-tabs button:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
.scope-tabs button:hover:not(:disabled):not(.on) {
|
||||
background: #edf5fb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.scope-tabs button.on {
|
||||
background: #4f78a5;
|
||||
color: #ffffff;
|
||||
}
|
||||
.scope-tabs button:disabled {
|
||||
color: #9baaba;
|
||||
background: #eef3f7;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.keyword-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 36px;
|
||||
padding: 6px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
}
|
||||
.keyword-input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
}
|
||||
.pane-error {
|
||||
margin: 0 0 8px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #f0c9c2;
|
||||
border-radius: 10px;
|
||||
background: #fdf1ef;
|
||||
color: #a04432;
|
||||
font-size: 13px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
/* 错误条右缘的重试入口:一条真能办成事的出口(重试绑页内 loadProducts,守卫 load-failure-visibility 钉)。 */
|
||||
.pane-error .btn {
|
||||
margin-left: auto;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.pane-tip {
|
||||
margin: 10px 2px;
|
||||
color: #8293a5;
|
||||
font-size: 13px;
|
||||
}
|
||||
.product-list {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.product-list table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.product-list th,
|
||||
.product-list td {
|
||||
padding: 8px 12px;
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
border-bottom: 1px solid #e7eef5;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.product-list th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.product-list tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.product-list tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.col-check {
|
||||
width: 42px;
|
||||
}
|
||||
.col-check input {
|
||||
margin: 0;
|
||||
}
|
||||
.col-group {
|
||||
width: 140px;
|
||||
color: #7b8a99;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.product-cell {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
}
|
||||
.product-thumb {
|
||||
flex-shrink: 0;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
object-fit: cover;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 6px;
|
||||
background: #f2f7fb;
|
||||
}
|
||||
.product-thumb-empty {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #8293a5;
|
||||
font-size: 12px;
|
||||
}
|
||||
.product-body {
|
||||
min-width: 0;
|
||||
}
|
||||
.product-title {
|
||||
color: #24384d;
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-all;
|
||||
}
|
||||
.product-meta {
|
||||
margin-top: 2px;
|
||||
color: #7b8a99;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.product-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.pick-summary {
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.footer-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-left: auto;
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 38px;
|
||||
padding: 7px 16px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.btn-small {
|
||||
min-height: 34px;
|
||||
padding: 5px 13px;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.btn-danger {
|
||||
background: #ffffff;
|
||||
color: #a04432;
|
||||
border-color: #e4b3a8;
|
||||
}
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: #fdf1ef;
|
||||
border-color: #d08a7b;
|
||||
}
|
||||
/* 弹窗里的分页贴右、收紧行高(页内版式在弹窗内偏大)。 */
|
||||
:deep(.old-pagination) {
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -146,7 +146,7 @@ function dash(value: string | number | null | undefined): string {
|
||||
<div class="info-item"><dt>总库存</dt><dd>{{ dash(item?.stockTotal) }}</dd></div>
|
||||
<div class="info-item"><dt>状态</dt><dd>{{ dash(item?.saleStatus) }}</dd></div>
|
||||
<div class="info-item"><dt>店铺</dt><dd :title="item?.shopName || ''">{{ dash(item?.shopName) }}</dd></div>
|
||||
<div class="info-item"><dt>分组</dt><dd>{{ dash(item?.groupName || '未分组') }}</dd></div>
|
||||
<div class="info-item"><dt>分类</dt><dd>{{ dash(item?.groupName || '未分类') }}</dd></div>
|
||||
<div class="info-item"><dt>上架时间</dt><dd>{{ item?.jdOnlineAt ? formatDateTime(item.jdOnlineAt) : '-' }}</dd></div>
|
||||
<div class="info-item"><dt>京东创建时间</dt><dd>{{ item?.jdCreatedAt ? formatDateTime(item.jdCreatedAt) : '-' }}</dd></div>
|
||||
<div class="info-item"><dt>京东修改时间</dt><dd>{{ item?.jdUpdatedAt ? formatDateTime(item.jdUpdatedAt) : '-' }}</dd></div>
|
||||
|
||||
@@ -263,9 +263,9 @@ function dash(value: string | number | null | undefined): string {
|
||||
<input v-model="form.stockTotal" type="text" inputmode="numeric" />
|
||||
</div>
|
||||
<div class="edit-item">
|
||||
<label>分组</label>
|
||||
<label>分类</label>
|
||||
<select v-model="form.groupId">
|
||||
<option value="">未分组</option>
|
||||
<option value="">未分类</option>
|
||||
<option v-for="group in groupOptions" :key="group.id" :value="String(group.id)">
|
||||
{{ group.name }}
|
||||
</option>
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
/** 京东商品分组管理弹窗(v1.4 Phase 5):新建/改名/删除,重名等业务失败把后端返回的中文文案
|
||||
* 原样展示在弹窗内(envelope code 非 0 → errorTextOf);删除前 openAdminConfirm 二次确认;
|
||||
* 变更成功后 emit('changed'),由页面刷新分组下拉与列表。 */
|
||||
/** 京东商品「店铺分类」弹窗(2026-11-15 由「分组管理」小弹窗重做):左右分栏——左栏分类管理
|
||||
* (新建/改名/删除;分组全平台一份、措辞「分类」),右栏商品人工归类(独立件
|
||||
* JdProductAssignPane:范围切换+搜索+勾选 →「归入所选分类」/「移出分类」,批量端点
|
||||
* batch-assign-group 与单行编辑同口径置 manual_locked=1——归类即人工干预,采集不再覆盖/
|
||||
* 清理该行)。左栏点亮的分类=右栏归类目标;目标被删时右栏自动拉回全量页签。
|
||||
* 重名等业务失败把后端返回的中文文案原样展示在弹窗内(envelope code 非 0 → errorTextOf);
|
||||
* 删除分类前 openAdminConfirm 二次确认;变更成功后 emit('changed'),由页面刷新分组下拉与
|
||||
* 列表。弹窗壳 v-if 整树重建 ⇒ 每次打开即两个面板都重新拉数据,无需手动重置。 */
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import {
|
||||
createJdProductGroup,
|
||||
@@ -10,6 +15,7 @@ import {
|
||||
updateJdProductGroup,
|
||||
type JdProductGroup,
|
||||
} from './jd-product-api.ts'
|
||||
import JdProductAssignPane from './JdProductAssignPane.vue'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import { requestErrorMessage } from '../../api/envelope.ts'
|
||||
|
||||
@@ -19,6 +25,8 @@ const props = defineProps<{
|
||||
|
||||
const emit = defineEmits<{ (event: 'close'): void; (event: 'changed'): void }>()
|
||||
|
||||
// ---------------- 左栏:分类管理(分组全平台一份,界面措辞「分类」) ----------------
|
||||
|
||||
const loading = ref(false)
|
||||
const errorText = ref('')
|
||||
const groups = ref<JdProductGroup[]>([])
|
||||
@@ -26,12 +34,15 @@ const groups = ref<JdProductGroup[]>([])
|
||||
const createName = ref('')
|
||||
const createSortOrder = ref(0)
|
||||
const creating = ref(false)
|
||||
/** 改名:正在编辑的分组 id 与草稿名。 */
|
||||
/** 改名:正在编辑的分类 id 与草稿名。 */
|
||||
const editingId = ref(0)
|
||||
const editingName = ref('')
|
||||
const saving = ref(false)
|
||||
/** 左侧点亮的分类=右栏「归入所选分类」的归类目标;删除后自动清掉。 */
|
||||
const selectedGroupId = ref(0)
|
||||
|
||||
const canCreate = computed(() => createName.value.trim().length > 0 && !creating.value && !saving.value)
|
||||
const selectedGroup = computed(() => groups.value.find((group) => group.id === selectedGroupId.value) || null)
|
||||
|
||||
async function loadGroups(): Promise<void> {
|
||||
loading.value = true
|
||||
@@ -39,7 +50,7 @@ async function loadGroups(): Promise<void> {
|
||||
try {
|
||||
groups.value = await fetchJdProductGroups()
|
||||
} catch (error) {
|
||||
errorText.value = requestErrorMessage(error) || '分组列表加载失败'
|
||||
errorText.value = requestErrorMessage(error) || '分类列表加载失败'
|
||||
groups.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -50,6 +61,12 @@ function sortGroups(list: JdProductGroup[]): JdProductGroup[] {
|
||||
return [...list].sort((a, b) => a.sortOrder - b.sortOrder || a.id - b.id)
|
||||
}
|
||||
|
||||
/** 变更后统一收口:刷新左栏商品数徽标+上抛页面(分组下拉与行集都依赖它)。 */
|
||||
async function refreshAfterChange(): Promise<void> {
|
||||
groups.value = sortGroups(await fetchJdProductGroups())
|
||||
emit('changed')
|
||||
}
|
||||
|
||||
async function submitCreate(): Promise<void> {
|
||||
const name = createName.value.trim()
|
||||
if (!name || creating.value) return
|
||||
@@ -59,10 +76,9 @@ async function submitCreate(): Promise<void> {
|
||||
await createJdProductGroup({ name, sortOrder: Math.floor(createSortOrder.value) || 0 })
|
||||
createName.value = ''
|
||||
createSortOrder.value = 0
|
||||
groups.value = sortGroups(await fetchJdProductGroups())
|
||||
emit('changed')
|
||||
await refreshAfterChange()
|
||||
} catch (error) {
|
||||
errorText.value = requestErrorMessage(error) || '新建分组失败'
|
||||
errorText.value = requestErrorMessage(error) || '新建分类失败'
|
||||
} finally {
|
||||
creating.value = false
|
||||
}
|
||||
@@ -87,8 +103,7 @@ async function submitRename(group: JdProductGroup): Promise<void> {
|
||||
try {
|
||||
await updateJdProductGroup(group.id, { name, sortOrder: group.sortOrder })
|
||||
cancelRename()
|
||||
groups.value = sortGroups(await fetchJdProductGroups())
|
||||
emit('changed')
|
||||
await refreshAfterChange()
|
||||
} catch (error) {
|
||||
errorText.value = requestErrorMessage(error) || '改名失败'
|
||||
} finally {
|
||||
@@ -97,21 +112,31 @@ async function submitRename(group: JdProductGroup): Promise<void> {
|
||||
}
|
||||
|
||||
async function removeGroup(group: JdProductGroup): Promise<void> {
|
||||
const ok = await openAdminConfirm({ title: '删除分组', message: `确定删除分组「${group.name}」吗?删除后该组商品回到未分组。`, confirmText: '确认删除', danger: true })
|
||||
const ok = await openAdminConfirm({ title: '删除分类', message: `确定删除分类「${group.name}」吗?删除后该分类下 ${group.productCount} 个商品回到未分类。`, confirmText: '确认删除', danger: true })
|
||||
if (!ok || saving.value) return
|
||||
saving.value = true
|
||||
errorText.value = ''
|
||||
try {
|
||||
await deleteJdProductGroup(group.id)
|
||||
groups.value = sortGroups(await fetchJdProductGroups())
|
||||
emit('changed')
|
||||
// 删掉的是当前归类目标:清点亮,右栏自己会拉回全量页签(watch selectedGroup)。
|
||||
if (selectedGroupId.value === group.id) {
|
||||
selectedGroupId.value = 0
|
||||
}
|
||||
await refreshAfterChange()
|
||||
} catch (error) {
|
||||
errorText.value = requestErrorMessage(error) || '删除分组失败'
|
||||
errorText.value = requestErrorMessage(error) || '删除分类失败'
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 左侧点亮分类=归类目标(右栏「当前分类」页签随点亮对象换行集)。 */
|
||||
function pickGroup(group: JdProductGroup): void {
|
||||
if (saving.value) return
|
||||
selectedGroupId.value = group.id
|
||||
}
|
||||
|
||||
// 打开即拉一次分类列表;右栏行集由 JdProductAssignPane 挂载时自取。
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
@@ -119,54 +144,81 @@ watch(
|
||||
cancelRename()
|
||||
createName.value = ''
|
||||
createSortOrder.value = 0
|
||||
errorText.value = ''
|
||||
selectedGroupId.value = 0
|
||||
void loadGroups()
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
/** 右栏归类成功:分类商品数变化+页面行集的 groupName 都要刷。 */
|
||||
function onPaneChanged(): void {
|
||||
void refreshAfterChange()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="modal-mask" @click.self="emit('close')">
|
||||
<div class="group-modal">
|
||||
<div class="modal-head">
|
||||
<h3>分组管理</h3>
|
||||
<h3>店铺分类</h3>
|
||||
<button class="modal-close" type="button" aria-label="关闭" @click="emit('close')">×</button>
|
||||
</div>
|
||||
|
||||
<div class="group-create">
|
||||
<input
|
||||
v-model="createName"
|
||||
type="text"
|
||||
placeholder="输入新分组名称"
|
||||
@keyup.enter="submitCreate"
|
||||
/>
|
||||
<input v-model.number="createSortOrder" type="number" class="sort-input" aria-label="排序" />
|
||||
<button class="btn" type="button" :disabled="!canCreate" @click="submitCreate">
|
||||
{{ creating ? '新建中...' : '新建分组' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p class="modal-tip">
|
||||
左侧管理分类并点选目标分类;右侧勾选商品后「归入所选分类」或「移出分类」。
|
||||
人工归类过的商品不再被采集自动覆盖(价格/库存等字段停更)。
|
||||
</p>
|
||||
<p v-if="errorText" class="group-error">{{ errorText }}</p>
|
||||
<p v-else-if="loading" class="group-tip">加载中...</p>
|
||||
|
||||
<ul class="group-list">
|
||||
<li v-for="group in groups" :key="group.id" class="group-row">
|
||||
<template v-if="editingId === group.id">
|
||||
<input v-model="editingName" type="text" @keyup.enter="submitRename(group)" />
|
||||
<button class="btn btn-small" type="button" :disabled="saving" @click="submitRename(group)">保存</button>
|
||||
<button class="btn btn-secondary btn-small" type="button" @click="cancelRename">取消</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="group-name" :title="group.name">{{ group.name }}</span>
|
||||
<span class="group-meta">排序 {{ group.sortOrder }} · {{ group.productCount }} 个商品</span>
|
||||
<span class="group-actions">
|
||||
<button class="btn btn-secondary btn-small" type="button" @click="startRename(group)">改名</button>
|
||||
<button class="btn btn-danger btn-small" type="button" :disabled="saving" @click="removeGroup(group)">删除</button>
|
||||
</span>
|
||||
</template>
|
||||
</li>
|
||||
<li v-if="!loading && !groups.length && !errorText" class="group-tip">暂无分组,先新建一个</li>
|
||||
</ul>
|
||||
<div class="split-body">
|
||||
<!-- 左栏:分类管理 -->
|
||||
<aside class="left-pane">
|
||||
<div class="group-create">
|
||||
<input
|
||||
v-model="createName"
|
||||
type="text"
|
||||
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>
|
||||
</div>
|
||||
<p v-if="loading" class="pane-tip">加载中...</p>
|
||||
<ul class="group-list">
|
||||
<li
|
||||
v-for="group in groups"
|
||||
:key="group.id"
|
||||
class="group-row"
|
||||
:class="{ active: selectedGroupId === group.id }"
|
||||
@click="pickGroup(group)"
|
||||
>
|
||||
<template v-if="editingId === group.id">
|
||||
<input v-model="editingName" type="text" @keyup.enter="submitRename(group)" />
|
||||
<span class="group-actions" @click.stop>
|
||||
<button class="btn btn-mini" type="button" :disabled="saving" @click="submitRename(group)">保存</button>
|
||||
<button class="btn btn-secondary btn-mini" type="button" @click="cancelRename">取消</button>
|
||||
</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="group-name" :title="group.name">{{ group.name }}</span>
|
||||
<span class="group-meta">{{ group.productCount }}</span>
|
||||
<span class="group-actions" @click.stop>
|
||||
<button class="btn btn-secondary btn-mini" type="button" @click="startRename(group)">改名</button>
|
||||
<button class="btn btn-danger btn-mini" type="button" :disabled="saving" @click="removeGroup(group)">删除</button>
|
||||
</span>
|
||||
</template>
|
||||
</li>
|
||||
<li v-if="!loading && !groups.length && !errorText" class="pane-tip">暂无分类,先新建一个</li>
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
<!-- 右栏:商品人工归类(独立件,行集/勾选/批量归类都在那里) -->
|
||||
<JdProductAssignPane :selected-group="selectedGroup" @changed="onPaneChanged" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -186,9 +238,9 @@ watch(
|
||||
.group-modal {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: min(560px, 100%);
|
||||
max-height: 84vh;
|
||||
padding: 18px 20px;
|
||||
width: min(1080px, 100%);
|
||||
max-height: 86vh;
|
||||
padding: 18px 20px 20px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 14px;
|
||||
background: #ffffff;
|
||||
@@ -221,16 +273,46 @@ watch(
|
||||
background: #eef4fa;
|
||||
color: #24384d;
|
||||
}
|
||||
.modal-tip {
|
||||
margin: 8px 0 10px;
|
||||
color: #8293a5;
|
||||
font-size: 12.5px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.group-error {
|
||||
margin: 0 0 8px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #f0c9c2;
|
||||
border-radius: 10px;
|
||||
background: #fdf1ef;
|
||||
color: #a04432;
|
||||
font-size: 13px;
|
||||
}
|
||||
.split-body {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
/* 左栏(分类管理):固定宽,独立滚动。 */
|
||||
.left-pane {
|
||||
flex: 0 0 248px;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-right: 1px solid #e7eef5;
|
||||
padding-right: 14px;
|
||||
}
|
||||
.group-create {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin: 14px 0 10px;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.group-create input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 38px;
|
||||
padding: 7px 12px;
|
||||
min-height: 36px;
|
||||
padding: 6px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
@@ -243,22 +325,12 @@ watch(
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
}
|
||||
.group-create-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.sort-input {
|
||||
flex: 0 0 88px !important;
|
||||
}
|
||||
.group-error {
|
||||
margin: 0 0 8px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #f0c9c2;
|
||||
border-radius: 10px;
|
||||
background: #fdf1ef;
|
||||
color: #a04432;
|
||||
font-size: 13px;
|
||||
}
|
||||
.group-tip {
|
||||
margin: 0 0 8px;
|
||||
color: #8293a5;
|
||||
font-size: 13px;
|
||||
flex: 0 0 72px !important;
|
||||
}
|
||||
.group-list {
|
||||
flex: 1;
|
||||
@@ -272,16 +344,25 @@ watch(
|
||||
.group-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 9px 4px;
|
||||
gap: 8px;
|
||||
padding: 8px 6px;
|
||||
border-bottom: 1px solid #e7eef5;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.group-row:hover {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
/* 左侧点亮=归类目标:右侧「归入所选分类」就落在这一行。 */
|
||||
.group-row.active {
|
||||
background: #e8f1fa;
|
||||
box-shadow: inset 3px 0 0 #4f78a5;
|
||||
}
|
||||
.group-row input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 34px;
|
||||
padding: 5px 10px;
|
||||
min-height: 32px;
|
||||
padding: 4px 10px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 8px;
|
||||
font-size: 13.5px;
|
||||
@@ -297,14 +378,24 @@ watch(
|
||||
}
|
||||
.group-meta {
|
||||
flex: none;
|
||||
color: #8293a5;
|
||||
font-size: 12.5px;
|
||||
min-width: 22px;
|
||||
padding: 1px 7px;
|
||||
border-radius: 9px;
|
||||
background: #eef4fa;
|
||||
color: #4e6479;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.group-actions {
|
||||
flex: none;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
}
|
||||
.pane-tip {
|
||||
margin: 10px 2px;
|
||||
color: #8293a5;
|
||||
font-size: 13px;
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
@@ -324,10 +415,10 @@ watch(
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.btn-small {
|
||||
min-height: 32px;
|
||||
padding: 4px 12px;
|
||||
font-size: 12.5px;
|
||||
.btn-mini {
|
||||
min-height: 28px;
|
||||
padding: 3px 9px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.btn-secondary {
|
||||
background: #ffffff;
|
||||
|
||||
@@ -37,6 +37,8 @@ export async function fetchJdProductList(
|
||||
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)
|
||||
}
|
||||
@@ -200,3 +202,16 @@ export async function deleteJdProductGroup(id: number): Promise<void> {
|
||||
const { data } = await http.delete<unknown>(`${JD_PRODUCT_GROUP_ENDPOINT}/${id}`)
|
||||
groupDataOf<unknown>(data)
|
||||
}
|
||||
|
||||
/** 批量人工归类(店铺分类弹窗,2026-11-15):勾选商品行 → 归入指定分类或移出分类。
|
||||
* groupId 传 null=移出分类(后端把 group_id 置 NULL);返回实际更新的行数。
|
||||
* 后端与单行编辑同口径置 manual_locked=1(归类即人工干预,采集不再覆盖/清理该行)。
|
||||
* 业务失败(分类不存在等)把中文文案抛回,弹窗红条原样展示。公共库写侧无公司维度。 */
|
||||
export async function batchAssignJdProductGroup(
|
||||
ids: number[],
|
||||
groupId: number | null,
|
||||
): Promise<number> {
|
||||
const body: Record<string, unknown> = { ids, groupId }
|
||||
const { data } = await http.post<unknown>(`${JD_PRODUCT_ENDPOINT}/batch-assign-group`, body)
|
||||
return groupDataOf<number>(data)
|
||||
}
|
||||
|
||||
@@ -60,6 +60,9 @@ export interface JdProductQuery {
|
||||
/** 京麦末级类目等值过滤(后端 JdProductQueryService.Filter.category)。 */
|
||||
category?: string
|
||||
group_id?: number
|
||||
/** 未分类过滤(店铺分类弹窗「未分类」范围):true=只看 group_id 为空的行。
|
||||
* 同 group_id 一样由 api 发送口下传——构造器不认识它(弹窗的取数不走筛选态)。 */
|
||||
ungrouped?: boolean
|
||||
synced_from?: string
|
||||
synced_to?: string
|
||||
/** 公司 tab:白名单构造不点名它,字段只为 api 发送口的 `query.company_id = params.companyId` 存在。 */
|
||||
@@ -75,6 +78,8 @@ export interface JdProductListParams {
|
||||
titleKeyword?: string
|
||||
category?: string
|
||||
groupId?: string
|
||||
/** 未分类范围(true=只看未分类行);仅店铺分类弹窗右栏传,页面筛选行不用。 */
|
||||
ungrouped?: boolean
|
||||
syncedFrom?: string
|
||||
syncedTo?: string
|
||||
companyId?: number | null
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* 京东数据库页(v1.4 Phase 5)的挂载契约。
|
||||
*
|
||||
* 形态:panel-box + 筛选行(店铺/商品编码/标题关键字/分组/同步起止 date 对)+
|
||||
* 查询/重置/管理分组 + 自绘明细表(点行开详情抽屉)+ OldPagination;
|
||||
* 形态:panel-box + 筛选行(店铺/商品编码/标题关键字/分类/同步起止 date 对)+
|
||||
* 查询/重置/店铺分类 + 自绘明细表(点行开详情抽屉)+ OldPagination;
|
||||
* 公司 tab 切换=清筛选重取(company-tab-wiring 同口径)。
|
||||
* 商品状态筛选/列与导出按钮已随 2026-11-15 客户口径从前端下线(后端端点保留)。
|
||||
* 不用 readFileSync(source-pin-ratchet 对台账外新文件带读点即红),全部走真实挂载断言。
|
||||
@@ -30,6 +30,7 @@ const jdApi = vi.hoisted(() => ({
|
||||
updateJdProductGroup: vi.fn(),
|
||||
deleteJdProductGroup: vi.fn(),
|
||||
updateJdProduct: vi.fn(),
|
||||
batchAssignJdProductGroup: vi.fn(),
|
||||
}))
|
||||
|
||||
const confirmMock = vi.hoisted(() => vi.fn())
|
||||
@@ -214,9 +215,9 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(wrapper.find('.drawer-mask').exists()).toBe(false, '点复制按钮不冒泡开抽屉')
|
||||
})
|
||||
|
||||
it('分组读不到的那行展示「未分组」(不猜名字)', async () => {
|
||||
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')[2].text()).toBe('未分类')
|
||||
})
|
||||
|
||||
it('筛选生效:店铺/编码/关键字/分组/起止日期,查询回第一页重发', async () => {
|
||||
@@ -259,7 +260,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
|
||||
const groupSelect = wrapper.find('select')
|
||||
const optionTexts = groupSelect.findAll('option').map((o) => o.text())
|
||||
expect(optionTexts).toContain('全部分组')
|
||||
expect(optionTexts).toContain('全部分类')
|
||||
expect(optionTexts).toContain('甲组')
|
||||
|
||||
const callsBeforeSelect = jdApi.fetchJdProductList.mock.calls.length
|
||||
@@ -471,20 +472,25 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(wrapper.find('.jd-delete-btn').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('管理分组弹窗:打开即拉分组列表,变更后刷新分组下拉与列表', async () => {
|
||||
it('店铺分类弹窗(原「管理分组」):打开即拉分类列表与右栏商品行集,变更后刷新分类下拉与列表', async () => {
|
||||
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
|
||||
const callsBefore = jdApi.fetchJdProductList.mock.calls.length
|
||||
|
||||
await wrapper.findAll('button').find((b) => b.text() === '管理分组')!.trigger('click')
|
||||
await wrapper.findAll('button').find((b) => b.text() === '店铺分类')!.trigger('click')
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
|
||||
expect(wrapper.find('.group-modal').exists()).toBe(true)
|
||||
// 打开弹窗 = 拉一次分组列表(第 2 次:首屏已拉过一次;分组全平台一份、不带公司维度)
|
||||
expect(wrapper.find('.group-modal').text()).toContain('店铺分类', '弹窗标题改「店铺分类」')
|
||||
// 打开弹窗 = 拉一次分类列表(第 2 次:首屏已拉过一次;分类全平台一份、不带公司维度)
|
||||
expect(jdApi.fetchJdProductGroups).toHaveBeenCalledTimes(2)
|
||||
expect(jdApi.fetchJdProductGroups).toHaveBeenLastCalledWith()
|
||||
// 右栏取数复用 fetchJdProductList:不带公司维度(公共库),默认「全部」范围不带 ungrouped=true。
|
||||
const dialogCall = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
|
||||
expect(dialogCall.companyId).toBeNull()
|
||||
expect(dialogCall.ungrouped).toBe(false)
|
||||
|
||||
// 模拟分组管理里删了一个分组:emit changed → 页面刷新分组下拉与列表(回第一页)
|
||||
// 模拟分类管理里删了一个分类:emit changed → 页面刷新分类下拉与列表(回第一页)
|
||||
wrapper.findComponent(JdProductGroupDialog).vm.$emit('changed')
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
@@ -492,6 +498,66 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ page: 1, companyId: 1 })
|
||||
})
|
||||
|
||||
it('店铺分类弹窗:左侧点亮分类→勾选商品→「归入所选分类」按(ids, 目标分类 id)调批量归类', async () => {
|
||||
jdApi.fetchJdProductGroups.mockResolvedValue([
|
||||
{ id: 7, name: '甲组', sortOrder: 0, productCount: 3 },
|
||||
{ id: 8, name: '乙组', sortOrder: 1, productCount: 0 },
|
||||
])
|
||||
jdApi.fetchJdProductList.mockImplementation(() =>
|
||||
Promise.resolve({ items: [item(1), item(2)], total: 2, page: 1, pageSize: 20 }))
|
||||
const wrapper = mount(JdProductGroupDialog, { props: { visible: false }, global: { plugins: [pinia] } })
|
||||
await wrapper.setProps({ visible: true })
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
|
||||
// 左侧点亮「甲组」=归类目标;只点亮还没勾选时按钮仍置灰(归入=目标+勾选两者齐备)。
|
||||
const assignBtn = () => wrapper.findAll('button').find((b) => b.text().includes('归入'))
|
||||
expect(assignBtn()!.attributes('disabled')).toBeDefined()
|
||||
await wrapper.findAll('.group-row')[0].trigger('click')
|
||||
await flushPromises()
|
||||
expect(assignBtn()!.attributes('disabled')).toBeDefined()
|
||||
expect(assignBtn()!.text()).toContain('甲组', '按钮点名归类目标')
|
||||
|
||||
// 勾选两行 → 按钮点亮 → 归入「甲组」。
|
||||
const boxes = wrapper.findAll('tbody input[type="checkbox"]')
|
||||
await boxes[0].setValue(true)
|
||||
await boxes[1].setValue(true)
|
||||
expect(assignBtn()!.attributes('disabled')).toBeUndefined()
|
||||
jdApi.batchAssignJdProductGroup.mockResolvedValue(2)
|
||||
await assignBtn()!.trigger('click')
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
|
||||
expect(jdApi.batchAssignJdProductGroup).toHaveBeenCalledTimes(1)
|
||||
expect(jdApi.batchAssignJdProductGroup).toHaveBeenCalledWith([1, 2], 7)
|
||||
// 成功后刷新左栏分类数(商品数)与右栏行集,勾选清空。
|
||||
expect(jdApi.fetchJdProductGroups).toHaveBeenCalled()
|
||||
expect(wrapper.findAll('tbody input[type="checkbox"]').every((b) => !(b.element as HTMLInputElement).checked).valueOf()).toBe(true)
|
||||
})
|
||||
|
||||
it('店铺分类弹窗:「未分类」页签走 ungrouped=true 取行集;「移出分类」按(ids, null)调批量归类', async () => {
|
||||
jdApi.fetchJdProductGroups.mockResolvedValue([{ id: 7, name: '甲组', sortOrder: 0, productCount: 3 }])
|
||||
jdApi.fetchJdProductList.mockImplementation(() =>
|
||||
Promise.resolve({ items: [item(1, { groupId: null, groupName: '' })], total: 1, page: 1, pageSize: 20 }))
|
||||
const wrapper = mount(JdProductGroupDialog, { props: { visible: false }, global: { plugins: [pinia] } })
|
||||
await wrapper.setProps({ visible: true })
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
|
||||
const listCallsBefore = jdApi.fetchJdProductList.mock.calls.length
|
||||
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 })
|
||||
|
||||
await wrapper.findAll('tbody input[type="checkbox"]')[0].setValue(true)
|
||||
jdApi.batchAssignJdProductGroup.mockResolvedValue(1)
|
||||
await wrapper.findAll('button').find((b) => b.text() === '移出分类')!.trigger('click')
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
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 })
|
||||
|
||||
+21
-1
@@ -7,6 +7,7 @@ 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;
|
||||
import com.nanri.aiimage.modules.jd.model.vo.JdProductCategoryVo;
|
||||
@@ -100,6 +101,8 @@ public class AdminJdProductController {
|
||||
@Parameter(description = "标题关键词(包含匹配)") @RequestParam(name = "title_keyword", required = false) String titleKeyword,
|
||||
@Parameter(description = "类目(京麦末级类目名,eq)") @RequestParam(name = "category", required = false) String category,
|
||||
@Parameter(description = "分组 id") @RequestParam(name = "group_id", required = false) Long groupId,
|
||||
@Parameter(description = "只看未分类(group_id IS NULL,店铺分类弹窗「未分类」范围)")
|
||||
@RequestParam(name = "ungrouped", required = false) Boolean ungrouped,
|
||||
@Parameter(description = "同步开始时间(包含,ISO datetime)")
|
||||
@RequestParam(name = "synced_from", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime syncedFrom,
|
||||
@Parameter(description = "同步结束时间(包含,ISO datetime)")
|
||||
@@ -112,7 +115,7 @@ public class AdminJdProductController {
|
||||
// 非超管传什么都不收——公共库对每一家管理员都是同一份全量。
|
||||
Long scopedCompanyId = dataReadScope.superAdminScopedCompanyId(user, companyId);
|
||||
return ApiResponse.success(jdProductQueryService.page(page, pageSize, scopedCompanyId, shopName,
|
||||
productCode, titleKeyword, category, groupId, syncedFrom, syncedTo));
|
||||
productCode, titleKeyword, category, groupId, ungrouped, syncedFrom, syncedTo));
|
||||
}
|
||||
|
||||
@GetMapping("/categories")
|
||||
@@ -172,6 +175,23 @@ public class AdminJdProductController {
|
||||
return ApiResponse.success(vo);
|
||||
}
|
||||
|
||||
@PostMapping("/batch-assign-group")
|
||||
@Operation(summary = "批量归类京东商品(店铺分类弹窗)", description = "勾选商品行 → 归入指定分类"
|
||||
+ "(groupId 必须真实存在)或移出分类(groupId=null,group_id 置 NULL)。与单行编辑"
|
||||
+ "同口径:归类即人工干预,落 manual_locked=1(采集 upsert/登记/覆盖清理此后跳过本行,"
|
||||
+ "分类不被重爬清理冲掉,代价是该行价格/库存随锁停更)。单次最多 200 个;id 不存在的"
|
||||
+ "行不计入更新数、不整批拒绝(弹窗行集与库行有采集刷新时间差,掉队行跳过)。")
|
||||
public ApiResponse<Integer> batchAssignGroup(
|
||||
@Valid @RequestBody JdProductBatchAssignGroupRequest body,
|
||||
HttpServletRequest request) {
|
||||
RequestOperator operator = requireJdAccess(request);
|
||||
int updated = jdProductUpdateService.assignGroup(body.getIds(), body.getGroupId());
|
||||
// 管理端写动作必须留痕:谁、把多少行归到哪个分类(null=移出分类)。
|
||||
log.info("[jd-product] 批量归类 operatorId={} requested={} updated={} groupId={}",
|
||||
operator.id(), body.getIds().size(), updated, body.getGroupId());
|
||||
return ApiResponse.success(updated);
|
||||
}
|
||||
|
||||
@PostMapping("/batch-delete")
|
||||
@Operation(summary = "批量删除京东商品", description = "与单行删除同一出口(先删桶对象、全成功才删库行);"
|
||||
+ "单次最多 200 个,id 里有一行不存在则整批拒绝(不做部分删除)。")
|
||||
|
||||
@@ -42,8 +42,9 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
|
||||
|
||||
/**
|
||||
* 后管只读页总数(Phase 5,v1.4):与 {@link #selectProductPage} 同一过滤面
|
||||
* (公司/店铺名/商品编码/标题关键词/类目/分组/同步起止,全部 SQL 侧下推,
|
||||
* 铁律 20)。{@code companyId}/{@code groupId} 为空或 ≤0=不过滤该面。
|
||||
* (公司/店铺名/商品编码/标题关键词/类目/分组/未分类/同步起止,全部 SQL 侧下推,
|
||||
* 铁律 20)。{@code companyId}/{@code groupId} 为空或 ≤0=不过滤该面;
|
||||
* {@code ungrouped=true}=只看未分类行(group_id IS NULL,店铺分类弹窗「未分类」范围)。
|
||||
*/
|
||||
long countProducts(@Param("companyId") Long companyId,
|
||||
@Param("shopName") String shopName,
|
||||
@@ -51,6 +52,7 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
|
||||
@Param("titleKeyword") String titleKeyword,
|
||||
@Param("category") String category,
|
||||
@Param("groupId") Long groupId,
|
||||
@Param("ungrouped") Boolean ungrouped,
|
||||
@Param("syncedFrom") LocalDateTime syncedFrom,
|
||||
@Param("syncedTo") LocalDateTime syncedTo);
|
||||
|
||||
@@ -92,6 +94,7 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
|
||||
@Param("titleKeyword") String titleKeyword,
|
||||
@Param("category") String category,
|
||||
@Param("groupId") Long groupId,
|
||||
@Param("ungrouped") Boolean ungrouped,
|
||||
@Param("syncedFrom") LocalDateTime syncedFrom,
|
||||
@Param("syncedTo") LocalDateTime syncedTo,
|
||||
@Param("offset") long offset,
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.nanri.aiimage.modules.jd.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 后管京东商品批量归类请求体(店铺分类弹窗,2026-11-15):勾选商品行 → 归入左侧选中分类
|
||||
* 或移出分类。公共库写侧无公司维度(2026-11-15 用户定案),body 不带 company_id——
|
||||
* 公司维度的假 tab 形状随 2026-11-15 公共化已从写侧端点整批摘除。
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "京东商品批量归类请求(归入分类或移出分类)")
|
||||
public class JdProductBatchAssignGroupRequest {
|
||||
|
||||
@Schema(description = "商品行 id 清单(单次最多 200 个,与批量删除同档)")
|
||||
@NotEmpty(message = "请先选择要归类的商品")
|
||||
@Size(max = 200, message = "单次最多归类 200 个商品,请分批操作")
|
||||
private List<Long> ids;
|
||||
|
||||
@Schema(description = "目标分类 id;null=移出分类(group_id 置 NULL,商品回到未分类)")
|
||||
private Long groupId;
|
||||
}
|
||||
+5
-5
@@ -104,19 +104,19 @@ public class JdProductGroupService {
|
||||
/** 名字归一:trim 后必须非空。 */
|
||||
private static String requireName(String name) {
|
||||
if (name == null || name.trim().isEmpty()) {
|
||||
throw new BusinessException(400, "分组名不能为空");
|
||||
throw new BusinessException(400, "分类名不能为空");
|
||||
}
|
||||
return name.trim();
|
||||
}
|
||||
|
||||
/** 分组行存在校验:不存在一律按「分组不存在」拒绝。 */
|
||||
/** 分类行存在校验:不存在一律按「分类不存在」拒绝。 */
|
||||
private JdProductGroupEntity requireExistingGroup(Long id) {
|
||||
if (id == null || id <= 0) {
|
||||
throw new BusinessException("分组不存在");
|
||||
throw new BusinessException("分类不存在");
|
||||
}
|
||||
JdProductGroupEntity group = jdProductGroupMapper.selectById(id);
|
||||
if (group == null) {
|
||||
throw new BusinessException("分组不存在");
|
||||
throw new BusinessException("分类不存在");
|
||||
}
|
||||
return group;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class JdProductGroupService {
|
||||
.eq(JdProductGroupEntity::getName, name)
|
||||
.ne(excludeId != null, JdProductGroupEntity::getId, excludeId));
|
||||
if (count != null && count > 0) {
|
||||
throw new BusinessException(409, "已存在同名分组:" + name);
|
||||
throw new BusinessException(409, "已存在同名分类:" + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-8
@@ -75,10 +75,11 @@ public class JdProductQueryService {
|
||||
* 分页查询商品行({@code synced_at} 倒序)。
|
||||
*
|
||||
* <p>过滤面:公司(物化列 eq)、店铺名 contains、商品编码 contains、标题关键词 contains、
|
||||
* 类目 eq、分组 eq、同步起止(datetime 闭区间)。</p>
|
||||
* 类目 eq、分组 eq、未分类(group_id IS NULL,店铺分类弹窗「未分类」范围)、
|
||||
* 同步起止(datetime 闭区间)。</p>
|
||||
*/
|
||||
public JdProductPageVo page(Long page, Long pageSize, Long scopedCompanyId, String shopName,
|
||||
String productCode, String titleKeyword, String category, Long groupId,
|
||||
String productCode, String titleKeyword, String category, Long groupId, Boolean ungrouped,
|
||||
LocalDateTime syncedFrom, LocalDateTime syncedTo) {
|
||||
if (syncedFrom != null && syncedTo != null && syncedFrom.isAfter(syncedTo)) {
|
||||
throw new BusinessException("开始时间不能晚于结束时间");
|
||||
@@ -87,13 +88,13 @@ public class JdProductQueryService {
|
||||
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,
|
||||
groupId, syncedFrom, syncedTo);
|
||||
groupId, ungrouped, syncedFrom, syncedTo);
|
||||
long total = jdProductMapper.countProducts(filter.companyId(), filter.shopName(), filter.productCode(),
|
||||
filter.titleKeyword(), filter.category(), filter.groupId(),
|
||||
filter.titleKeyword(), filter.category(), filter.groupId(), filter.ungrouped(),
|
||||
filter.syncedFrom(), filter.syncedTo());
|
||||
List<JdProductEntity> rows = total <= 0 ? List.of()
|
||||
: jdProductMapper.selectProductPage(filter.companyId(), filter.shopName(), filter.productCode(),
|
||||
filter.titleKeyword(), filter.category(), filter.groupId(),
|
||||
filter.titleKeyword(), filter.category(), filter.groupId(), filter.ungrouped(),
|
||||
filter.syncedFrom(), filter.syncedTo(), (safePage - 1) * safeSize, (int) safeSize);
|
||||
List<JdProductListItemVo> items = rows.stream().map(this::toListItem).toList();
|
||||
fillGroupNames(items);
|
||||
@@ -171,15 +172,17 @@ public class JdProductQueryService {
|
||||
|
||||
/** 服务侧过滤面归一:companyId/groupId ≤0 按没选处理,文本 trim 后空串归 null。 */
|
||||
private record Filter(Long companyId, String shopName, String productCode, String titleKeyword,
|
||||
String category, Long groupId, LocalDateTime syncedFrom, LocalDateTime syncedTo) {
|
||||
String category, Long groupId, Boolean ungrouped, LocalDateTime syncedFrom, LocalDateTime syncedTo) {
|
||||
}
|
||||
|
||||
private static Filter filter(Long scopedCompanyId, String shopName, String productCode, String titleKeyword,
|
||||
String category, Long groupId, LocalDateTime syncedFrom, LocalDateTime syncedTo) {
|
||||
String category, Long groupId, Boolean ungrouped, 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;
|
||||
return new Filter(companyId, trimToNull(shopName), trimToNull(productCode), trimToNull(titleKeyword),
|
||||
trimToNull(category), safeGroupId, syncedFrom, syncedTo);
|
||||
trimToNull(category), safeGroupId, safeUngrouped, syncedFrom, syncedTo);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 列表/详情搬运
|
||||
|
||||
+46
-1
@@ -54,6 +54,9 @@ public class JdProductUpdateService {
|
||||
|
||||
private static final String LOG_TAG = "jd-update";
|
||||
|
||||
/** 单次批量归类上限(与批量删除同档,防脏包一次写爆)。 */
|
||||
private static final int MAX_ASSIGN_IDS = 200;
|
||||
|
||||
/** 单次属性分组/属性行上限(防脏包一次写爆 attr_json;京麦 8 个 Tab 量级)。 */
|
||||
private static final int MAX_ATTR_GROUPS = 64;
|
||||
private static final int MAX_ATTRS_PER_GROUP = 200;
|
||||
@@ -97,7 +100,7 @@ public class JdProductUpdateService {
|
||||
if (groupId != null) {
|
||||
JdProductGroupEntity group = jdProductGroupMapper.selectById(groupId);
|
||||
if (group == null) {
|
||||
throw new BusinessException("分组不存在,请刷新分组后重试");
|
||||
throw new BusinessException("分类不存在,请刷新分类后重试");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +153,48 @@ public class JdProductUpdateService {
|
||||
|
||||
// ---------- 校验 ----------
|
||||
|
||||
/**
|
||||
* 批量人工归类(店铺分类弹窗,2026-11-15):勾选商品行 → 归入指定分类或移出分类。
|
||||
*
|
||||
* <p>与单行编辑同口径(用户拍板「置锁」):归类即人工干预,落 {@code manual_locked=1}——
|
||||
* 采集 upsert 本就不写 group_id,置锁后覆盖清理也不再把这些行整行删掉,分类永不丢;
|
||||
* 代价是该行的价格/库存等字段随锁停更(与编辑保存同一语义)。</p>
|
||||
*
|
||||
* <p>{@code groupId} null=移出分类(group_id 置 NULL 回到未分类);非 null 时必须真实
|
||||
* 存在(分类全平台一份,无公司维度)。只写 group_id 与锁两个列,不动其它字段——
|
||||
* 与 {@link #update} 的全量覆写不同,这是行集级轻touch。</p>
|
||||
*
|
||||
* @return 实际更新的行数(id 不存在/已被删的行不计入,不按不存在整批拒绝——
|
||||
* 弹窗行集与库行之间天然有采集刷新的时间差,掉队的行跳过即可)
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int assignGroup(List<Long> ids, Long groupId) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
throw new BusinessException("请先选择要归类的商品");
|
||||
}
|
||||
List<Long> distinctIds = ids.stream().filter(id -> id != null && id > 0).distinct().toList();
|
||||
if (distinctIds.isEmpty()) {
|
||||
throw new BusinessException("请先选择要归类的商品");
|
||||
}
|
||||
if (distinctIds.size() > MAX_ASSIGN_IDS) {
|
||||
throw new BusinessException("单次最多归类 " + MAX_ASSIGN_IDS + " 个商品,请分批操作");
|
||||
}
|
||||
if (groupId != null) {
|
||||
JdProductGroupEntity group = jdProductGroupMapper.selectById(groupId);
|
||||
if (group == null) {
|
||||
throw new BusinessException("分类不存在,请刷新分类后重试");
|
||||
}
|
||||
}
|
||||
int updated = jdProductMapper.update(null, new LambdaUpdateWrapper<JdProductEntity>()
|
||||
.in(JdProductEntity::getId, distinctIds)
|
||||
.set(JdProductEntity::getGroupId, groupId)
|
||||
// 人工编辑锁:归类即人工干预,采集链路(upsert/登记/覆盖清理)此后跳过本行。
|
||||
.set(JdProductEntity::getManualLocked, 1));
|
||||
log.info("[{}] 批量归类 requested={} distinct={} groupId={} updated={}",
|
||||
LOG_TAG, ids.size(), distinctIds.size(), groupId, updated);
|
||||
return updated;
|
||||
}
|
||||
|
||||
private void validateBody(JdProductUpdateRequest body) {
|
||||
if (body.getPriceMin() != null && body.getPriceMax() != null
|
||||
&& body.getPriceMin().compareTo(body.getPriceMax()) > 0) {
|
||||
|
||||
@@ -101,7 +101,8 @@
|
||||
</select>
|
||||
|
||||
<!-- 后管只读页(Phase 5,v1.4)过滤面:公司(物化列 eq)、店铺名/商品编码/标题关键词
|
||||
(contains LIKE)、类目 eq、分组 eq、同步起止(datetime 闭区间)。
|
||||
(contains LIKE)、类目 eq、分组 eq、未分类(group_id IS NULL,店铺分类弹窗
|
||||
「未分类」范围)、同步起止(datetime 闭区间)。
|
||||
sale_status 筛选随 2026-11-15 客户口径撤掉(前端筛选框下线;列本身与详情/回传链不动)。
|
||||
全部走 #{} 占位符;offset/limit 必须是服务侧钳制后的值(铁律 15),mapper 不做第二次换算。 -->
|
||||
<sql id="productConds">
|
||||
@@ -111,6 +112,7 @@
|
||||
<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>
|
||||
<if test="groupId != null and groupId > 0">AND p.group_id = #{groupId}</if>
|
||||
<if test="ungrouped != null and ungrouped">AND p.group_id IS NULL</if>
|
||||
<if test="syncedFrom != null">AND p.synced_at >= #{syncedFrom}</if>
|
||||
<if test="syncedTo != null">AND p.synced_at <= #{syncedTo}</if>
|
||||
</sql>
|
||||
|
||||
+73
-19
@@ -90,6 +90,9 @@ class AdminJdProductControllerTest {
|
||||
assertTrue(source.contains("@DeleteMapping"), "删除端点必须落在 @DeleteMapping");
|
||||
assertTrue(source.contains("\"/batch-delete\""), "批量删除端点必须是 POST /batch-delete");
|
||||
assertTrue(source.contains("@Valid"), "批量删除请求体必须过 @Valid(ids 非空)");
|
||||
// 批量归类端点(店铺分类弹窗,2026-11-15):POST /batch-assign-group,归入/移出分类。
|
||||
assertTrue(source.contains("\"/batch-assign-group\""),
|
||||
"批量归类端点必须是 POST /batch-assign-group(店铺分类弹窗人工归类)");
|
||||
// PUT 旧绊线(「不得有 PUT:商品行只能被采集链回传覆盖」)已随后台「编辑商品」特性放行
|
||||
// (AdminJdProductController 的 @PutMapping("/{id}",JdProductUpdateService 承接);商品行
|
||||
// 采集回传覆盖链不变,人工改名只走这条 PUT。分组改排序仍落 AdminJdProductGroupController。
|
||||
@@ -125,7 +128,7 @@ class AdminJdProductControllerTest {
|
||||
void 分页参数snake且带默认值() throws IOException {
|
||||
String source = stripComments(Files.readString(CONTROLLER));
|
||||
for (String param : List.of("page_size", "shop_name", "product_code", "title_keyword",
|
||||
"group_id", "synced_from", "synced_to", "company_id")) {
|
||||
"group_id", "ungrouped", "synced_from", "synced_to", "company_id")) {
|
||||
assertTrue(source.contains(param), "查询参数必须 snake_case:" + param);
|
||||
}
|
||||
// 商品状态筛选框已随 2026-11-15 客户口径从前端下线 ⇒ 服务端同名参数一起撤(反向钉住防回潜)。
|
||||
@@ -193,13 +196,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)).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, 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);
|
||||
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());
|
||||
}
|
||||
@@ -321,23 +324,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())).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);
|
||||
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(), 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);
|
||||
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(), 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());
|
||||
}
|
||||
@@ -351,9 +354,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, 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());
|
||||
verify(mapper, never()).countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -362,17 +365,68 @@ 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())).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);
|
||||
service.page(1L, 20L, 5L, " 店铺甲 ", " SKU-1 ", " 连衣裙 ", " 艺考形体服 ", 0L, null, null, null);
|
||||
verify(mapper).countProducts(eq(5L), eq("店铺甲"), eq("SKU-1"), eq("连衣裙"),
|
||||
eq("艺考形体服"), isNull(), isNull(), isNull());
|
||||
eq("艺考形体服"), isNull(), isNull(), isNull(), isNull());
|
||||
// 全量(scopedCompanyId=null)⇒ companyId 不过滤。
|
||||
service.page(1L, 20L, 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());
|
||||
|
||||
// 未分类范围(店铺分类弹窗「未分类」页签):ungrouped=true 原样下推到 SQL 侧。
|
||||
service.page(1L, 20L, null, null, null, null, null, null, Boolean.TRUE, null, null);
|
||||
verify(mapper).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
|
||||
isNull(), eq(Boolean.TRUE), isNull(), isNull());
|
||||
// ungrouped=false / 缺省按不过滤处理(Filter 归一成 null,不进 IS NULL 分支);
|
||||
// 与②「全量」那发同形状,累计 2 次。
|
||||
service.page(1L, 20L, null, null, null, null, null, null, Boolean.FALSE, null, null);
|
||||
verify(mapper, times(2)).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
|
||||
isNull(), isNull(), isNull(), isNull());
|
||||
}
|
||||
|
||||
@Test
|
||||
void 批量归类端点走同一鉴权正门且参数透传() {
|
||||
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);
|
||||
|
||||
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(updateService.assignGroup(List.of(11L, 12L), 3L)).thenReturn(2);
|
||||
|
||||
com.nanri.aiimage.modules.jd.model.dto.JdProductBatchAssignGroupRequest body =
|
||||
new com.nanri.aiimage.modules.jd.model.dto.JdProductBatchAssignGroupRequest();
|
||||
body.setIds(List.of(11L, 12L));
|
||||
body.setGroupId(3L);
|
||||
ApiResponse<Integer> response = controller.batchAssignGroup(body, request);
|
||||
|
||||
// 公共库写侧没有公司维度:不收 company_id、DataReadScope 不参与。
|
||||
verifyNoInteractions(dataReadScope);
|
||||
verify(updateService).assignGroup(List.of(11L, 12L), 3L);
|
||||
assertEquals(Boolean.TRUE, response.isSuccess(), "放行必须是 success 信封(B80-03)");
|
||||
assertEquals(2, response.getData(), "回执=实际更新的行数");
|
||||
|
||||
// 业务失败(目标分类不存在)文案原样透出,不吞。
|
||||
when(updateService.assignGroup(List.of(11L), 404L))
|
||||
.thenThrow(new BusinessException("分类不存在,请刷新分类后重试"));
|
||||
com.nanri.aiimage.modules.jd.model.dto.JdProductBatchAssignGroupRequest ghostBody =
|
||||
new com.nanri.aiimage.modules.jd.model.dto.JdProductBatchAssignGroupRequest();
|
||||
ghostBody.setIds(List.of(11L));
|
||||
ghostBody.setGroupId(404L);
|
||||
BusinessException ex = assertThrows(BusinessException.class,
|
||||
() -> controller.batchAssignGroup(ghostBody, request));
|
||||
assertTrue(ex.getMessage().contains("分类不存在"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -532,8 +586,8 @@ class AdminJdProductControllerTest {
|
||||
grouped.setGroupId(3L);
|
||||
JdProductEntity missing = productEntity(2L);
|
||||
missing.setGroupId(99L);
|
||||
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(2L);
|
||||
when(mapper.selectProductPage(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();
|
||||
@@ -541,7 +595,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);
|
||||
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),前端展示 -");
|
||||
|
||||
+2
-2
@@ -64,7 +64,7 @@ class JdProductGroupServiceTest {
|
||||
BusinessException ex = assertThrows(BusinessException.class,
|
||||
() -> service.create(" 秋冬款 ", 2));
|
||||
assertEquals(409, ex.getCode(), "重名冲突=409(语义正确的资源冲突码,仓内 DeviceLogService 有先例)");
|
||||
assertTrue(ex.getMessage().contains("同名分组"), "重名必须给可读文案,不拿 DB 唯一键异常撞 500");
|
||||
assertTrue(ex.getMessage().contains("同名分类"), "重名必须给可读文案,不拿 DB 唯一键异常撞 500(2026-11-15 起界面措辞「分类」)");
|
||||
verify(groupMapper, never()).insert(any(JdProductGroupEntity.class));
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class JdProductGroupServiceTest {
|
||||
|
||||
BusinessException ex = assertThrows(BusinessException.class,
|
||||
() -> service.rename(1L, "新名字", null));
|
||||
assertTrue(ex.getMessage().contains("分组不存在"));
|
||||
assertTrue(ex.getMessage().contains("分类不存在"));
|
||||
verify(groupMapper, never()).updateById(any(JdProductGroupEntity.class));
|
||||
}
|
||||
|
||||
|
||||
+80
-2
@@ -172,17 +172,95 @@ class JdProductUpdateServiceTest {
|
||||
when(jdProductMapper.update(isNull(), any(Wrapper.class))).thenReturn(1);
|
||||
assertThat(service.update(PRODUCT_ID, body)).isEqualTo(PRODUCT_ID);
|
||||
|
||||
// 分组不存在 ⇒ 拒绝且零写。
|
||||
// 分组不存在 ⇒ 拒绝且零写(2026-11-15 起界面措辞「分类」)。
|
||||
JdProductUpdateRequest ghost = mainFieldsOnly();
|
||||
ghost.setGroupId(404L);
|
||||
when(jdProductGroupMapper.selectById(404L)).thenReturn(null);
|
||||
assertThatThrownBy(() -> service.update(PRODUCT_ID, ghost))
|
||||
.isInstanceOf(BusinessException.class)
|
||||
.hasMessageContaining("分组不存在");
|
||||
.hasMessageContaining("分类不存在");
|
||||
// update 只剩成功挂组那 1 次:ghost 分支零写点(同用例前半段已成功写过一次,不能按 never 数)。
|
||||
verify(jdProductMapper, org.mockito.Mockito.times(1)).update(isNull(), any(Wrapper.class));
|
||||
}
|
||||
|
||||
// ---------- 批量归类(店铺分类弹窗,2026-11-15) ----------
|
||||
|
||||
/** 取批量归类落下的 SET 键值对(paramNameValuePairs),供断言 groupId/ids 落值。 */
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<String, Object> capturedAssignValues() {
|
||||
ArgumentCaptor<Wrapper<JdProductEntity>> captor = ArgumentCaptor.forClass(Wrapper.class);
|
||||
verify(jdProductMapper).update(isNull(), captor.capture());
|
||||
LambdaUpdateWrapper<JdProductEntity> wrapper = (LambdaUpdateWrapper<JdProductEntity>) captor.getValue();
|
||||
return (Map<String, Object>) ReflectionTestUtils.getField(wrapper, "paramNameValuePairs");
|
||||
}
|
||||
|
||||
@Test
|
||||
void 批量归类成功_置分类并落人工编辑锁() {
|
||||
JdProductGroupEntity group = new JdProductGroupEntity();
|
||||
group.setId(7L);
|
||||
when(jdProductGroupMapper.selectById(7L)).thenReturn(group);
|
||||
when(jdProductMapper.update(isNull(), any(Wrapper.class))).thenReturn(3);
|
||||
|
||||
// 入参含重复 id:去重后 1/2/3 三行
|
||||
int updated = service.assignGroup(List.of(1L, 1L, 2L, 3L), 7L);
|
||||
|
||||
assertThat(updated).isEqualTo(3);
|
||||
ArgumentCaptor<Wrapper<JdProductEntity>> captor = ArgumentCaptor.forClass(Wrapper.class);
|
||||
verify(jdProductMapper).update(isNull(), captor.capture());
|
||||
LambdaUpdateWrapper<JdProductEntity> wrapper = (LambdaUpdateWrapper<JdProductEntity>) captor.getValue();
|
||||
// SET 段必须同时带 group_id 与 manual_locked(归类即人工干预:置锁后覆盖清理不再删行)
|
||||
assertThat(wrapper.getSqlSet()).contains("group_id").contains("manual_locked");
|
||||
// WHERE 段(IN ids)惰性构参:先触发 getSqlSegment 再读参数表,IN 值才落进 paramNameValuePairs。
|
||||
wrapper.getSqlSegment();
|
||||
Map<String, Object> values = capturedAssignValues();
|
||||
assertThat(values.values()).contains(7L, 1L, 2L, 3L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void 批量归类目标分类不存在拒绝且零写() {
|
||||
when(jdProductGroupMapper.selectById(404L)).thenReturn(null);
|
||||
|
||||
assertThatThrownBy(() -> service.assignGroup(List.of(1L, 2L), 404L))
|
||||
.isInstanceOf(BusinessException.class)
|
||||
.hasMessageContaining("分类不存在");
|
||||
verify(jdProductMapper, never()).update(isNull(), any(Wrapper.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void 批量归类空清单与超上限可读拒绝() {
|
||||
assertThatThrownBy(() -> service.assignGroup(List.of(), null))
|
||||
.isInstanceOf(BusinessException.class)
|
||||
.hasMessageContaining("请先选择要归类的商品");
|
||||
assertThatThrownBy(() -> service.assignGroup(List.of(0L, -1L), null))
|
||||
.isInstanceOf(BusinessException.class)
|
||||
.hasMessageContaining("请先选择要归类的商品");
|
||||
|
||||
List<Long> tooMany = new java.util.ArrayList<>();
|
||||
for (long i = 1; i <= 201; i++) {
|
||||
tooMany.add(i);
|
||||
}
|
||||
assertThatThrownBy(() -> service.assignGroup(tooMany, null))
|
||||
.isInstanceOf(BusinessException.class)
|
||||
.hasMessageContaining("单次最多归类 200");
|
||||
verify(jdProductMapper, never()).update(isNull(), any(Wrapper.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void 移出分类_groupId置空仍落人工编辑锁() {
|
||||
when(jdProductMapper.update(isNull(), any(Wrapper.class))).thenReturn(2);
|
||||
|
||||
int updated = service.assignGroup(List.of(5L, 6L), null);
|
||||
|
||||
assertThat(updated).isEqualTo(2);
|
||||
ArgumentCaptor<Wrapper<JdProductEntity>> captor = ArgumentCaptor.forClass(Wrapper.class);
|
||||
verify(jdProductMapper).update(isNull(), captor.capture());
|
||||
LambdaUpdateWrapper<JdProductEntity> wrapper = (LambdaUpdateWrapper<JdProductEntity>) captor.getValue();
|
||||
// groupId=null 也显式落 SET(group_id=NULL=回到未分类),锁照落。
|
||||
assertThat(wrapper.getSqlSet()).contains("group_id").contains("manual_locked");
|
||||
// 移出分类没有目标组:不查分组表。
|
||||
verify(jdProductGroupMapper, never()).selectById(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void 属性重建只覆写tabs段其余顶层键保留() {
|
||||
givenOwnedRow();
|
||||
|
||||
Reference in New Issue
Block a user