Compare commits
8 Commits
a9c74b9ad2
...
99687f4601
| Author | SHA1 | Date | |
|---|---|---|---|
| 99687f4601 | |||
| 6a355e842f | |||
| c1088cd45e | |||
| 3654d02256 | |||
| 0d7030deb8 | |||
| 3c9754b697 | |||
| 0ffa9ab002 | |||
| 01fe3c2f2d |
@@ -78,19 +78,33 @@ export interface TaskCenterVariantPage {
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
/** 汇总卡:GET /api/admin/task-center/overview */
|
||||
export async function fetchTaskCenterOverview(): Promise<TaskCenterOverview> {
|
||||
const { data } = await http.get('/api/admin/task-center/overview')
|
||||
/**
|
||||
* 汇总卡:GET /api/admin/task-center/overview
|
||||
* companyId = 公司 tab 选中的公司(超管专用,页面只从 companyTab.requestCompanyId 取);
|
||||
* null/undefined 由这里自己丢掉——不发给后端 = 按会话口径看全部,不是「筛成空」。
|
||||
*/
|
||||
export async function fetchTaskCenterOverview(companyId?: number | null): Promise<TaskCenterOverview> {
|
||||
const query: QueryParams = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const { data } = await http.get('/api/admin/task-center/overview', { params: query })
|
||||
return unwrap<TaskCenterOverview>(data)
|
||||
}
|
||||
|
||||
/** 店铺筛选候选(店铺库内的店铺名,精确匹配):GET /api/admin/task-center/shop-options */
|
||||
export async function fetchTaskCenterShopOptions(): Promise<string[]> {
|
||||
const { data } = await http.get('/api/admin/task-center/shop-options')
|
||||
/**
|
||||
* 店铺筛选候选(店铺库内的店铺名,精确匹配):GET /api/admin/task-center/shop-options
|
||||
* 下拉候选必须跟列表同宽:少了这一支,切 tab 后能选到别家的店铺名(选了又筛不出东西)。
|
||||
*/
|
||||
export async function fetchTaskCenterShopOptions(companyId?: number | null): Promise<string[]> {
|
||||
const query: QueryParams = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const { data } = await http.get('/api/admin/task-center/shop-options', { params: query })
|
||||
return unwrap<string[]>(data)
|
||||
}
|
||||
|
||||
/** 任务分页列表:GET /api/admin/task-center/tasks */
|
||||
/**
|
||||
* 任务分页列表:GET /api/admin/task-center/tasks
|
||||
* params 由 buildTaskQuery 构造(含 company_id,见 task-center-model.ts)。
|
||||
*/
|
||||
export async function fetchTaskCenterTasks(params: QueryParams): Promise<TaskCenterTaskPage> {
|
||||
const { data } = await http.get('/api/admin/task-center/tasks', { params })
|
||||
return unwrap<TaskCenterTaskPage>(data)
|
||||
@@ -98,14 +112,22 @@ export async function fetchTaskCenterTasks(params: QueryParams): Promise<TaskCen
|
||||
|
||||
/** 任务详情(品牌任务 taskNo 形如 brand-1):GET /api/admin/task-center/tasks/detail
|
||||
* 任务不存在或不在可见范围时后端返回 success + data:null,这里归一为 null 供页面提示(unwrap 对 null data 会回传信封)。 */
|
||||
export async function fetchTaskCenterTaskDetail(taskNo: string): Promise<TaskCenterTaskDetail | null> {
|
||||
const { data } = await http.get('/api/admin/task-center/tasks/detail', { params: { taskNo } })
|
||||
export async function fetchTaskCenterTaskDetail(
|
||||
taskNo: string,
|
||||
companyId?: number | null,
|
||||
): Promise<TaskCenterTaskDetail | null> {
|
||||
const query: QueryParams = { taskNo }
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const { data } = await http.get('/api/admin/task-center/tasks/detail', { params: query })
|
||||
const envelope = data as { data?: unknown } | null
|
||||
if (envelope && typeof envelope === 'object' && 'data' in envelope && envelope.data == null) return null
|
||||
return unwrap<TaskCenterTaskDetail>(data)
|
||||
}
|
||||
|
||||
/** 变体采集(代理麦象 console,取当前可见用户集合):GET /api/admin/task-center/variant-tasks */
|
||||
/**
|
||||
* 变体采集(代理麦象 console,取当前可见用户集合):GET /api/admin/task-center/variant-tasks
|
||||
* params 由 buildVariantQuery 构造(含 company_id,见 task-center-model.ts)。
|
||||
*/
|
||||
export async function fetchTaskCenterVariantTasks(params: QueryParams): Promise<TaskCenterVariantPage> {
|
||||
const { data } = await http.get('/api/admin/task-center/variant-tasks', { params })
|
||||
return unwrap<TaskCenterVariantPage>(data)
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
* 页签一「客户端任务」= biz_file_task(12 个客户端模块)∪ brand_crawl_tasks;
|
||||
* 页签二「变体采集」= 麦象批量任务(variant-collection),数据口径与列不同故独立页签。
|
||||
* 30s 轮询:页面隐藏暂停、回前台立即刷新、卸载清理;另有手动刷新。 */
|
||||
import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import {
|
||||
fetchTaskCenterOverview,
|
||||
@@ -44,6 +45,10 @@ import {
|
||||
|
||||
const POLL_INTERVAL_MS = 30_000
|
||||
|
||||
/** 公司 tab 的唯一取值出口:非超管恒 null(store 里 companyIdForRequest 已经把它算成 null),
|
||||
* 所以这里不需要再判一次角色——第二把尺子就是第二个口径。 */
|
||||
const companyTab = useCompanyTabStore()
|
||||
|
||||
type BoardTab = 'tasks' | 'variant'
|
||||
const activeTab = ref<BoardTab>('tasks')
|
||||
|
||||
@@ -96,7 +101,7 @@ function errorText(error: unknown, fallback: string): string {
|
||||
|
||||
async function loadOverview() {
|
||||
try {
|
||||
overview.value = await fetchTaskCenterOverview()
|
||||
overview.value = await fetchTaskCenterOverview(companyTab.requestCompanyId)
|
||||
} catch (error) {
|
||||
ElMessage.error(errorText(error, '汇总数据加载失败'))
|
||||
}
|
||||
@@ -105,7 +110,7 @@ async function loadOverview() {
|
||||
/** 店铺库下拉候选。 */
|
||||
async function loadShopOptions() {
|
||||
try {
|
||||
shopOptions.value = (await fetchTaskCenterShopOptions()) || []
|
||||
shopOptions.value = (await fetchTaskCenterShopOptions(companyTab.requestCompanyId)) || []
|
||||
} catch (error) {
|
||||
ElMessage.error(errorText(error, '店铺候选加载失败'))
|
||||
}
|
||||
@@ -114,7 +119,9 @@ async function loadShopOptions() {
|
||||
async function loadTasks(silent = false) {
|
||||
if (!silent) tasksLoading.value = true
|
||||
try {
|
||||
const result = await fetchTaskCenterTasks(buildTaskQuery(filter, taskPage.value, taskPageSize.value))
|
||||
const result = await fetchTaskCenterTasks(
|
||||
buildTaskQuery(filter, taskPage.value, taskPageSize.value, companyTab.requestCompanyId),
|
||||
)
|
||||
tasks.value = result?.items || []
|
||||
taskTotal.value = Number(result?.total || 0)
|
||||
} catch (error) {
|
||||
@@ -128,7 +135,7 @@ async function loadVariants(silent = false) {
|
||||
if (!silent) variantLoading.value = true
|
||||
try {
|
||||
const result = await fetchTaskCenterVariantTasks(
|
||||
buildVariantQuery(variantFilter, variantPage.value, variantPageSize.value),
|
||||
buildVariantQuery(variantFilter, variantPage.value, variantPageSize.value, companyTab.requestCompanyId),
|
||||
)
|
||||
variantRows.value = result?.items || []
|
||||
variantTotal.value = tabCount(result?.total)
|
||||
@@ -160,6 +167,19 @@ async function loadInactiveTabTotal() {
|
||||
else await loadTasks(true)
|
||||
}
|
||||
|
||||
/** 切公司 = 五个取数点全部重取(汇总卡 / 店铺候选 / 当前页签列表 / 另一页签的徽章数)。
|
||||
* filter.shop 必须一起清掉:上一家选中的店铺名在新一家的候选里根本不存在,留着会把切 tab 后的首屏
|
||||
* 筛成「暂无符合条件的任务」——口径同 ShopManagePage 的 filter.groupId(G1 钉着那条)。
|
||||
* 两个页签的页码也回 1:第 7 页对另一家没有意义。详情不在这条链上重取,它按 taskNo 现点现取,
|
||||
* 带的是切换后的 company_id,越权那一侧由后端 scope.visible() 把关。 */
|
||||
watch(() => companyTab.activeId, () => {
|
||||
filter.shop = ''
|
||||
taskPage.value = 1
|
||||
variantPage.value = 1
|
||||
void refreshAll()
|
||||
void loadInactiveTabTotal()
|
||||
})
|
||||
|
||||
function switchTab(tab: BoardTab) {
|
||||
if (activeTab.value === tab) return
|
||||
activeTab.value = tab
|
||||
@@ -223,7 +243,7 @@ async function openDetail(row: TaskCenterTaskRow) {
|
||||
detailLoading.value = true
|
||||
detail.value = null
|
||||
try {
|
||||
detail.value = await fetchTaskCenterTaskDetail(row.taskNo)
|
||||
detail.value = await fetchTaskCenterTaskDetail(row.taskNo, companyTab.requestCompanyId)
|
||||
if (!detail.value) ElMessage.warning('任务不存在或无权查看')
|
||||
} catch (error) {
|
||||
ElMessage.error(errorText(error, '任务详情加载失败'))
|
||||
|
||||
@@ -213,13 +213,19 @@ function text(value: unknown): string {
|
||||
return typeof value === 'string' ? value.trim() : ''
|
||||
}
|
||||
|
||||
/** 任务列表查询参数:空白项不下传(后端按缺省处理)。 */
|
||||
/**
|
||||
* 任务列表查询参数:空白项不下传(后端按缺省处理)。
|
||||
* companyId = 公司 tab 选中的公司(超管专用,页面从 companyTab.requestCompanyId 取);
|
||||
* 非超管恒 null ⇒ 这一支压根不发 company_id,后端的会话口径不受前端影响。
|
||||
*/
|
||||
export function buildTaskQuery(
|
||||
filter: TaskCenterTaskFilter,
|
||||
page: number,
|
||||
pageSize: number,
|
||||
companyId?: number | null,
|
||||
): TaskCenterQueryParams {
|
||||
const query: TaskCenterQueryParams = { page, pageSize }
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const put = (key: string, value: string | undefined) => {
|
||||
if (value) query[key] = value
|
||||
}
|
||||
@@ -232,12 +238,15 @@ export function buildTaskQuery(
|
||||
return query
|
||||
}
|
||||
|
||||
/** 变体采集查询参数:companyId 的口径与 buildTaskQuery 同一条(null 不发,不发=不筛)。 */
|
||||
export function buildVariantQuery(
|
||||
filter: TaskCenterVariantFilter,
|
||||
page: number,
|
||||
pageSize: number,
|
||||
companyId?: number | null,
|
||||
): TaskCenterQueryParams {
|
||||
const query: TaskCenterQueryParams = { page, pageSize }
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const status = text(filter.status)
|
||||
if (status !== '') query.status = Number(status)
|
||||
return query
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
||||
import { readSource } from './helpers.ts'
|
||||
import { occurrences, readSource } from './helpers.ts'
|
||||
import { adminPages } from '../src/router/routes.ts'
|
||||
import { COMPANY_SCOPED_PAGES, SUPER_ADMIN_ONLY_MENU_KEYS } from '../src/config/company-scope.ts'
|
||||
|
||||
@@ -21,13 +21,64 @@ const read = (p: string) => {
|
||||
* 这正是本批次要杀的那类静默失效,尺子却看不见。
|
||||
* <p>于是每页登记一条"company_id 右侧的根标识符**必须**是该页 api 函数自己的入参"的形状:
|
||||
* `shape` 为 `RegExp` 时,对**剥完注释的源码**求值,不匹配即红并点名文件;`shape` 为 `null` 是
|
||||
* "这一页还没接线"的显式声明(今天 6 页如此,它们本来就在缺口清单里)。
|
||||
* "这一页还没接线"的显式声明(批次 1 的 8 页到 Task 10 全部登记完,今天表里没有 null 项了;
|
||||
* 这一档留着是给将来新页先进清单、后接线的中间状态用的,不是默认分支)。
|
||||
* <p>两道不留缝:① `COMPANY_SCOPED_PAGES` 里每一页都必须在表里有条目,缺条目直接红;
|
||||
* ② 一旦某个文件真的出现了 `company_id` 下传而它的 `shape` 还是 `null`,同样红——
|
||||
* 所以"新页接线时顺手不改登记表"过不去,也**没有**"没登记就退回宽松判据"的默认分支。
|
||||
*/
|
||||
type CompanyIdPin = { readonly file: string; readonly shape: RegExp | null; readonly note: string }
|
||||
|
||||
/** 任务看板这一页发送口的共同形状:五处都是「函数自己那行把 companyId 塞进 query」(缩进两格,逐字相同)。 */
|
||||
const TASK_CENTER_SEND_LINE = 'if (companyId != null) query.company_id = companyId'
|
||||
|
||||
/**
|
||||
* 一条钉 = 一个发送口:窗口上界。2026-10-05 复评 N-3 把举证口径写死成判据真正求值的那份文本
|
||||
* (`stripComments(read(file))`,块注释连内部换行一起删)与那两个端点:
|
||||
* - 从 `function <fn>(` 的**括号后**起算(这是 `[\s\S]{0,320}` 的实际预算):
|
||||
* 「→ 它自己那行的 `company_id`」= 121/111/161/214/217,
|
||||
* 「→ 同文件下一个发送口的 `company_id`」= 438/690/(无)/853/(无)。
|
||||
* - 从 `function` 这个词的头起算(旧举证用的口径,比上组各多 33~36):154/147/196/238/244 与 471/726/(无)/877/(无)。
|
||||
* ⇒ 320 够得着自己的行(最紧 217),够不到隔壁(最紧 438,余量 **118 字符**):删掉任一处,那条 shape 就匹配不出
|
||||
* (不是"文件里还有别人在发"就算过)。
|
||||
* ⚠ 下面那段「拆条取样自检·负样本」只证明「窗口有界」,它跟着 `TASK_CENTER_WINDOW` 自动缩放 ⇒ **证明不了余量还在**。
|
||||
* 把 320 调大之前必须按第一组口径重测这五个数;api 函数体写长会先假红(fail-closed,可接受)。
|
||||
*/
|
||||
const TASK_CENTER_WINDOW = 320
|
||||
|
||||
/**
|
||||
* 这一页的 5 处 `company_id` 发送口(2026-10-05 修复轮 1,复评 I-1)。
|
||||
*
|
||||
* <p>为什么从 2 条文件级钉拆成 5 条:`shape` 的求值是整文件 `RegExp.test`(不数次数),
|
||||
* 评审实测「删掉 5 处里的任何一处」在两条文件级钉下**双双仍为 true**——包括 brief
|
||||
* `task-10-brief.md:14` 点名的那一处(`fetchTaskCenterTaskDetail` 少带参数 ⇒ 超管在别家 tab 下按
|
||||
* taskNo 读别家详情照样 200,这一页的护栏恰好全落在前端)。`vue-tsc` 也救不了:tsconfig 没开
|
||||
* `noUnusedParameters`,删了塞键那一行、留一个没人用的形参,编译器不响。</p>
|
||||
*
|
||||
* <p>选「拆条」而不是「计数」(`occurrences()` 数 api=3 / model=2):计数不回答「哪三处」,
|
||||
* 把一处重复写三遍、另一处删掉,计数照样绿;函数名锚 + 有界窗口才把判据绑到发送口自己的身份上。
|
||||
* 形状照 `admin_shop_manage` 的先例(同一个文件两条 pin,「两条各管一处取值口,不许合成一条 alternation」)。</p>
|
||||
*
|
||||
* <p>`shape` 与取样样本同源于这张表(都由 fn/window 现算),不会出现「钉改了、自检还测旧串」的漂移。</p>
|
||||
*/
|
||||
const TASK_CENTER_SEND_POINTS: ReadonlyArray<{ readonly file: string; readonly fn: string; readonly title: string }> = [
|
||||
{ file: 'src/api/task-center.ts', fn: 'fetchTaskCenterOverview', title: 'GET /overview 汇总卡' },
|
||||
{ file: 'src/api/task-center.ts', fn: 'fetchTaskCenterShopOptions', title: 'GET /shop-options 店铺候选' },
|
||||
{ file: 'src/api/task-center.ts', fn: 'fetchTaskCenterTaskDetail', title: 'GET /tasks/detail 详情(brief 点名那一处)' },
|
||||
{ file: 'src/pages/task-center/task-center-model.ts', fn: 'buildTaskQuery', title: '任务列表 query 构造器' },
|
||||
{ file: 'src/pages/task-center/task-center-model.ts', fn: 'buildVariantQuery', title: '变体采集 query 构造器' },
|
||||
]
|
||||
|
||||
/** 一个发送口一条钉:锚在自己的函数开行上,要求窗口内出现「塞键」那一行。 */
|
||||
function sendPointShape(fn: string): RegExp {
|
||||
return new RegExp(`function ${fn}\\([\\s\\S]{0,${TASK_CENTER_WINDOW}}company_id\\s*=\\s*companyId\\b`)
|
||||
}
|
||||
|
||||
/** 正样本用的迷你源码:函数开行 + 它自己那行塞键(缩进、形状逐字照抄真实发送口)。 */
|
||||
function sendPointCompliant(fn: string): string {
|
||||
return `function ${fn}(companyId?: number | null) {\n const query: QueryParams = {}\n ${TASK_CENTER_SEND_LINE}\n`
|
||||
}
|
||||
|
||||
const COMPANY_ID_SOURCE_PINS: Readonly<Record<string, readonly CompanyIdPin[]>> = {
|
||||
admin_history: [
|
||||
{
|
||||
@@ -46,10 +97,16 @@ const COMPANY_ID_SOURCE_PINS: Readonly<Record<string, readonly CompanyIdPin[]>>
|
||||
note: 'filter 走 toImageVideoQuery 白名单构造,公司值只能落在 companyId 形参上',
|
||||
},
|
||||
],
|
||||
admin_task_center: [
|
||||
{ file: 'src/api/task-center.ts', shape: null, note: 'Task 10 未接线(已在缺口清单里);谁接线谁把 null 换成本函数真实取值口' },
|
||||
{ file: 'src/pages/task-center/task-center-model.ts', shape: null, note: '同上:这一页有两个取数模块,两个都得登记' },
|
||||
],
|
||||
// 五个发送口五条钉(一函数一条),不是一条文件级钉数五处:判据形状见 TASK_CENTER_SEND_POINTS 的举证。
|
||||
// 这一页也不许套 Task 8 的 `params.companyId` 形——api 侧 `tasks`/`variant-tasks` 是 `params: QueryParams`
|
||||
// 直传、没有 params.companyId 这个口,公司键由 model 那两个 builder 补进同一个对象。
|
||||
admin_task_center: TASK_CENTER_SEND_POINTS.map((p, i) => ({
|
||||
file: p.file,
|
||||
shape: sendPointShape(p.fn),
|
||||
note: `发送口 ${i + 1}/5 ${p.title}(${p.fn}):null 由发送口自己丢(不依赖 axios 丢 null),`
|
||||
+ '右半边必须是本函数自己的形参 companyId;红点归属见下面「拆条的补集」那段——删掉塞键那一行报在对平闸门,'
|
||||
+ '这条 shape 独家点名的是计数不掉的形变(函数名改了、或那一行离自己函数开行超过了窗口)',
|
||||
})),
|
||||
admin_user_secret_usage: [
|
||||
{
|
||||
file: 'src/api/user-secret-usage.ts',
|
||||
@@ -105,8 +162,8 @@ let strictPinsPassed = 0
|
||||
|
||||
test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company_id,页面组件必须 watch activeId', () => {
|
||||
// 循环里**收集**、循环后一次性断言:Task 8-12 是 5 个任务共用这把尺子,fail-fast 时做完自己那页的同事
|
||||
// 仍然只看到一句指向**别人页**的红(今天只报 src/api/task-center.ts),判断不出本页是否已收敛。
|
||||
// 这条不改变"Task 12 之前必红"的既定性质,只是让尺子可诊断——红消息里 8 页缺口逐页列全。
|
||||
// 仍然只看到一句指向**别人页**的红,判断不出本页是否已收敛。
|
||||
// 这条只是让尺子可诊断——红消息里 8 页缺口逐页列全(批次 1 到 Task 10 已全部接线,今天这支应绿)。
|
||||
const problems: string[] = []
|
||||
for (const page of COMPANY_SCOPED_PAGES) {
|
||||
const gaps: string[] = []
|
||||
@@ -178,8 +235,57 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
|
||||
assert.ok(COMPANY_ID_SOURCE_PINS.admin_history.some((p) => p.shape !== null)
|
||||
&& COMPANY_ID_SOURCE_PINS.admin_image_video_tasks.some((p) => p.shape !== null),
|
||||
'Task 8 已接线的两页在登记表里的 shape 被改回 null 了:严格判据对这两页不再起作用(正样本归零)')
|
||||
|
||||
// —— I-1 拆条那 5 条钉的取样自检(全局约束 15:反向钉必须自带同支正样本,
|
||||
// 不许让另一支用例替我证明"这串本来就会被匹配到")。
|
||||
// ⚠ 身份要说清:下面这几条是对**字面量字符串**求值的探针,只证明判据形状没写坏
|
||||
// (正样本匹配得出 ⇒ 不恒红;窗口外的负样本不匹配 ⇒ 窗口真有界,删一处不会靠隔壁过关),
|
||||
// 任何代码注入都不会让它们红。真覆盖 = 上面 loop 里那 5 条 shape 对真实文件的求值 + 变异自证。
|
||||
// ⚠ 这条 length 比对**按构造恒真**(2026-10-05 复评 N-2):登记表条目就是 `TASK_CENTER_SEND_POINTS.map(...)`,
|
||||
// 删表一行两边同时变成 4,它一声不响。它只剩一种防御对象——有人把那个 `.map()` 换成手写 N 条字面 pin;
|
||||
// 「删表一行」的真红点在下面「拆条的补集」那条逐文件对平闸门(它的分母取自源码里的字面发送口,与表不同源)。
|
||||
assert.equal(COMPANY_ID_SOURCE_PINS.admin_task_center.length, TASK_CENTER_SEND_POINTS.length,
|
||||
`登记表条数与 TASK_CENTER_SEND_POINTS 条数不等 ⇒ 上面那条 .map() 被换成了手写 pin 且数量不符`
|
||||
+ `(表 ${TASK_CENTER_SEND_POINTS.length} 条 / 登记表 ${COMPANY_ID_SOURCE_PINS.admin_task_center.length} 条)`)
|
||||
for (const p of TASK_CENTER_SEND_POINTS) {
|
||||
const shape = sendPointShape(p.fn)
|
||||
const compliant = sendPointCompliant(p.fn)
|
||||
assert.ok(shape.test(compliant),
|
||||
`(拆条取样自检·正样本)${p.fn} 的合规样本都匹配不出 ${shape} ⇒ 这条钉恒红,删没删发送口都会红,等于没看守`)
|
||||
const deleted = compliant.replace(` ${TASK_CENTER_SEND_LINE}\n`, '')
|
||||
+ ' '.repeat(TASK_CENTER_WINDOW + 1) + TASK_CENTER_SEND_LINE
|
||||
assert.equal(shape.test(deleted), false,
|
||||
`(拆条取样自检·负样本)${p.fn} 删掉自己那一行、只剩窗口外的隔壁发送口却仍然匹配 ⇒ 窗口够得到了隔壁,删一处不会红`)
|
||||
}
|
||||
|
||||
// 拆条的补集(复评 I-1 的另一半):一条钉管一个发送口 ⇒ 每个文件登记的钉数必须等于该文件里发送口的实际条数。
|
||||
// 红点归属要说实(2026-10-05 复评 N-1):shape 不匹配只往 gaps 里记,得等本用例末尾的
|
||||
// `assert.deepEqual(problems, [])` 才喊,而这条闸门在同一 test 体内**先执行** ⇒
|
||||
// 「删源码里的塞键那一行」(变异自证 M1–M5 就是这一形)实际报的是这里的「钉数 ≠ 实际条数」消息
|
||||
// (点名到文件,点不到函数)。顺序不许倒过来:取样自检与这条闸门先跑,判据坏了要先说"判据坏了"。
|
||||
// 上面那 5 条 shape 独家点名的字面发送口条数不变,只有它能红——函数名改了(锚点消失)、
|
||||
// 或那一行还在但离自己函数开行超过了窗口(前面被写长)。
|
||||
// 这一条杀的是「把 TASK_CENTER_SEND_POINTS 删剩 4 行」——少一条钉就等于少一处看守,而 5 条 shape 谁都不会红。
|
||||
// 路线 ②(occurrences 计数)在这里只当"钉数与发送口条数对平"的闸门,不当"是哪一处"的判据:
|
||||
// 计数回答不了"哪三处"(把一处重复写三遍、另一处删掉,计数照样对平),所以主判据仍是路线 ① 的函数名锚 + 有界窗口。
|
||||
const pinnedPerFile = new Map<string, number>()
|
||||
for (const p of TASK_CENTER_SEND_POINTS) {
|
||||
pinnedPerFile.set(p.file, (pinnedPerFile.get(p.file) ?? 0) + 1)
|
||||
}
|
||||
assert.equal(pinnedPerFile.size, 2,
|
||||
`发送口表应当只覆盖 api + model 这 2 个文件,现在却有 ${pinnedPerFile.size} 个 —— 表被改形状了,对平判据失去分母`)
|
||||
for (const [file, pinned] of pinnedPerFile) {
|
||||
const actual = occurrences(stripComments(read(file)), TASK_CENTER_SEND_LINE)
|
||||
assert.equal(pinned, actual,
|
||||
`${file} 里实际有 ${actual} 处「${TASK_CENTER_SEND_LINE}」,登记表却只钉了 ${pinned} 条 —— `
|
||||
+ '有一处发送口脱管(一函数一钉:钉数必须与该文件的发送口条数逐文件对平)')
|
||||
}
|
||||
// 同支正样本(全局约束 15:计数判据不许"0 == 0 也算对平"就当自己成立):字面样本里有两条,occurrences 必须数得出 2。
|
||||
assert.equal(occurrences(sendPointCompliant('f') + sendPointCompliant('g'), TASK_CENTER_SEND_LINE), 2,
|
||||
'(计数取样自检·正样本)occurrences 连两条字面发送口都数不出来 ⇒ 上面那条逐文件对平恒真,等于没看守')
|
||||
|
||||
assert.deepEqual(problems, [],
|
||||
`公司 tab 接线缺口(逐页列全;Task 8-12 补齐后这支自动收敛,本轮刻意留红):\n`
|
||||
`公司 tab 接线缺口(逐页列全;批次 1 的 8 页到 Task 10 已全部接线,谁再退回未接线就红在这里):\n`
|
||||
+ problems.map((p) => ` - ${p}`).join('\n'))
|
||||
})
|
||||
|
||||
@@ -196,6 +302,121 @@ test('反向:把 company_id 当查询参数用的取数模块必须被清单
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 切公司必须把「上一家选中的筛选项」一起清掉(TaskList #22,控制方 2026-10-05 点名;
|
||||
* 2026-10-05 修复轮 1 复评 M-2 把它抽成 (file, token) 两对,见下面 WATCH_BODY_PINS)。
|
||||
*
|
||||
* <p>为什么单独钉 watch 体:体里那些赋值是**用户选中的值**,不是每次请求重算的。切到另一家公司后,
|
||||
* 上一家选中的 `filter.groupId` / `filter.shop` 在新一家的可见集与候选字典里根本不存在,列表于是被
|
||||
* 一个不存在的值筛成空页——症状是「tab 一切页面就白」,而请求、后端、权限三处全对。
|
||||
* G1 的 pageFiles 只断「watch 了 activeId」与「读过 requestCompanyId」(正向那条用例的末尾两行),
|
||||
* 看不见 watch 体里到底做了什么,所以体内容必须单独钉。</p>
|
||||
*
|
||||
* <p>M-2 的洞:这条看守原本把锚写死在 `ShopManagePage.vue:108` 的 `filter.groupId = null` 上,
|
||||
* 同形不同页——任务看板页自己那条 `filter.shop = ''`(裁决 1 加的,`TaskCenterBoardPage.vue:176`)
|
||||
* 当时没有任何看守:删掉那一行时 G1 只断「存在 watch」、G2 不扫 `.vue`、后端用例不涉及前端文本 ⇒ 全绿,
|
||||
* 症状回到裁决 1 想避免的那一型。</p>
|
||||
*
|
||||
* <p>判据形状:从 `watch(() => companyTab.activeId, …)` 那**一条语句**取文本(正则在第一个
|
||||
* `}` + `)` 处收口 ⇒ 单层,体内再嵌对象字面量会截早;两页今天都没有那种写法,由下面的取样自检兜着)。
|
||||
* 反向钉与正样本同支(全局约束 15,三条前提不成立就是探针失效、当场红,不许静默空跑),**每一对**都各跑一遍:
|
||||
* ① 合规样本必须匹配得出且含两把 token ⇒ 判据不恒红;
|
||||
* ② 删掉那一句的样本必须不含 ⇒ 判据能红(变异自证走的就是这一条);
|
||||
* ③ 把同一串 token 挪到 watch 之外的样本必须不含 ⇒ 钉的是**位置**,不是「文件里出现过」。
|
||||
* 每对末尾还配了一条同链前提:那一页的发送口仍在发 `company_id`,清筛选项才有意义。</p>
|
||||
*
|
||||
* <p>刻意没钉的部分(判据收在"钉得住"那一档):`taskPage.value = 1` / `variantPage.value = 1`——
|
||||
* `= 1` 这一形在 watch 体外满篇都是(search/changeTaskPage/resetFilter 都写它),
|
||||
* 用 `matches[0].includes('taskPage.value = 1')` 只会把判据做成"这一行在不在体内"的第二个 filter.shop,
|
||||
* 而页码回 1 的红利是观感不是越权,本轮不扩围。</p>
|
||||
*/
|
||||
const WATCH_ACTIVE_ID = /watch\(\(\)\s*=>\s*companyTab\.activeId\s*,\s*\(\)\s*=>\s*\{([\s\S]*?)\}\s*\)/
|
||||
|
||||
/**
|
||||
* (文件, 必须出现在 watch 体内的赋值) 两对,同一条 test 里逐对钉。
|
||||
* `premise` 是这一对的反向钉前提:这一页的发送口今天还在发 `company_id`,清筛选项才有意义;
|
||||
* 哪天发送口退回不带参,watch 看守就变成"清了一个没人用的筛选项",必须一起红。
|
||||
*/
|
||||
const WATCH_BODY_PINS: ReadonlyArray<{
|
||||
readonly file: string
|
||||
readonly token: string
|
||||
readonly why: string
|
||||
readonly premise: ReadonlyArray<{ readonly file: string; readonly shapes: readonly RegExp[] }>
|
||||
}> = [
|
||||
{
|
||||
file: 'src/pages/shop/ShopManagePage.vue',
|
||||
token: 'filter.groupId = null',
|
||||
why: '上一家选中的 groupId 在新一家的可见集里根本不存在,列表会被它筛成空页',
|
||||
premise: [
|
||||
{
|
||||
file: 'src/pages/shop/shop-manage-api.ts',
|
||||
shapes: [/company_id\s*=\s*params\.companyId\b/, /company_id\s*:\s*companyId\b/],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
file: 'src/pages/task-center/TaskCenterBoardPage.vue',
|
||||
token: "filter.shop = ''",
|
||||
why: 'shop 的候选字典 /shop-options 现在按公司下传,上一家选中的店铺名在新一家不存在 ⇒ 切 tab 后首屏被筛成「暂无符合条件的任务」',
|
||||
premise: [
|
||||
{ file: 'src/api/task-center.ts', shapes: [/company_id\s*=\s*companyId\b/] },
|
||||
{ file: 'src/pages/task-center/task-center-model.ts', shapes: [/company_id\s*=\s*companyId\b/] },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
/** 取「`watch(() => companyTab.activeId, () => { … })`」这一条语句的原文;匹配不出返回 null(由调用方判探针失效)。 */
|
||||
function watchStatement(source: string): string | null {
|
||||
const m = WATCH_ACTIVE_ID.exec(source)
|
||||
return m ? m[0] : null
|
||||
}
|
||||
|
||||
test('切公司的 watch 体:每对 (file, token) 都要在该页 watch 体内出现(店铺管理清 groupId、任务看板清 shop)', () => {
|
||||
assert.ok(WATCH_BODY_PINS.length >= 2,
|
||||
'watch 体看守被删到只剩一对 ⇒ 这一族又退回"只钉 ShopManagePage",任务看板那行 filter.shop 再次没人看守')
|
||||
const pinnedFiles = new Set(WATCH_BODY_PINS.map((pin) => pin.file))
|
||||
for (const pin of WATCH_BODY_PINS) {
|
||||
// ① 正样本(判据不恒红)——逐字就是这一页今天 watch 体里的那一行。
|
||||
const positive = watchStatement(`watch(() => companyTab.activeId, () => { ${pin.token}; void loadGroups(); void load() })`)
|
||||
assert.ok(positive, `探针失效(${pin.file}):合规样本都匹配不出 watch 语句 ⇒ 判据恒红,这条看守等于没写`)
|
||||
assert.ok(positive.includes('companyTab.activeId') && positive.includes(pin.token),
|
||||
`探针失效(${pin.file}):合规样本没同时含两把 token ⇒ 下面两条断言无从判定`)
|
||||
|
||||
// ② 负样本 1(判据能红):删掉清筛选项那一句——变异自证注入的就是这一形。
|
||||
const dropped = watchStatement('watch(() => companyTab.activeId, () => { void loadGroups(); void load() })')
|
||||
assert.ok(dropped, `探针失效(${pin.file}):负样本 1 匹配不出 watch 语句,无从判定它该红`)
|
||||
assert.equal(dropped.includes(pin.token), false,
|
||||
`负样本 1 失效(${pin.file}):删掉 ${pin.token} 还判它含 ⇒ 这条看守杀不了变异`)
|
||||
|
||||
// ③ 负样本 2(钉位置不钉全文):token 在同一个文件里、但不在 watch 体内。
|
||||
const elsewhere = watchStatement(`function resetAll() { ${pin.token} }\nwatch(() => companyTab.activeId, () => { void load() })`)
|
||||
assert.ok(elsewhere, `探针失效(${pin.file}):负样本 2 匹配不出 watch 语句,无从判定它该红`)
|
||||
assert.equal(elsewhere.includes(pin.token), false,
|
||||
`负样本 2 失效(${pin.file}):watch 体外的 ${pin.token} 被算成了体内 ⇒ 判据退化成"文件里出现过就行"`)
|
||||
|
||||
const source = stripComments(readSource(pin.file))
|
||||
const matches = source.match(new RegExp(WATCH_ACTIVE_ID.source, 'g')) ?? []
|
||||
assert.equal(matches.length, 1,
|
||||
`${pin.file} 里匹配到 ${matches.length} 条 watch(() => companyTab.activeId, () => {…}):`
|
||||
+ '0 条 = watch 换了写法(判据失明)或被拆成多条,都得先核对再动判据')
|
||||
assert.ok(matches[0].includes(pin.token),
|
||||
`切公司没清掉上一家选中的筛选项 ${pin.token}:${pin.why}`
|
||||
+ '(tab 看起来"坏了",而请求、后端、权限三处都没错,最难查的那一型)')
|
||||
|
||||
// 同链前提(反向钉不许独自成立):这一页的发送口仍然在发 company_id。
|
||||
// 哪天发送口退回不带参,上面这条 watch 看守就变成"清了一个没人用的筛选项"——前提必须一起在场。
|
||||
for (const link of pin.premise) {
|
||||
const api = stripComments(read(link.file))
|
||||
for (const shape of link.shapes) {
|
||||
assert.ok(shape.test(api),
|
||||
`${link.file} 不再带 company_id(要求 ${shape}):${pin.file} 那条 watch 看守的前提没了`)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 覆盖性自检(表别被顺手删空,也别只钉上一对)。
|
||||
assert.equal(pinnedFiles.size, WATCH_BODY_PINS.length, 'WATCH_BODY_PINS 里出现了重复 file ⇒ 有一对被覆盖掉了')
|
||||
})
|
||||
|
||||
test('两张清单不许重叠:超管专属页不可能同时是按公司看数据的页', () => {
|
||||
const scoped = new Set(COMPANY_SCOPED_PAGES.map((p) => p.menuKey))
|
||||
for (const key of SUPER_ADMIN_ONLY_MENU_KEYS) assert.equal(scoped.has(key), false)
|
||||
|
||||
+79
-12
@@ -3,6 +3,7 @@ package com.nanri.aiimage.modules.taskcenter.controller;
|
||||
import com.nanri.aiimage.common.api.ApiResponse;
|
||||
import com.nanri.aiimage.common.model.entity.AdminUserEntity;
|
||||
import com.nanri.aiimage.common.security.AdminAuthSupport;
|
||||
import com.nanri.aiimage.common.service.DataReadScope;
|
||||
import com.nanri.aiimage.modules.permission.service.PermissionMenuService;
|
||||
import com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterTaskQuery;
|
||||
import com.nanri.aiimage.modules.taskcenter.model.vo.TaskCenterOverviewVo;
|
||||
@@ -13,6 +14,7 @@ import com.nanri.aiimage.modules.taskcenter.service.TaskCenterQueryService;
|
||||
import com.nanri.aiimage.modules.taskcenter.service.TaskCenterScopeService;
|
||||
import com.nanri.aiimage.modules.taskcenter.service.TaskCenterVariantService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -29,6 +31,17 @@ import java.util.List;
|
||||
*
|
||||
* <p>仅超管默认可见;管理员需超管在「用户管理 → 菜单权限」授权 {@code admin_task_center}
|
||||
* 后才能访问。数据范围 = 本人 + 本组用户 + 自己管理的成员(超管不裁剪)。</p>
|
||||
*
|
||||
* <p>公司 tab(spec §4):五个端点各收一个可选 {@code company_id},都在 handler 体内过唯一出口
|
||||
* {@link DataReadScope#readScope} 算成员集,再交给 {@code TaskCenterScopeService.resolve} 与既有口径
|
||||
* 求交——一处收窄,五个出口天然同宽(详情走 {@code scope.visible()},用的就是同一条集合)。
|
||||
* 那一行之所以在五个 handler 里各写一遍而不是抽进私有方法:护栏
|
||||
* {@code CompanyIdParamGoesThroughReadScopeTest} 的断言 A 认的是「这支 handler 体内出现过 readScope(」,
|
||||
* 抽走之后**只有 A 会红**(且因为 A 是 fail-fast,只点名第一支);C 根本不响——它的门槛就是「体内含
|
||||
* readScope(」,体内没了就连评估都不评估;D 绿——它认 {@code resolveScope(},而 {@code companyId} 正好
|
||||
* 还在那条私有委托的实参表里。所以逐字重复买到的是「A 这一记看守在每支 handler 上各站一次」,
|
||||
* 不是三重红:别把它当成「C/D 也兜着」而去试 A 拦得住之外的形状(2026-10-05 复评 I-2 订正,
|
||||
* 原话「抽走即三只都红」与 MUT-A 的实测读数 2 tests / 1 failure 不符)。</p>
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -42,20 +55,35 @@ public class AdminTaskCenterController {
|
||||
private final TaskCenterScopeService scopeService;
|
||||
private final TaskCenterQueryService queryService;
|
||||
private final TaskCenterVariantService variantService;
|
||||
private final DataReadScope dataReadScope;
|
||||
|
||||
@GetMapping("/overview")
|
||||
@Operation(summary = "汇总卡", description = "总店铺/在跑店铺数、进行中任务数、今日完成任务数、"
|
||||
+ "疑似卡住数(进行中且 >10 分钟无上报)。")
|
||||
public ApiResponse<TaskCenterOverviewVo> overview(HttpServletRequest request) {
|
||||
TaskCenterScopeService.ScopeContext scope = resolveScope(request);
|
||||
public ApiResponse<TaskCenterOverviewVo> overview(
|
||||
HttpServletRequest request,
|
||||
@Parameter(description = "公司 ID(超管 tab;不传=不筛)")
|
||||
@RequestParam(name = "company_id", required = false) Long companyId) {
|
||||
AdminUserEntity operator = authorizedOperator(request);
|
||||
boolean superAdmin = isSuper(operator);
|
||||
Long operatorId = operator.getId();
|
||||
List<Long> companyUserIds = superAdmin ? dataReadScope.readScope(operator, companyId).userIdsOr(null) : null;
|
||||
TaskCenterScopeService.ScopeContext scope = resolveScope(operatorId, companyUserIds);
|
||||
return ApiResponse.success(queryService.overview(scope));
|
||||
}
|
||||
|
||||
@GetMapping("/shop-options")
|
||||
@Operation(summary = "店铺筛选候选",
|
||||
description = "店铺库(biz_shop_manage)在可见范围内的店铺名,供筛选下拉精确匹配;只出店铺名。")
|
||||
public ApiResponse<List<String>> shopOptions(HttpServletRequest request) {
|
||||
TaskCenterScopeService.ScopeContext scope = resolveScope(request);
|
||||
public ApiResponse<List<String>> shopOptions(
|
||||
HttpServletRequest request,
|
||||
@Parameter(description = "公司 ID(超管 tab;不传=不筛)")
|
||||
@RequestParam(name = "company_id", required = false) Long companyId) {
|
||||
AdminUserEntity operator = authorizedOperator(request);
|
||||
boolean superAdmin = isSuper(operator);
|
||||
Long operatorId = operator.getId();
|
||||
List<Long> companyUserIds = superAdmin ? dataReadScope.readScope(operator, companyId).userIdsOr(null) : null;
|
||||
TaskCenterScopeService.ScopeContext scope = resolveScope(operatorId, companyUserIds);
|
||||
return ApiResponse.success(queryService.shopOptions(scope));
|
||||
}
|
||||
|
||||
@@ -64,8 +92,16 @@ public class AdminTaskCenterController {
|
||||
description = "biz_file_task(12 个客户端模块)∪ brand_crawl_tasks 按创建时间倒序;"
|
||||
+ "店铺按规范化名精确匹配(来源=上架结果文件 + 逐店落行的结果文件名);"
|
||||
+ "进行中且 >10 分钟无上报标记 stuck。")
|
||||
public ApiResponse<TaskCenterTaskPageVo> tasks(HttpServletRequest request, TaskCenterTaskQuery query) {
|
||||
TaskCenterScopeService.ScopeContext scope = resolveScope(request);
|
||||
public ApiResponse<TaskCenterTaskPageVo> tasks(
|
||||
HttpServletRequest request,
|
||||
TaskCenterTaskQuery query,
|
||||
@Parameter(description = "公司 ID(超管 tab;不传=不筛)")
|
||||
@RequestParam(name = "company_id", required = false) Long companyId) {
|
||||
AdminUserEntity operator = authorizedOperator(request);
|
||||
boolean superAdmin = isSuper(operator);
|
||||
Long operatorId = operator.getId();
|
||||
List<Long> companyUserIds = superAdmin ? dataReadScope.readScope(operator, companyId).userIdsOr(null) : null;
|
||||
TaskCenterScopeService.ScopeContext scope = resolveScope(operatorId, companyUserIds);
|
||||
return ApiResponse.success(queryService.tasks(scope, query));
|
||||
}
|
||||
|
||||
@@ -74,8 +110,14 @@ public class AdminTaskCenterController {
|
||||
description = "参数 taskNo(品牌任务为 brand-<id>):基础信息 + 进度快照 + 分组明细 + 错误信息;"
|
||||
+ "任务不存在或不在可见范围时 data 为空。")
|
||||
public ApiResponse<TaskCenterTaskDetailVo> taskDetail(HttpServletRequest request,
|
||||
@RequestParam String taskNo) {
|
||||
TaskCenterScopeService.ScopeContext scope = resolveScope(request);
|
||||
@RequestParam String taskNo,
|
||||
@Parameter(description = "公司 ID(超管 tab;不传=不筛)")
|
||||
@RequestParam(name = "company_id", required = false) Long companyId) {
|
||||
AdminUserEntity operator = authorizedOperator(request);
|
||||
boolean superAdmin = isSuper(operator);
|
||||
Long operatorId = operator.getId();
|
||||
List<Long> companyUserIds = superAdmin ? dataReadScope.readScope(operator, companyId).userIdsOr(null) : null;
|
||||
TaskCenterScopeService.ScopeContext scope = resolveScope(operatorId, companyUserIds);
|
||||
TaskCenterTaskDetailVo detail = queryService.detail(scope, taskNo);
|
||||
if (detail == null) {
|
||||
return ApiResponse.success("任务不存在或无权查看", null);
|
||||
@@ -92,14 +134,39 @@ public class AdminTaskCenterController {
|
||||
@RequestParam(required = false) Integer status,
|
||||
@RequestParam(required = false) String taskType,
|
||||
@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer pageSize) {
|
||||
TaskCenterScopeService.ScopeContext scope = resolveScope(request);
|
||||
@RequestParam(required = false) Integer pageSize,
|
||||
@Parameter(description = "公司 ID(超管 tab;不传=不筛)")
|
||||
@RequestParam(name = "company_id", required = false) Long companyId) {
|
||||
AdminUserEntity operator = authorizedOperator(request);
|
||||
boolean superAdmin = isSuper(operator);
|
||||
Long operatorId = operator.getId();
|
||||
List<Long> companyUserIds = superAdmin ? dataReadScope.readScope(operator, companyId).userIdsOr(null) : null;
|
||||
TaskCenterScopeService.ScopeContext scope = resolveScope(operatorId, companyUserIds);
|
||||
return ApiResponse.success(variantService.variantTasks(scope, status, taskType, page, pageSize));
|
||||
}
|
||||
|
||||
private TaskCenterScopeService.ScopeContext resolveScope(HttpServletRequest request) {
|
||||
/** 会话闸门(登录态 + 菜单权限),五个端点同一把;service 只认算好的 operatorId。 */
|
||||
private AdminUserEntity authorizedOperator(HttpServletRequest request) {
|
||||
AdminUserEntity operator = adminAuthSupport.requireAdminOrInternal(request);
|
||||
permissionMenuService.requireClientTaskCenterAccess(operator);
|
||||
return scopeService.resolve(operator.getId());
|
||||
return operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否站点超管——用的是 {@code AdminAuthSupport.currentRole}(与 {@code DataReadScope} 内部同一把尺子,
|
||||
* 含「role 为空 + isAdmin=1 + createdById 为空」的历史超管推断),不是这里新造的判定。
|
||||
* 只有超管才按公司 tab 收窄:非超管的可见集里含「靠分组可见」的行,给它叠成员集会把那批行
|
||||
* 从每一个 tab 里静默删掉;它的公司维度本来就由会话独家决定(spec §4)。
|
||||
*/
|
||||
private boolean isSuper(AdminUserEntity operator) {
|
||||
return "super_admin".equals(adminAuthSupport.currentRole(operator));
|
||||
}
|
||||
|
||||
/**
|
||||
* 五个端点共用的收窄出口:{@code companyUserIds} 必须是 handler 体内 {@code readScope} 算出来的那个值
|
||||
* ({@code null} = 不收窄),不许在这一层重新取公司值——那样护栏 A/C/D 看见的就不是这条链了。
|
||||
*/
|
||||
private TaskCenterScopeService.ScopeContext resolveScope(Long operatorId, List<Long> companyUserIds) {
|
||||
return scopeService.resolve(operatorId, companyUserIds);
|
||||
}
|
||||
}
|
||||
|
||||
+36
@@ -17,6 +17,9 @@ import java.util.Set;
|
||||
* 客户端任务管理的数据范围:超管看全部,管理员看「本人 + 本组用户 + 自己管理的成员」。
|
||||
* 口径与 {@code DedupeTotalDataService.resolveAccessScope} 一致——范围按任务发起账号
|
||||
* (biz_file_task.user_id)判定,不按设备归属,设备跨组使用也不会串组。
|
||||
*
|
||||
* <p>公司 tab(spec §4)叠在这条既有口径之上:{@link #resolve(Long, List)} 只与上面的集合求交,
|
||||
* 超管选了公司才有收窄,非超管的范围仍由会话独家决定。</p>
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -26,7 +29,40 @@ public class TaskCenterScopeService {
|
||||
private final ShopManageGroupMapper shopManageGroupMapper;
|
||||
private final CompanyScopeSupport companyScopeSupport;
|
||||
|
||||
/** 一参委托不是死代码:main 侧零调用点(controller 只走两参),活着只因 TaskCenterScopeServiceTest 的 8 处单参调用 service.resolve(id)(:58/:73/:83/:98/:112/:124/:130/:131,行号会漂移,计数以 grep「service.resolve( 单参」= 8 为准),裁决 3 指定保留,删这一行红那 8 支用例。 */
|
||||
public ScopeContext resolve(Long operatorId) {
|
||||
return resolve(operatorId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司 tab 的收窄点:在 {@link #resolveBase(Long)} 的既有可见集上**只叠一层交集**,一律不放大
|
||||
* (spec §4)。客户端任务管理的五个端点共用这一处,所以「列表筛了但按 id 能读」在这一页不存在
|
||||
* ——详情走 {@code scope.visible(userId)},与列表同一条集合。
|
||||
*
|
||||
* <p>{@code companyUserIds} 由 controller 过唯一出口 {@code DataReadScope.readScope} 算好
|
||||
* (本 service 手上只有 operatorId,没有操作者实体之外的会话信息,交不出这个集合)。
|
||||
* <b>{@code null} 与空集不是一回事</b>:{@code null} = 不收窄(非超管、或超管没选公司),
|
||||
* 逐字退回今天的行为;空集 = 选了公司但这家一个账号都没有,必须收窄成恒不命中
|
||||
* ({@link ScopeContext#sqlUserIds()} 的 {@code [-1]} 兜底)。这里要是把空集也当「没选」放过,
|
||||
* 症状是「切到空公司 tab 反而看见全量」——越权,且不报错。</p>
|
||||
*
|
||||
* @param companyUserIds 公司成员账号集;{@code null} 表示不按公司收窄
|
||||
*/
|
||||
public ScopeContext resolve(Long operatorId, List<Long> companyUserIds) {
|
||||
ScopeContext base = resolveBase(operatorId);
|
||||
if (companyUserIds == null) {
|
||||
return base;
|
||||
}
|
||||
LinkedHashSet<Long> visible = new LinkedHashSet<>();
|
||||
addAll(visible, companyUserIds);
|
||||
if (!base.allUsers()) {
|
||||
visible.retainAll(base.visibleUserIds());
|
||||
}
|
||||
return new ScopeContext(false, Set.copyOf(visible));
|
||||
}
|
||||
|
||||
/** 今天的三条腿,逐字保留(超管直通 / 公司超管按会话 / 管理员按分组),不动口径、不换 mapper 方法。 */
|
||||
private ScopeContext resolveBase(Long operatorId) {
|
||||
AdminUserEntity operator = requireOperator(operatorId);
|
||||
if (isSuperAdmin(operator)) {
|
||||
return new ScopeContext(true, Set.of());
|
||||
|
||||
+277
-1
@@ -95,6 +95,25 @@ import org.junit.jupiter.api.Test;
|
||||
* ② 该变量必须出现在 handler 体内<b>另一条方法调用的实参列表</b>里(扣掉它自己那条赋值语句,
|
||||
* 单层括号够用,今天两页都是这一形)。只要求"在别处被引用一次"不够:
|
||||
* {@code if (scoped != null) throw …} 是装饰,不算把范围交给谁 ⇒ 控制语句关键字不认。</li>
|
||||
* <li><b>调了出口不等于把公司参数交给了出口</b>(本轮新增的断言 D)。现网最难查的一刀是
|
||||
* {@code dataReadScope.readScope(operator, null)}:参数照样收下(B 绿)、{@code readScope(} 照样写在
|
||||
* handler 体内(A 绿)、算出来的范围照样接住并喂给 service(C 绿),唯独 tab 传下来的那个值
|
||||
* 没进出口——症状是"接口 200、页面一切正常、切 tab 数字永远不动",G1 只看前端文本同样不红。
|
||||
* D 因此先按 {@link Block#boundCompanyParam()} 从<b>声明窗口</b>里取出被绑定到
|
||||
* {@code company_id} 的<b>变量名</b>(不硬编码 {@code companyId}:这一支改叫 {@code orgId} 就用
|
||||
* {@code orgId} 判),再要求它作为整词实参出现在 {@code readScope}/{@code resolveScope} 的参数表里
|
||||
* (单层括号,复用 {@link #CALL_ARGUMENTS};私有收口方法 {@code resolveScope(request, companyId)}
|
||||
* 那一形算,Task 11 模板鼓励的正是它)。只写在 {@code if (companyId != null)} 里、或只出现在
|
||||
* {@code @Operation} 文案里,都不算消费——沿用 C 的 {@link #NOT_VALUE_CONSUMERS} 那把尺子,不放宽。
|
||||
* 射程与 A/B/C 同源:同一个 {@code takesCompanyParam()} 谓词、同一份
|
||||
* {@link #READ_SCOPE_ALLOWLIST}(一条豁免同时免 A/B/C/D,不许另起第二张表),并且只咬
|
||||
* {@code viaRequestParam()} 那一族(F-C 的同一把尺子:{@code getParameter("company_id")} 给不出
|
||||
* 绑定变量名,D 对它无从判定)。取不到绑定名 = 形状不认识 ⇒ 判红并报形状,不许静默放过。
|
||||
* D 的代价与射程一并交代(本轮报告有逐条清单):{@link #CALL_ARGUMENTS} 只吃单层括号,于是
|
||||
* {@code readScope(operator, normalize(companyId))} 这种嵌套写法会判红(误伤合规代码,改写法或补宽
|
||||
* D 的取法都算核对过);非 {@code Long} 型公司参数取不到绑定名,同样判红;而"handler 之外的私有
|
||||
* 收口方法里把公司参数硬写成 {@code null}"这一族 D 看不见——块边界止于该 handler 自己的闭括号
|
||||
* (第 7 条),{@code AdminImageVideoTaskController.scopeOf} 正是它,那一处是<b>故意</b>传 null 的。</li>
|
||||
* </ol>
|
||||
*
|
||||
* <p>取样键:可执行行里出现 {@code company_id} <b>或</b> {@code companyId}(裸 token 即入样本,交给逐 handler
|
||||
@@ -170,6 +189,24 @@ class CompanyIdParamGoesThroughReadScopeTest {
|
||||
private static final Set<String> NOT_VALUE_CONSUMERS = Set.of(
|
||||
"if", "for", "while", "switch", "do", "catch", "synchronized", "return", "throw", "else", "try");
|
||||
|
||||
/**
|
||||
* 断言 D 认的两个被调名:{@code readScope} 是唯一出口本身,{@code resolveScope} 是 Task 11 模板
|
||||
* 鼓励的"controller 里的私有收口方法"那一形(它内部再去 readScope)。除此之外的调用都不算
|
||||
* "把公司参数交给了出口"——尤其 {@code readScope(operator, null)} 里那个 {@code null}。
|
||||
*/
|
||||
private static final String RESOLVE_SCOPE_CALL = "resolveScope(";
|
||||
private static final Set<String> SCOPE_CALLEES = Set.of("readScope", "resolveScope");
|
||||
|
||||
/**
|
||||
* 断言 D 的取绑定名(两把锚一起用):先在声明窗口里找 {@code name = "company_id"}
|
||||
* (容 {@code name="company_id"} 这类空格写法,且窗口已 join ⇒ 折行签名也认),
|
||||
* 再取它<b>之后</b>第一个 {@code Long 变量名}。取"之后第一个"而不是"最后一个":
|
||||
* {@code ShopManageController.page} 的参数表里 {@code Long page}/{@code Long pageSize}/{@code Long groupId}
|
||||
* 都排在公司参数<b>之前</b>,抓最后一个或整窗抓都会抓错人。
|
||||
*/
|
||||
private static final Pattern EXPLICIT_COMPANY_NAME = Pattern.compile("name\\s*=\\s*\"company_id\"");
|
||||
private static final Pattern COMPANY_PARAM_DECL = Pattern.compile("Long\\s+([A-Za-z_$][\\w$]*)");
|
||||
|
||||
/**
|
||||
* 参数绑定注解(F-A):一行里出现它们,这一行就是<b>真参数声明</b>,无论同行是否还写着
|
||||
* {@code description =}——本仓 93 行 {@code @Parameter(description = "…") @RequestParam(…)} 挤同一行的
|
||||
@@ -256,8 +293,68 @@ class CompanyIdParamGoesThroughReadScopeTest {
|
||||
}
|
||||
""";
|
||||
|
||||
/**
|
||||
* 断言 D 的负探针(<b>D 的存在理由</b>):公司参数收了、{@code readScope(} 也写在 handler 体内、
|
||||
* 结果也接住并喂给了 service——唯独 tab 传下来的那个值被写成了 {@code null}。
|
||||
* <p>A/B/C 三条判据对这段源码<b>都判通过</b>(用例里带了这三条反面证据,判不过就说明探针没有区分度、
|
||||
* D 只是重复劳动),G1 只看前端文本同样不红;现网症状"接口 200、页面正常、切 tab 数字永远不动"
|
||||
* 就是这一形。只有 D 红。</p>
|
||||
*/
|
||||
private static final String SCOPE_PASSED_NULL_PROBE = """
|
||||
@GetMapping("/probe")
|
||||
public String passedNull(@RequestParam(name = "company_id", required = false) Long companyId) {
|
||||
List<Long> ids = dataReadScope.readScope(operator, null).userIdsOr(null);
|
||||
shopService.page(page, ids);
|
||||
return "ok";
|
||||
}
|
||||
""";
|
||||
|
||||
/**
|
||||
* 断言 D 的正探针:{@code companyId} 交给同文件的私有收口方法({@code resolveScope(request, companyId)},
|
||||
* Task 11 模板那一形,内部再去 readScope)⇒ D 不许红。
|
||||
*/
|
||||
private static final String SCOPE_PASSED_THROUGH_HELPER_PROBE = """
|
||||
@GetMapping("/probe")
|
||||
public String passedHelper(@RequestParam(name = "company_id", required = false) Long companyId,
|
||||
HttpServletRequest request) {
|
||||
ScopeContext scope = resolveScope(request, companyId);
|
||||
return String.valueOf(taskCenterQueryService.overview(scope));
|
||||
}
|
||||
""";
|
||||
|
||||
/**
|
||||
* 断言 D 的负探针 2(任务书 D.3 最后那一记"别放宽"的独立证据):{@code companyId} 只被 {@code if}
|
||||
* 读了一次(控制语句不算消费,与 C 共用 {@link #NOT_VALUE_CONSUMERS} 那把尺子),进出口的是 {@code null}
|
||||
* ⇒ D 必须红。断言 A/B/C 对它同样全绿:{@code readScope(} 在、{@code name = "company_id"} 在、
|
||||
* 结果接进 {@code scoped} 又喂给了 {@code shopService.page(…, scoped)}。
|
||||
*/
|
||||
private static final String SCOPE_ONLY_IF_DECOR_PROBE = """
|
||||
@GetMapping("/probe")
|
||||
public String onlyIf(@RequestParam(name = "company_id", required = false) Long companyId) {
|
||||
if (companyId != null) {
|
||||
log.info("tab 切了");
|
||||
}
|
||||
List<Long> scoped = dataReadScope.readScope(operator, null).userIdsOr(null);
|
||||
return String.valueOf(shopService.page(page, scoped));
|
||||
}
|
||||
""";
|
||||
|
||||
/**
|
||||
* 断言 D 的"绑定名不许硬编码"探针:这一支的公司参数声明叫 {@code orgId}(有的页会把它叫别的名字),
|
||||
* 并且真把 {@code orgId} 交给了出口 ⇒ D 必须用它自己取到的名字去判,判绿。
|
||||
* 如果 D 里写死了 {@code companyId},这一支会假红——这条就是那件事的反面证据。
|
||||
*/
|
||||
private static final String SCOPE_ALTERNATE_NAME_PROBE = """
|
||||
@GetMapping("/probe")
|
||||
public String otherName(@RequestParam(name = "company_id", required = false) Long orgId) {
|
||||
List<Long> scoped = dataReadScope.readScope(operator, orgId).userIdsOr(null);
|
||||
return String.valueOf(shopService.page(page, scoped));
|
||||
}
|
||||
""";
|
||||
|
||||
@Test
|
||||
@DisplayName("每个收公司 id 参数的 handler 都走唯一出口,并且显式写了 name = \"company_id\"")
|
||||
@DisplayName("每个收公司 id 参数的 handler 都走唯一出口、显式写了 name = \"company_id\","
|
||||
+ "而且 tab 传下来的那个值真被交给了出口(A/B/C/D)")
|
||||
void everyCompanyIdHandlerGoesThroughReadScope() throws IOException {
|
||||
assertThat(READ_SCOPE_ALLOWLIST)
|
||||
.as("白名单只允许 AdminUserController 一条:多一条 = 有人新开了一个不走唯一出口的 if")
|
||||
@@ -309,10 +406,43 @@ class CompanyIdParamGoesThroughReadScopeTest {
|
||||
.as("断言 C 自检(第二形):ReadScope s = dataReadScope.readScope(…) 且 s 进了 service.page(…) 的实参 ⇒ 同样要认")
|
||||
.isNull();
|
||||
|
||||
// 断言 D 的判据自检(两个方向都要,全局约束 15)。负探针要先证明"A/B/C 三条对它都判通过"——
|
||||
// 这三条前提不成立就说明这段源码本来已经有人看守,D 没有区分度、只是重复劳动。
|
||||
String nullProbeText = String.join("\n", textsOf(sourceLines(SCOPE_PASSED_NULL_PROBE)));
|
||||
assertThat(nullProbeText)
|
||||
.as("断言 D 负样本的前提(断言 A):readScope( 确实写在 handler 体内 ⇒ A 判它绿")
|
||||
.contains(READ_SCOPE_CALL);
|
||||
assertThat(nullProbeText)
|
||||
.as("断言 D 负样本的前提(断言 B):name = \"company_id\" 字面量也在 ⇒ B 判它绿")
|
||||
.contains(EXPLICIT_PARAM_NAME);
|
||||
assertThat(scopeProbeReason(SCOPE_PASSED_NULL_PROBE, "SCOPE_PASSED_NULL_PROBE"))
|
||||
.as("断言 D 负样本的前提(断言 C):范围照样接住并喂给了 service ⇒ C 也判它绿;"
|
||||
+ "三条前提同时成立才说明『参数被传成 null』这一刀今天没人杀")
|
||||
.isNull();
|
||||
assertThat(companyIdArgProbeReason(SCOPE_PASSED_NULL_PROBE, "SCOPE_PASSED_NULL_PROBE", CAMEL_PARAM))
|
||||
.as("断言 D 自检(负样本):readScope(operator, null) —— 公司参数没进出口 ⇒ 必须判红")
|
||||
.isNotNull()
|
||||
.contains("没进任何 readScope/resolveScope 的实参列表");
|
||||
assertThat(companyIdArgProbeReason(SCOPE_ONLY_IF_DECOR_PROBE, "SCOPE_ONLY_IF_DECOR_PROBE", CAMEL_PARAM))
|
||||
.as("断言 D 自检(负样本 2):companyId 只被 if 读了一次、进出口的是 null ⇒ 同样要红"
|
||||
+ "(控制语句不算消费,与 C 同一把尺子)")
|
||||
.isNotNull()
|
||||
.contains("没进任何 readScope/resolveScope 的实参列表");
|
||||
assertThat(companyIdArgProbeReason(SCOPE_PASSED_THROUGH_HELPER_PROBE, "SCOPE_PASSED_THROUGH_HELPER_PROBE", CAMEL_PARAM))
|
||||
.as("断言 D 自检(正样本):companyId 交给同文件私有 resolveScope(request, companyId) ⇒ 判据不许恒红")
|
||||
.isNull();
|
||||
assertThat(companyIdArgProbeReason(SCOPE_ALTERNATE_NAME_PROBE, "SCOPE_ALTERNATE_NAME_PROBE", "orgId"))
|
||||
.as("断言 D 自检(改名那一族):参数声明叫 orgId、交出去的也是 orgId ⇒ 不许红"
|
||||
+ "(这条同时钉住\"D 不许硬编码 companyId\":写死了它就会在这一支假红)")
|
||||
.isNull();
|
||||
|
||||
// 断言 C 的分母由本轮实扫得出(不写死数字):扫进射程的 handler 键、走完两步的正样本支数、红因先攒后判。
|
||||
List<String> scopeCaughtSample = new ArrayList<>();
|
||||
List<String> scopeDiscarded = new ArrayList<>();
|
||||
int scopeCaughtHandlers = 0;
|
||||
// 断言 D 的分母同一把尺子(同一批 handler、同一份豁免键):被 D 评过的 handler 键 + 红因先攒后判。
|
||||
List<String> companyIdArgSample = new ArrayList<>();
|
||||
List<String> companyIdArgMissing = new ArrayList<>();
|
||||
|
||||
List<Path> sampled = sampledControllers();
|
||||
assertThat(sampled)
|
||||
@@ -361,6 +491,20 @@ class CompanyIdParamGoesThroughReadScopeTest {
|
||||
scopeDiscarded.add(where + dropped);
|
||||
}
|
||||
}
|
||||
// 断言 D(本轮新增):范围"算过"且"交出去了"还不够——C 咬的是 readScope( 的<b>返回值</b>,
|
||||
// D 咬的是它的<b>入参</b>:tab 传下来的那个变量名必须真出现在 readScope/resolveScope 的
|
||||
// 实参列表里。readScope(operator, null) 三条判据全绿而 tab 恒不动,就是这一记。
|
||||
// 射程与 A/B/C 同源:同一个 takesCompanyParam() 谓词、同一份 READ_SCOPE_ALLOWLIST
|
||||
// (一条豁免同时免 A/B/C/D,不另起第二张表);只咬 viaRequestParam() 那一族(F-C 同一把
|
||||
// 尺子:getParameter("company_id") 那一族给不出绑定变量名,D 对它无从判定,不硬判)。
|
||||
if (takesCompanyParam && handler.viaRequestParam() && handler.hasScopeCall()
|
||||
&& !READ_SCOPE_ALLOWLIST.contains(exemptionKey(rel, handler))) {
|
||||
companyIdArgSample.add(exemptionKey(rel, handler));
|
||||
String argMissing = handler.companyIdArgFailure();
|
||||
if (argMissing != null) {
|
||||
companyIdArgMissing.add(where + argMissing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 残块(package/import/类级注解/字段,以及 handler 收口之后、下一支 handler 之前的尾随方法)
|
||||
@@ -391,6 +535,19 @@ class CompanyIdParamGoesThroughReadScopeTest {
|
||||
assertThat(scopeDiscarded)
|
||||
.as("范围算了但没接住(断言 C):readScope( 的结果要么没赋给变量,要么赋了却没交给任何方法调用")
|
||||
.isEmpty();
|
||||
|
||||
// 断言 D 的取样自检与分母(与 C 同一族纪律):空样本 = D 空转,射程不含已接线的页 = 静默脱离。
|
||||
assertThat(companyIdArgSample)
|
||||
.as("断言 D 取样集非空自检:一支『用 @RequestParam 收了公司 id 参数、体内又调了 "
|
||||
+ "readScope/resolveScope』的 handler 都没扫到 ⇒ D 一行都没评")
|
||||
.isNotEmpty();
|
||||
assertThat(companyIdArgSample)
|
||||
.as("断言 D 的射程必须覆盖已接线的那两页(改名/换 mapping 会让它静默脱离射程,分母不能自造)")
|
||||
.contains(SCOPE_CAUGHT_HISTORY_KEY, SCOPE_CAUGHT_VIDEO_KEY);
|
||||
assertThat(companyIdArgMissing)
|
||||
.as("公司参数没被交给出口(断言 D):readScope/resolveScope 的实参列表里没有出现被绑定到 "
|
||||
+ "company_id 的那个变量名 —— 参数收下、出口也调了,tab 却是死的")
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -436,6 +593,34 @@ class CompanyIdParamGoesThroughReadScopeTest {
|
||||
return handler.scopeCatchFailure();
|
||||
}
|
||||
|
||||
/**
|
||||
* 断言 D 的探针驱动器(形状同 {@link #scopeProbeReason},不新开风格):先确认这段样本真被切成
|
||||
* "1 支用 {@code @RequestParam} 收公司 id 参数、体内调了 readScope/resolveScope"的 handler,
|
||||
* 再钉住"取到的绑定名 == 探针里写的那个参数名"——取不到或取错人 = D 没在读声明窗口而是在硬编码
|
||||
* {@code companyId},那 D 自己就是坏的,探针必须红给编写者看;最后跑
|
||||
* {@link Block#companyIdArgFailure()} 取红因。
|
||||
*/
|
||||
private static String companyIdArgProbeReason(String probeSource, String probeName, String expectedBinding) {
|
||||
List<Block> blocks = splitBlocks(sourceLines(probeSource)).handlers();
|
||||
assertThat(blocks)
|
||||
.as(probeName + " 应当恰好切出 1 支 handler;切不出来则断言 D 的自检无从判定")
|
||||
.hasSize(1);
|
||||
Block handler = blocks.get(0);
|
||||
assertThat(handler.takesCompanyParam())
|
||||
.as(probeName + " 的 handler 没被认成收公司 id 参数,断言 D 根本不会触发 ⇒ 探针失效")
|
||||
.isTrue();
|
||||
assertThat(handler.viaRequestParam())
|
||||
.as(probeName + " 的公司参数不是 @RequestParam 绑定形状,断言 D 不咬它 ⇒ 探针失效")
|
||||
.isTrue();
|
||||
assertThat(handler.boundCompanyParam())
|
||||
.as(probeName + " 取到的绑定名与探针声明的参数名不一致 ⇒ D 没在读声明窗口(硬编码 companyId 的形状)")
|
||||
.isEqualTo(expectedBinding);
|
||||
assertThat(handler.hasScopeCall())
|
||||
.as(probeName + " 的 handler 体内没有 readScope( 或 resolveScope( ,断言 D 扫不到它 ⇒ 探针失效")
|
||||
.isTrue();
|
||||
return handler.companyIdArgFailure();
|
||||
}
|
||||
|
||||
/** 取样=可执行行里出现公司 token(下划线或驼峰),逐 handler 的窗口谓词再判定是否真收参数。 */
|
||||
private static List<Path> sampledControllers() throws IOException {
|
||||
if (!Files.isDirectory(MAIN_ROOT)) fail("找不到 " + MAIN_ROOT + " —— 用例依赖以 backend-java 为工作目录");
|
||||
@@ -769,6 +954,97 @@ class CompanyIdParamGoesThroughReadScopeTest {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 断言 D 的"这支到底调没调出口"门槛:连 {@code readScope(}/{@code resolveScope(} 都没写的 handler,
|
||||
* 红它的是断言 A,D 不叠一条重复的红(免得同一支同时冒出两条口径不同的消息)。
|
||||
*/
|
||||
boolean hasScopeCall() {
|
||||
String src = text();
|
||||
return src.contains(READ_SCOPE_CALL) || src.contains(RESOLVE_SCOPE_CALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 断言 D 的取绑定名:在<b>声明窗口</b>(mapping 注解行 → 方法体开行,join 后判 ⇒ 折行签名与
|
||||
* {@code @Parameter(…) @RequestParam(…)} 挤同一行的主流写法都认)里找 {@code name = "company_id"},
|
||||
* 取它<b>之后</b>第一个 {@code Long 变量名}("之后"必须留、"第一个"也必须留:
|
||||
* {@code ShopManageController.page} 的 {@code Long page}/{@code Long pageSize}/{@code Long groupId}
|
||||
* 全排在公司参数前面,整窗抓最后一个就抓错人了)。
|
||||
* <p>窗口里没有显式 {@code name=} 的那一支(驼峰静默失效,断言 B 已经为它判红)退回"窗口里第一条
|
||||
* 带公司 token 的非文档行"取同一个名字。<b>取的是源码里那个名字,不是 {@link #CAMEL_PARAM} 常量</b>:
|
||||
* 有的页把它叫 {@code orgId},写死就会在合规页上假红(改名为 orgId 的探针就是这条的反面证据)。
|
||||
* <p>返回 {@code null} = 公司参数不是 {@code … Long x} 那一形,由 {@link #companyIdArgFailure()} 判红
|
||||
* 并报形状,不许"当作这支没收公司参数"静默放过;窗口本身取不到的那一支由结构守卫负责,D 不重复报。</p>
|
||||
*/
|
||||
String boundCompanyParam() {
|
||||
List<String> window = declarationWindow();
|
||||
if (window == null) {
|
||||
return null;
|
||||
}
|
||||
String joined = String.join("\n", window);
|
||||
Matcher anchor = EXPLICIT_COMPANY_NAME.matcher(joined);
|
||||
if (anchor.find()) {
|
||||
return firstLongDeclaration(joined.substring(anchor.end()));
|
||||
}
|
||||
for (String line : window) {
|
||||
if (hasCompanyToken(line) && !isDocLine(line)) {
|
||||
String name = firstLongDeclaration(line);
|
||||
if (name != null) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** {@code Long 变量名} 的第一个命中;窗口里根本没有 {@code Long} 型参数就取不到(返回 null)。 */
|
||||
private static String firstLongDeclaration(String declarationText) {
|
||||
Matcher declared = COMPANY_PARAM_DECL.matcher(declarationText);
|
||||
return declared.find() ? declared.group(1) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 断言 D:被绑定到 {@code company_id} 的那个变量名,必须作为<b>整词实参</b>出现在这一支 handler
|
||||
* 体内某一次 {@code readScope}/{@code resolveScope} 调用的参数表里(单层括号,复用
|
||||
* {@link #CALL_ARGUMENTS} 的形状,与 A/B/C 同一个 handler 窗口)。
|
||||
* <ul>
|
||||
* <li>{@code dataReadScope.readScope(operator, companyId)} ⇒ 绿;</li>
|
||||
* <li>{@code resolveScope(request, companyId)}(私有收口方法内部再去 readScope)⇒ 绿;</li>
|
||||
* <li>{@code dataReadScope.readScope(operator, null)} ⇒ <b>红</b>;</li>
|
||||
* <li>{@code readScope(operator, operator.getCompanyId())} ⇒ <b>红</b>:源里那个名字是
|
||||
* {@code CompanyId}(大写 C,整词判据大小写敏感,咬不住它);而 {@link #CALL_ARGUMENTS}
|
||||
* 只吃单层括号,看不穿 {@code readScope(operator, normalize(companyId))} 这种嵌套写法 ——
|
||||
* 两种都落在"没进参数表"那一侧(后者是会误伤合规写法的已知形状,见类注释第 11 条与本轮报告);</li>
|
||||
* <li>只在 {@code if (companyId != null)} 里读一次、或只在 {@code @Operation} 文案里提一句
|
||||
* ⇒ <b>红</b>:控制语句关键字沿用 {@link #NOT_VALUE_CONSUMERS} 那把尺子(与 C 同源,不放宽),
|
||||
* 而注释与文档行根本进不到 {@link #text()} 里。</li>
|
||||
* </ul>
|
||||
* <p>返回 {@code null} = 公司参数确实交给了出口;否则返回红因片段,由调用方拼上 handler 名。
|
||||
*/
|
||||
String companyIdArgFailure() {
|
||||
String bound = boundCompanyParam();
|
||||
if (bound == null) {
|
||||
return " 认不出被绑定到 company_id 的变量名(断言 D 只认 @RequestParam(name = \"company_id\") … "
|
||||
+ "Long 变量名 那一形),这支的公司参数是怎么进出口的无从判定 —— 必须人工核对,"
|
||||
+ "不许当作\"这支没收公司参数\"静默放过";
|
||||
}
|
||||
Matcher call = CALL_ARGUMENTS.matcher(text());
|
||||
Pattern use = Pattern.compile("(?<!\\w)" + Pattern.quote(bound) + "(?!\\w)");
|
||||
while (call.find()) {
|
||||
String callee = call.group(1);
|
||||
// 与 C 同一条纪律:控制语句读它一次不算"把值交给谁";D 只认出口那两个被调名。
|
||||
if (NOT_VALUE_CONSUMERS.contains(callee) || !SCOPE_CALLEES.contains(callee)) {
|
||||
continue;
|
||||
}
|
||||
if (use.matcher(call.group(2)).find()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return " 的公司参数 `" + bound + "` 没进任何 readScope/resolveScope 的实参列表"
|
||||
+ "(`readScope(operator, null)`、`readScope(operator, operator.getCompanyId())` 就是这个形状:"
|
||||
+ "参数收下了、出口也调了、算出来的范围也交出去了,唯独 tab 传下来的那个值被换成了别的来源"
|
||||
+ " ⇒ 接口 200、页面正常、切 tab 数字永远不动,而 A/B/C 三条全绿没人喊)";
|
||||
}
|
||||
}
|
||||
|
||||
/** 源码行:{@code text} 已 trim(口径同仓内既有过滤器),{@code indent} 保留原始缩进(块边界靠它收口)。 */
|
||||
|
||||
+59
-9
@@ -3,6 +3,7 @@ package com.nanri.aiimage.modules.devicelog.service;
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.nanri.aiimage.common.exception.BusinessException;
|
||||
import com.nanri.aiimage.common.mapper.AdminUserMapper;
|
||||
@@ -253,9 +254,18 @@ class DeviceLogServiceTest {
|
||||
service().page(null, null, null, null, 1L, 20L, List.of(11L, 12L));
|
||||
|
||||
AbstractWrapper<?, ?, ?> q = capturedCount();
|
||||
assertThat(q.getSqlSegment())
|
||||
// 先求值一次 segment(paramNameValuePairs 惰性填,见上面那条订正),下面的结构判据都读这同一个串。
|
||||
String sql = q.getSqlSegment();
|
||||
assertThat(sql)
|
||||
.as("必须是 (source = ? OR uid IN (...)) 一整组,括号丢了就等于把麦象筛掉")
|
||||
.contains(" OR ").contains("IN (");
|
||||
.contains(" OR ").contains("IN (")
|
||||
// 评审 I-1:这一支没有外层 source 条件,公司腿是整个条件的头一段,
|
||||
// 分组成立时它外面套着**它自己**那对括号 ⇒ 实测原文以 "((source =" 开头;
|
||||
// 平铺写法只剩 MP 白送的那对外层括号(实测原文 `(source = #{..} OR uid IN (#{..},#{..}) AND …`),
|
||||
// 所以判据必须数到第二对括号——写 contains("(source =") 会被外层那对括号喂饱 = 恒真断言。
|
||||
.contains("((source =")
|
||||
// 组必须在 OR 之后才收口:一出现 ") OR " 就说明 OR 的左半边已经被括在组外(半开)。
|
||||
.doesNotContain(") OR ");
|
||||
// 值落在 paramNameValuePairs 里,不在 getSqlSegment() 里——别写成 segment.contains("maixiang"),
|
||||
// MP 渲染的是 #{ew.paramNameValuePairs.MPGENVAL1},那条断言恒假。
|
||||
assertThat(q.getParamNameValuePairs().values()).contains("maixiang", 11L, 12L);
|
||||
@@ -273,13 +283,30 @@ class DeviceLogServiceTest {
|
||||
// `() -> formatParam(null, val)` 塞进 ISqlSegment lambda,只有 segment 被求值过一次,
|
||||
// pairs 里才落值。先读 pairs 会拿到空 map(实跑红过一次),所以结构断言在前。
|
||||
String sql = q.getSqlSegment();
|
||||
// 评审 M-2①:反向钉的正样本必须住在同一支。这一支的 doesNotContain("IN (") 只说
|
||||
// 「这个 wrapper 没渲染出 IN (」,它成立的前提是「IN ( 这串本来就会被渲染出来」——
|
||||
// 那半句以前只由别支(maixiangRows/countAndList/companyFilterStacks/anonymous)证明。
|
||||
// 这里用同一把尺子就地自检一次:同一个实体、同一个列、成员集非空
|
||||
// ⇒ MP 实测渲染 `(uid IN (#{ew.paramNameValuePairs.MPGENVAL1}))`。
|
||||
LambdaQueryWrapper<DeviceLogFileEntity> probe = new LambdaQueryWrapper<>();
|
||||
probe.in(DeviceLogFileEntity::getUid, List.of(11L));
|
||||
assertThat(probe.getSqlSegment()).as("形状自检:成员集非空时 MP 确实渲染出 \"IN (\"").contains("IN (");
|
||||
// 只用 contains/doesNotContain:page 里还有 log_date >= ? 那条必带参数,
|
||||
// 写 containsExactly(...) 会因为多一个 LocalDate 而恒红。
|
||||
assertThat(sql).as("空集不许渲染出 IN (),MySQL 直接语法错").doesNotContain("IN (");
|
||||
assertThat(q.getParamNameValuePairs().values())
|
||||
.as("空集走 in() 会渲染出 IN (),MySQL 直接语法错;这里必须只看 maixiang")
|
||||
.contains("maixiang")
|
||||
.doesNotContain(11L);
|
||||
.contains("maixiang");
|
||||
// 评审 M-2②:原句 `.doesNotContain(11L)` 在「传入 List.of()」的用例里是恒真死断言
|
||||
// ——空集里根本没有 11L,任何实现(含把空集写成 in() 或哨兵 id 的)都不会红在它身上,
|
||||
// 留着只会让人以为这一支钉住了成员 id。删掉,换成两条同方向、可被杀死的判据:
|
||||
// ① 空集这一支只许从 source 收窄,不许对 uid 列叠任何条件(实测原文 `(source = #{..1} AND log_date >= #{..2})`,
|
||||
// 里面没有 "uid";改成 in()/eq(uid,-1) 立刻红);
|
||||
// ② pairs 里不许出现任何 Long —— 出现就说明有人把成员 id 或恒空哨兵 id 塞进了空集分支。
|
||||
assertThat(sql).as("空集那支不许改成对 uid 叠条件").doesNotContain("uid");
|
||||
assertThat(q.getParamNameValuePairs().values())
|
||||
.as("空集那支不许把成员 id / 恒不命中的哨兵 id 写进参数")
|
||||
.allSatisfy(v -> assertThat(v).isNotInstanceOf(Long.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -290,7 +317,13 @@ class DeviceLogServiceTest {
|
||||
service().page("client", 7L, null, null, 1L, 20L, null);
|
||||
|
||||
AbstractWrapper<?, ?, ?> q = capturedCount();
|
||||
assertThat(q.getSqlSegment()).doesNotContain(" OR ");
|
||||
// 评审 M-2①:同支形状自检——" OR " 这串本来就会被 MP 渲染出来(实测原文
|
||||
// `(source = #{..1} OR uid IN (#{..2}))`),下面那句 doesNotContain(" OR ") 才是
|
||||
// 「memberUids==null 一条公司条件都没叠」的证据,而不是「这一族形状根本渲染不出所以看不见」。
|
||||
LambdaQueryWrapper<DeviceLogFileEntity> probe = new LambdaQueryWrapper<>();
|
||||
probe.eq(DeviceLogFileEntity::getSource, "maixiang").or().in(DeviceLogFileEntity::getUid, List.of(11L, 12L));
|
||||
assertThat(probe.getSqlSegment()).as("形状自检:成员集非空时 MP 确实渲染出 \" OR \"").contains(" OR ");
|
||||
assertThat(q.getSqlSegment()).as("不筛=平铺的三条件里一个 OR 都没有").doesNotContain(" OR ");
|
||||
assertThat(q.getParamNameValuePairs().values()).doesNotContain("maixiang");
|
||||
assertThat(q.getParamNameValuePairs().values()).contains("client", 7L);
|
||||
}
|
||||
@@ -330,9 +363,18 @@ class DeviceLogServiceTest {
|
||||
service().page("client", null, null, null, 1L, 20L, List.of(11L, 12L));
|
||||
|
||||
AbstractWrapper<?, ?, ?> q = capturedCount();
|
||||
String sql = q.getSqlSegment();
|
||||
// 正向取样自检:外层 source 等值 + OR 分组 + 成员集 IN + 必带的 log_date 四条都在。
|
||||
assertThat(q.getSqlSegment())
|
||||
assertThat(sql)
|
||||
.contains("source =").contains(" OR ").contains("IN (").contains("log_date >=");
|
||||
// 评审 I-1:这一支是「外层条件 + OR 组并存」的那一支,公司腿必须被 and(w -> …) 整段括起来。
|
||||
// 分组实测原文:`(source = #{..1} AND (source = #{..2} OR (uid IN (#{..3},#{..4}))) AND log_date >= #{..5})`
|
||||
// 平铺实测原文:`(source = #{..1} AND source = #{..2} OR uid IN (#{..3},#{..4}) AND log_date >= #{..5} …)`
|
||||
// ⇒ 平铺既没有 "AND (" 也照样含 " OR "/"IN (",只有下面三条能把它判红(形状同 ShopManageGroupServiceTest:73-76)。
|
||||
assertThat(sql).as("公司腿必须由 AND 后开的一对括号整段包住").contains("AND (source =");
|
||||
assertThat(sql).as("组在 OR 之前不许收口,否则 OR 的左半边已经逃出公司筛选").doesNotContain(") OR ");
|
||||
assertThat(sql.indexOf("AND (")).as("分组括号必须开在 OR 之前,OR 才在那一组里面")
|
||||
.isLessThan(sql.indexOf(" OR "));
|
||||
// 嵌套 wrapper 若复用父级的 MPGENVAL 序号,'client' 会被 'maixiang' 就地覆盖 ⇒ 筛出来
|
||||
// 是「来源=maixiang」的行却写着 source=client,且不报错。四个值同时在 pairs 里才算各占各的键。
|
||||
assertThat(q.getParamNameValuePairs().values()).contains("client", "maixiang", 11L, 12L);
|
||||
@@ -356,18 +398,26 @@ class DeviceLogServiceTest {
|
||||
// 于是那 22 行「有客户端来源、却没有账号可归属」的行在任何一个公司 tab 下都不出现。
|
||||
// 取舍:另一条腿 (uid IS NULL) 会把它们塞进**每一家**的 tab——一家没归属的行不该在每家各冒充一份,
|
||||
// 那既是错的归属、也会让「这家有多少日志」这个数没法用;而 tab 只是超管的视图过滤器
|
||||
// (这页 9 个端点全在 requireSuperAdmin 之后),全量仍可由不带 company_id 的请求拿到
|
||||
// (readScope(operator, null) ⇒ unfiltered ⇒ memberUids=null ⇒ 一条条件都不叠)。
|
||||
// (这页 9 个端点全在 requireSuperAdmin 之后)。
|
||||
// 代价要说实话:只有**不带 company_id 的 API 调用**还能拿到全量
|
||||
// (readScope(operator, null) ⇒ unfiltered ⇒ memberUids=null ⇒ 一条条件都不叠);
|
||||
// tab 条按定案没有「全部公司」那一枚、activeId 必落在一启用公司上 ⇒ 这 22 行在界面上点不回来。
|
||||
// 完整定案与代价见 docs/plans/19-company-tab.md 附B(Task 12 评审 I-2/M-3,2026-10-05 记)。
|
||||
assertThat(q.getSqlSegment()).doesNotContain("IS NULL");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("按 fileId 的端点与 devices 刻意不收 company_id:这页无超管外调用方,收了只会误伤麦象日志")
|
||||
@DisplayName("按 fileId 的端点与 config/devices 刻意不收 company_id:这页无超管外调用方,收了只会误伤麦象日志")
|
||||
void singleFileEndpointsStayUnscoped() {
|
||||
String text = SourceScan.sourceText("AdminDeviceLogController.java");
|
||||
assertThat(SourceScan.methodBody(text, "content")).doesNotContain("dataReadScope");
|
||||
assertThat(SourceScan.methodBody(text, "download")).doesNotContain("dataReadScope");
|
||||
assertThat(SourceScan.methodBody(text, "delete")).doesNotContain("dataReadScope");
|
||||
// 评审 M-1:brief 数死过分母「这页一共 9 支端点」,GET /config 以前不在任何一支 doesNotContain
|
||||
// 的名字表里(隔壁用例只点名了 updateGlobal/updateDevice/deleteOverride/delete),
|
||||
// 于是"哪天有人给 config 挂上 dataReadScope/公司参数"没有用例响。补上它 ⇒ 5 支不接 + files 正样本
|
||||
// + 隔壁用例的 4 支写口 = 9/9,两支反向钉并起来才等于分母。
|
||||
assertThat(SourceScan.methodBody(text, "config")).doesNotContain("dataReadScope");
|
||||
assertThat(SourceScan.methodBody(text, "devices")).doesNotContain("dataReadScope");
|
||||
assertThat(SourceScan.methodBody(text, "files")).contains("dataReadScope"); // 取样非空自检
|
||||
}
|
||||
|
||||
+49
-11
@@ -25,20 +25,36 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Task 11 分组侧(计划 Step 1 点名的新建文件):{@code ShopManageGroupService.list} 叠公司条件时,
|
||||
* 既有那条 {@code created_by_id = ? OR user_id = ?} 必须整块留在括号里。
|
||||
* 既有那条 {@code created_by_id = ? OR user_id = ?} 必须整块留在它自己的括号组里。
|
||||
*
|
||||
* <p>这是本任务唯一一处「错了不报错、只是多放行」的形状:MP 的 normal 段按顺序拼 AND/OR,而 MySQL 里
|
||||
* AND 优先 ⇒ 平铺成 {@code created_by_id = ? OR user_id = ? AND created_by_id IN (...)} 时,第一个
|
||||
* {@code created_by_id = ?} 整块逃出公司筛选,别家的分组照样列出来,接口还是 200。</p>
|
||||
*
|
||||
* <p>断言口径与 {@code ShopManageServiceTest} 同一条:<b>结构</b>(括号、OR、IN)从
|
||||
* {@code getSqlSegment()} 读,<b>值</b>从 {@code getParamNameValuePairs()} 读——MP 在 segment 里只放
|
||||
* {@code #{ew.paramNameValuePairs.MPGENVALn}} 占位,写 {@code segment.contains("11")} 是恒假断言。
|
||||
* 反向钉(没给成员集不许叠条件)与它的正样本写在同一支用例里,两支护一支持平。</p>
|
||||
* <p><b>断言口径(修复轮 2 换掉的旧口径写在这里,免得下一个人又把它加回来)</b>:
|
||||
* 上一版这里用的是 {@code segment.contains("(created_by_id")}。它在「OR 组到底有没有被包住」这件事上
|
||||
* 是<b>恒真</b>的,两个来源都能白送它:①同一条串里公司那条腿自己的 {@code AND (created_by_id IN (};
|
||||
* ②MP 的 {@code NormalSegmentList.childrenSqlSegment()} 会把整个 normal 段用一对括号包起来
|
||||
* ({@code LEFT_BRACKET + str + RIGHT_BRACKET})——那对括号<b>不是</b> {@code and()} 给的,
|
||||
* 实测连平铺实现都会白送一个开头的 {@code (}。{@code lastIndexOf("AND (") > indexOf("created_by_id")}
|
||||
* 同理只量到「公司条件自成一组」,杀得住 M1(平铺会把 {@code AND (} 抹掉)纯属顺带命中。
|
||||
* ⇒ 结论:这类「串里某处出现过左括号」的判据一律不用,主锚改成<b>脱敏后整串逐字比对</b>,
|
||||
* 字面量来自实跑打出来的 {@code getSqlSegment()}(不是推理),见 {@link #OR_GROUP_MASKED}。
|
||||
* 值仍旧单独从 {@code getParamNameValuePairs()} 断(MP 在 segment 里只放
|
||||
* {@code #{ew.paramNameValuePairs.MPGENVALn}} 占位,写 {@code segment.contains("11")} 是恒假断言)。
|
||||
* 反向钉(不叠条件/不渲染 IN)与它的正样本写在同一支用例里,两支护一支持平。</p>
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class ShopManageGroupServiceTest {
|
||||
|
||||
/** 实跑(MP 3.5.7,TableInfo 手工初始化)打出来的 {@code list(5L, List.of(11L))} 脱敏整串:每个字符都取自媒体,不是推测。 */
|
||||
private static final String OR_GROUP_MASKED =
|
||||
"((created_by_id = ? OR (user_id = ?)) AND (created_by_id IN (?))) ORDER BY id ASC";
|
||||
|
||||
/** M2(I-1 点名的那个形状)实测渲染出来的样子:OR 的左半边逃出括号组。整串比对对它必红。 */
|
||||
private static final String FLAT_OR_MASKED =
|
||||
"(created_by_id = ? OR (user_id = ?) AND (created_by_id IN (?))) ORDER BY id ASC";
|
||||
|
||||
@Mock
|
||||
private ShopManageGroupMapper groupMapper;
|
||||
|
||||
@@ -61,6 +77,17 @@ class ShopManageGroupServiceTest {
|
||||
return (List) captor.getAllValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* 脱敏:占位符统一换成 {@code ?},好让「结构」能整串比对,而「值」仍单独从 pairs 断。
|
||||
* 换完必须一个占位符都不剩——留着就说明渲染格式变了(正则抓不到 ⇒ 整串比对会被原文糊弄),
|
||||
* 这里当场红,而不是留下一条谁也说不清的红。
|
||||
*/
|
||||
private static String masked(String segment) {
|
||||
String sql = segment.replaceAll("#\\{ew\\.paramNameValuePairs\\.MPGENVAL\\d+}", "?");
|
||||
assertThat(sql).as("脱敏必须把每个 MP 占位符都换成 ?").doesNotContain("MPGENVAL").doesNotContain("#{");
|
||||
return sql;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("分组:list 叠公司必须把既有那条平铺 OR 整个套进括号(否则 created_by_id=? 那半边逃出筛选)")
|
||||
void groupListWrapsTheOrBeforeNarrowing() {
|
||||
@@ -69,12 +96,23 @@ class ShopManageGroupServiceTest {
|
||||
groupService.list(5L, List.of(11L));
|
||||
|
||||
LambdaQueryWrapper<ShopManageGroupEntity> q = captureAll(1).get(0);
|
||||
String segment = q.getSqlSegment();
|
||||
assertThat(segment).as("OR 组必须被 and() 包住").contains("(created_by_id").contains(" OR ");
|
||||
assertThat(segment.lastIndexOf("AND ("))
|
||||
.as("公司条件必须自成一组,不能与 OR 平铺")
|
||||
.isGreaterThan(segment.indexOf("created_by_id"));
|
||||
assertThat(q.getParamNameValuePairs().values()).contains(11L);
|
||||
// 必须先求值 segment:paramNameValuePairs 是渲染时才填充的,顺序写反就是在断一个空 map(正反两断言双双恒真)。
|
||||
String sql = masked(q.getSqlSegment());
|
||||
|
||||
// 主锚:脱敏整串逐字比对。它同时钉住两条腿的分组形状——
|
||||
// M2(本用例为它而建):AND 之后紧跟 (created_by_id IN (
|
||||
// M1:OR 的右半边后必须还有第二个右括号,把 created_by_id = ? 关在组里。
|
||||
assertThat(sql).as("两条腿各自成组,实测整串逐字比对").isEqualTo(OR_GROUP_MASKED);
|
||||
// 平铺形状不许出现(同串的另一写法,失败信息比整串比对更直白)。
|
||||
assertThat(sql).as("M2 的平铺形状不得出现").doesNotContain(FLAT_OR_MASKED);
|
||||
|
||||
// 正样本配对:这一支确实把 OR 与公司 IN 都渲染出来了 ⇒ 本文件另两支的 doesNotContain 才有东西可反证。
|
||||
assertThat(sql).contains(" OR ").contains(" IN (");
|
||||
|
||||
assertThat(q.getParamNameValuePairs().values())
|
||||
.as("三个占位符 = created_by_id / user_id / 公司成员集各一个绑定")
|
||||
.hasSize(3)
|
||||
.contains(5L, 11L);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+38
@@ -86,6 +86,44 @@ class ShopManageServiceTest {
|
||||
assertThat(captor.getValue().getParamNameValuePairs().values()).contains(11L, 12L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读:非超管那条可见集 {@code created_by_id IN (...) OR group_id IN (...)} 必须整块裹在括号里。
|
||||
*
|
||||
* <p>与分组侧 M2 同形的另一处({@code ShopManageService.java:49-60}):MP 的 normal 段按顺序拼 AND/OR,
|
||||
* MySQL 里 AND 优先 ⇒ 一旦平铺,{@code created_by_id IN (我的)} 会整块逃出后面的公司筛选。
|
||||
* 上面那支 {@code superAdmin=true} 的用例进不了这个分支({@code if (!superAdmin)} 短路),
|
||||
* 实测把它平铺后本文件 8 例全绿(rc=0)——这一支就是补上那把尺子的。</p>
|
||||
*/
|
||||
@Test
|
||||
@DisplayName("读:非超管的可见集 OR 组必须自成一组(平铺后 created_by_id IN (我的) 逃出公司筛选,与分组侧同形)")
|
||||
void nonSuperAdminVisibleSetOrIsBracketedBeforeCompanyLeg() {
|
||||
when(shopManageMapper.selectCount(any())).thenReturn(0L);
|
||||
when(shopManageMapper.selectList(any())).thenReturn(List.of());
|
||||
// 单元素 Set:Set.of 两个元素时迭代顺序不保证稳定,整串比对会假红。
|
||||
when(shopManageGroupService.listAccessibleCreatorUserIds(2L, false)).thenReturn(Set.of(11L));
|
||||
when(shopManageGroupService.listAccessibleGroupIds(2L, false)).thenReturn(Set.of(5L));
|
||||
|
||||
service.page(1L, 15L, null, null, 2L, false, List.of(21L, 22L));
|
||||
|
||||
ArgumentCaptor<LambdaQueryWrapper<ShopManageEntity>> captor =
|
||||
ArgumentCaptor.forClass(LambdaQueryWrapper.class);
|
||||
verify(shopManageMapper).selectCount(captor.capture());
|
||||
LambdaQueryWrapper<ShopManageEntity> q = captor.getValue();
|
||||
// 先求值 segment(pairs 惰性填充),再把占位符脱敏成 ? 做整串逐字比对。
|
||||
// 串尾的 LIMIT 是实测形态:selectCount 捕到的就是同一个 wrapper 对象,page() 随后对它 last("LIMIT 0, 15")。
|
||||
String sql = q.getSqlSegment().replaceAll("#\\{ew\\.paramNameValuePairs\\.MPGENVAL\\d+}", "?");
|
||||
assertThat(sql).as("三条腿的分组形状,字面量取自实跑 getSqlSegment()")
|
||||
.isEqualTo("((created_by_id IN (?) OR group_id IN (?)) AND created_by_id IN (?,?))"
|
||||
+ " ORDER BY id DESC LIMIT 0, 15");
|
||||
// 正样本(上面那串真的渲染出了 OR 与两个 IN)配反向钉:平铺那形不许出现。
|
||||
assertThat(sql).doesNotContain("created_by_id IN (?) OR group_id IN (?) AND created_by_id IN");
|
||||
|
||||
assertThat(q.getParamNameValuePairs().values())
|
||||
.as("四个占位符 = 可见集的创建人/分组各一 + 公司成员集两个")
|
||||
.hasSize(4)
|
||||
.contains(11L, 5L, 21L, 22L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("读:超管选了一家没有成员的公司 ⇒ 走 id = -1 恒空,不许退化成不加条件")
|
||||
void superAdminPageWithEmptyMemberSetStaysEmpty() {
|
||||
|
||||
+103
@@ -4,6 +4,9 @@ import com.nanri.aiimage.common.exception.BusinessException;
|
||||
import com.nanri.aiimage.common.mapper.AdminUserMapper;
|
||||
import com.nanri.aiimage.common.mapper.ShopManageGroupMapper;
|
||||
import com.nanri.aiimage.common.model.entity.AdminUserEntity;
|
||||
import com.nanri.aiimage.common.security.DeviceSessionPolicy;
|
||||
import com.nanri.aiimage.common.service.CompanyScopeSupport;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
@@ -15,6 +18,7 @@ import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyList;
|
||||
@@ -25,12 +29,18 @@ import static org.mockito.Mockito.when;
|
||||
/**
|
||||
* 客户端任务管理的组范围裁剪:超管直通,管理员 = 本人 + 本组用户 + 自己管理的成员。
|
||||
* 口径与 DedupeTotalDataService.resolveAccessScope 一致。
|
||||
*
|
||||
* <p>公司 tab 的收窄走第二个入参 {@code companyUserIds}(controller 已经过 {@code DataReadScope}
|
||||
* 把成员集算好,见 {@code AdminTaskCenterController} 五个 handler),所以本类只喂 List、不 mock
|
||||
* {@code DataReadScope}:{@code null} = 不收窄,空集 = 「选了公司但这家一个账号都没有」,
|
||||
* 两者绝不许混为一谈(后者必须是恒不命中,不是全量)。</p>
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class TaskCenterScopeServiceTest {
|
||||
|
||||
@Mock private AdminUserMapper adminUserMapper;
|
||||
@Mock private ShopManageGroupMapper shopManageGroupMapper;
|
||||
@Mock private CompanyScopeSupport companyScopeSupport;
|
||||
@InjectMocks private TaskCenterScopeService service;
|
||||
|
||||
private AdminUserEntity user(Long id, String role) {
|
||||
@@ -120,4 +130,97 @@ class TaskCenterScopeServiceTest {
|
||||
assertThrows(BusinessException.class, () -> service.resolve(404L));
|
||||
assertThrows(BusinessException.class, () -> service.resolve(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("超管选了公司:allUsers 必须翻成 false,否则集合根本不进 SQL,tab 是装饰品")
|
||||
void superAdminWithCompanyStopsBeingUnfiltered() {
|
||||
when(adminUserMapper.selectById(1L)).thenReturn(user(1L, "super_admin"));
|
||||
|
||||
TaskCenterScopeService.ScopeContext scope = service.resolve(1L, List.of(11L, 12L));
|
||||
|
||||
assertFalse(scope.allUsers(), "选了公司还 allUsers=true ⇒ sqlUserIds() 交 null ⇒ SQL 整段条件不渲染");
|
||||
assertEquals(Set.of(11L, 12L), Set.copyOf(scope.sqlUserIds()));
|
||||
assertTrue(scope.visible(11L));
|
||||
assertFalse(scope.visible(13L), "别家账号连 tasks/detail 也进不去(详情走 scope.visible,不走 SQL)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("第二参 null(非超管 / 超管没选公司):今天的行为一分不变")
|
||||
void nullCompanyUserIdsKeepsTodayBehavior() {
|
||||
when(adminUserMapper.selectById(1L)).thenReturn(user(1L, "super_admin"));
|
||||
|
||||
TaskCenterScopeService.ScopeContext scope = service.resolve(1L, null);
|
||||
|
||||
assertTrue(scope.allUsers(), "没选公司的超管仍然直通");
|
||||
assertNull(scope.sqlUserIds(), "allUsers=true 时交给 SQL 的是 null = 整段 user_id 条件不加");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("历史超管(role 为空 + isAdmin=1 + createdById 为空)选了公司,也得跟着窄")
|
||||
void legacySuperAdminIsNotLeftUnfiltered() {
|
||||
AdminUserEntity legacy = new AdminUserEntity();
|
||||
legacy.setId(2L);
|
||||
legacy.setIsAdmin(1);
|
||||
legacy.setCreatedById(null);
|
||||
when(adminUserMapper.selectById(2L)).thenReturn(legacy);
|
||||
|
||||
// 两把尺子同框(2026-10-05 复评 I-3):这一支原本只喂 service 那一侧(TaskCenterScopeService.isSuperAdmin),
|
||||
// 而 controller 那侧认历史超管走的是 AdminAuthSupport.currentRole → DeviceSessionPolicy.resolveRole
|
||||
// (「role 为空 + isAdmin=1 + createdById 为空 ⇒ super_admin」那条推断)——单边改掉 resolveRole 时
|
||||
// 本用例一行都不碰,五个 handler 的 superAdmin 却已经恒 false(公司 tab 对他失效)。
|
||||
// 现在把**同一份 fixture** 直接喂给 resolveRole,改任何一侧都红在这一支(既有的全局钉子
|
||||
// AdminAuthSupportTest:45 / DeviceSessionPolicyTest:40 继续钉 resolveRole 本体,不是被这里替掉)。
|
||||
assertEquals("super_admin",
|
||||
DeviceSessionPolicy.resolveRole(legacy.getRole(), legacy.getIsAdmin(), legacy.getCreatedById()),
|
||||
"controller 那侧的历史超管推断(role 空 + isAdmin=1 + createdById 空)不许单边改:"
|
||||
+ "它一改,五个 handler 就不再给这个账号算公司成员集,本用例的 service 断言抓不到那一侧");
|
||||
|
||||
TaskCenterScopeService.ScopeContext scope = service.resolve(2L, List.of(31L));
|
||||
|
||||
assertFalse(scope.allUsers(), "controller 那侧认这把的是 AdminAuthSupport.currentRole→resolveRole,"
|
||||
+ "与本类的 isSuperAdmin 必须同一条:哪一天单边改了,红的是这条而不是某个历史超管看见全量");
|
||||
assertEquals(Set.of(31L), scope.visibleUserIds());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("成员集为空时交给 SQL 的是 [-1] 不是空集:IN () 是语法错,兜底在 ScopeContext 里")
|
||||
void emptyMemberSetFallsBackToSentinelNotEmptyList() {
|
||||
when(adminUserMapper.selectById(1L)).thenReturn(user(1L, "super_admin"));
|
||||
|
||||
TaskCenterScopeService.ScopeContext scope = service.resolve(1L, List.of());
|
||||
|
||||
assertTrue(scope.visibleUserIds().isEmpty());
|
||||
assertEquals(List.of(-1L), scope.sqlUserIds(), "本任务不许改 :100 那条兜底");
|
||||
assertFalse(scope.visible(11L), "空公司连详情也不能看见任何人");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("非超管的既有分组集:公司集只与之求交,一律不放大")
|
||||
void adminIntersectsWithGroupScope() {
|
||||
when(adminUserMapper.selectById(5L)).thenReturn(user(5L, "admin"));
|
||||
when(shopManageGroupMapper.selectAccessibleGroupIds(5L)).thenReturn(List.of(3L));
|
||||
when(shopManageGroupMapper.selectUserIdsByGroupIds(List.of(3L))).thenReturn(List.of(6L));
|
||||
when(shopManageGroupMapper.selectManagedMemberUserIds(5L)).thenReturn(List.of());
|
||||
|
||||
// 分组集 = 本人 5 + 组员 6(:42-48 的既有口径),公司集 = 6、7 ⇒ 只剩 6
|
||||
TaskCenterScopeService.ScopeContext scope = service.resolve(5L, List.of(6L, 7L));
|
||||
|
||||
assertFalse(scope.allUsers());
|
||||
assertEquals(Set.of(6L), scope.visibleUserIds(), "公司集里的 7 不在本组可见集内,不许被放大进来");
|
||||
assertFalse(scope.visible(5L), "连本人都被公司维度筛掉时就是筛掉,不保留全部");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("第三条腿(公司超管按会话定本公司成员)逐字留在 resolveBase:没选公司时一分不变")
|
||||
void companySuperAdminLegStillDecidedBySession() {
|
||||
AdminUserEntity operator = user(9L, "company_super_admin");
|
||||
operator.setCompanyId(7L);
|
||||
when(adminUserMapper.selectById(9L)).thenReturn(operator);
|
||||
when(companyScopeSupport.memberUserIds(7L)).thenReturn(List.of(41L, 42L));
|
||||
|
||||
TaskCenterScopeService.ScopeContext scope = service.resolve(9L, null);
|
||||
|
||||
assertFalse(scope.allUsers(), "公司超管不是超管,不能直通");
|
||||
assertEquals(Set.of(9L, 41L, 42L), scope.visibleUserIds(), "本人 + 本公司成员(既有口径)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2195,6 +2195,13 @@ public final class SourceScan {
|
||||
// 值在 paramNameValuePairs 里,segment 里只有 MPGENVAL 占位 ⇒ 结构从 segment 读、值从 pairs 读。
|
||||
assertThat(captor.getValue().getSqlSegment()).contains("created_by_id").contains("IN (");
|
||||
assertThat(captor.getValue().getParamNameValuePairs().values()).contains(11L, 12L);
|
||||
// ⚠️ 执行期补(Task 11 修复轮 2,评审 F5):**超管**分支这两句不是恒真(那串里两个 contains 只可能来自公司腿),
|
||||
// 但**非超管**那块 `query.and(wrapper -> created_by_id IN (…) OR group_id IN (…))` 本 Step 没给用例 ⇒
|
||||
// 平铺它实测 `8 例全绿、rc=0`(同样是"错了不报错、只多放行")。已另写一支
|
||||
// nonSuperAdminVisibleSetOrIsBracketedBeforeCompanyLeg 用同一把尺子(脱敏整串逐字比对)钉住,实测串:
|
||||
// ((created_by_id IN (?) OR group_id IN (?)) AND created_by_id IN (?,?)) ORDER BY id DESC LIMIT 0, 15
|
||||
// (注意公司腿这一形是**平铺**的 `AND created_by_id IN (?,?)`、外面只有一层白送括号——与上面分组侧那形不同,
|
||||
// 别照抄串;一切以实跑打印为准。)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -2208,11 +2215,19 @@ public final class SourceScan {
|
||||
ArgumentCaptor.forClass(LambdaQueryWrapper.class);
|
||||
verify(groupMapper).selectList(captor.capture());
|
||||
String segment = captor.getValue().getSqlSegment();
|
||||
// 断"OR 被包在 and( ... ) 里"的形状:OR 之前必须出现一个 '(',且整段以 AND (…IN…) 收尾。
|
||||
assertThat(segment).contains("(created_by_id").contains(" OR ");
|
||||
assertThat(segment.lastIndexOf("AND ("))
|
||||
.as("公司条件必须自成一组,不能与 OR 平铺")
|
||||
.isGreaterThan(segment.indexOf("created_by_id"));
|
||||
// 断"OR 被包在 and( ... ) 里"的形状。⚠️ 执行期订正(Task 11 修复轮 2,评审 I-1/F1–F3):
|
||||
// 原写法 contains("(created_by_id") + lastIndexOf("AND (") > indexOf("created_by_id") **两句都恒真**——
|
||||
// "(created_by_id" 有两个白送来源:①公司腿自己的 `AND (created_by_id IN (`;②MP 的
|
||||
// NormalSegmentList.childrenSqlSegment() 无条件给整段 normal 套一对最外层括号
|
||||
// (LEFT_BRACKET + str + RIGHT_BRACKET),实测连平铺实现也含开头的 "(";而 lastIndexOf("AND (")
|
||||
// 只量到"公司条件自成一组",杀平铺纯属顺带命中。⇒ 把 :57 那条 OR 改回平铺,全仓 16 例照绿。
|
||||
// 主锚改成**脱敏后整串逐字比对**,字面量来自实跑打印的 getSqlSegment()(不是推理):
|
||||
String masked = segment.replaceAll("#\\{ew\\.paramNameValuePairs\\.MPGENVAL\\d+}", "?");
|
||||
assertThat(masked).isEqualTo(
|
||||
"((created_by_id = ? OR (user_id = ?)) AND (created_by_id IN (?))) ORDER BY id ASC");
|
||||
// 分组括号与"白送括号"的差就是那**第二对**——正确实现两对、平铺一对,整串恰好量这一维。
|
||||
// 代价(明写):绑死 MP 3.5.7 的渲染形态与占位符个数 ⇒ 升级 MP 或改分页会**假红**(不是假绿),
|
||||
// 处置是重跑探针重取串,不许手改字面量。值仍旧单独从 getParamNameValuePairs() 断。
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -2454,9 +2469,21 @@ SELECT source, COUNT(*) FROM device_log_file GROUP BY source;
|
||||
service().page(null, null, null, null, 1L, 20L, List.of(11L, 12L));
|
||||
|
||||
AbstractWrapper<?, ?, ?> q = capturedCount();
|
||||
assertThat(q.getSqlSegment())
|
||||
String seg = q.getSqlSegment();
|
||||
assertThat(seg)
|
||||
.as("必须是 (source = ? OR uid IN (...)) 一整组,括号丢了就等于把麦象筛掉")
|
||||
.contains(" OR ").contains("IN (");
|
||||
.contains(" OR ").contains("IN (")
|
||||
// ⚠️ 执行期订正(Task 12 修复轮 1,评审 I-1):上面那两句**平铺实现照样全满足** ⇒ 那句 .as 声称的
|
||||
// 检查并没有被执行。但"补 contains(\"(source =\")"也不行——MP 3.5.7 给整段 WHERE 白送一对最外层括号,
|
||||
// 平铺实测原文是 `(source = ? OR uid IN (?,?) AND log_date >= ?)`,那句恒真。
|
||||
// 判据必须**数到第二对括号**,并排掉"半开"那形(`.and(w->eq).or(o->in)` 照样含 `AND (source =`,
|
||||
// 但 OR 已在组外):
|
||||
.contains("((source =") // 分组实测原文以两对括号开头(REAL-1)
|
||||
.doesNotContain(") OR "); // 一出现 ") OR " 就说明 OR 的左半边被括在组外
|
||||
// 实跑原文(脱敏后):((source = ? OR (uid IN (?,?))) AND log_date >= ?)
|
||||
// 「外层条件 + OR 组并存」那一支(companyFilterStacks…)换一组锚:contains("AND (source =")
|
||||
// + doesNotContain(") OR ") + indexOf("AND (") < indexOf(" OR ")(原文 REAL-2:
|
||||
// (source = ? AND (source = ? OR (uid IN (?,?))) AND log_date >= ?))。
|
||||
// 值落在 paramNameValuePairs 里,不在 getSqlSegment() 里——别写成 segment.contains("maixiang"),
|
||||
// MP 渲染的是 #{ew.paramNameValuePairs.MPGENVAL1},那条断言恒假。
|
||||
assertThat(q.getParamNameValuePairs().values()).contains("maixiang", 11L, 12L);
|
||||
@@ -2510,11 +2537,12 @@ SELECT source, COUNT(*) FROM device_log_file GROUP BY source;
|
||||
}
|
||||
```
|
||||
|
||||
**读法三条,都是这组用例能不能咬住实现的关键:**
|
||||
**读法四条,都是这组用例能不能咬住实现的关键:**
|
||||
|
||||
1. `selectCount` **一定**被打到,`selectList` 只在 `total != 0` 时才打(`DeviceLogService.java:189-193` 的三元)。所以凡是"看生成的条件"的用例,要么把 `selectCount` 桩成 `1L` 再捕两支,要么直接捕 `selectCount` 那支——别写一个"selectCount 桩 0 然后断言 selectList 的 wrapper"的用例,它捕到的是 null,红在断言之前。
|
||||
2. MP 把值放进 `paramNameValuePairs`,`getSqlSegment()` 里只有 `#{ew.paramNameValuePairs.MPGENVAL1}` 这种占位。⇒ **结构**(括号、`OR`、`IN`)从 segment 读,**值**(`"maixiang"`、`11L`)从 `getParamNameValuePairs().values()` 读。写成 `segment.contains("maixiang")` 是恒假断言(memory「字符串断言必须排他、解析断言必须可匹配」)。**同一条还有后半截:`paramNameValuePairs` 是惰性填的**——MP 3.5.7 把值装进 `() -> formatParam(null, val)` 这样的 lambda,只有 `getSqlSegment()` 被求值过一次,pairs 里才落值。所以凡断 pairs 的用例必须**先取一次 segment** 再读 pairs;反过来写(Task 12 实跑撞过)会拿到 `[]`,于是 `doesNotContain(...)` 恒真、`两支的 pairs 相等` 变成「两个空 map 相等」也恒真——尺子绿着,什么都没钉住。
|
||||
3. `capturedCount()` / `capturedList()` 各用一个 `ArgumentCaptor<Wrapper<DeviceLogFileEntity>>` 捕(本文件已 import `ArgumentCaptor` 与 `AbstractWrapper`),捕获后 `(AbstractWrapper<?, ?, ?>)` 转型取 `getSqlSegment()`。`row(1024L, 2)` 用文件里已有的助手即可——这几条测的是**生成的 SQL 形状**,不是返回内容,所以不需要给行设 `source`/`uid`。
|
||||
4. **`contains("(列名")` 这一族判据一律不能用**(Task 11 修复轮 2 + Task 12 修复轮 1 各撞一次,两轮实测):MP 3.5.7 的 `NormalSegmentList.childrenSqlSegment()` 是 `join(" ")` 外面**无条件**套 `(` + `)`——整段 WHERE 白送一对最外层括号,**平铺实现照样含开头的 `(`**。于是 `contains("(created_by_id")`、`contains("(source =")` 在它声称要防的形状上恒真;`lastIndexOf("AND (") > indexOf(列名)` 只量到"公司条件自成一组",杀平铺属顺带命中。⇒ 两条出路:①数到**第二对**括号(`contains("((source =")` / `contains("AND (source =")`)并叠 `doesNotContain(") OR ")` 排掉"半开"那形(`.and(w->eq).or(o->in)` 照样含 `AND (source =`,但 OR 已在组外);②**脱敏后整串逐字比对**——`segment.replaceAll("#\\{ew\\.paramNameValuePairs\\.MPGENVAL\\d+}", "?")` 再 `isEqualTo(实测串)`,字面量**只能来自实跑打印**(不许推理),且脱敏函数自带"占位符一个不剩"的自检(`doesNotContain("MPGENVAL").doesNotContain("#{")`),否则脱敏漏一种形状会退化成"整串恒不匹配"的糊涂红。②的代价要明写:绑死 MP 渲染形态与占位符个数 ⇒ 升级 MP/改分页算术时**假红(不是假绿)**,届时重跑探针重新取串,不许手改字面量。这一族的失败模式是"错了不报错、只多放行",所以宁可选会假红的尺子。
|
||||
|
||||
- [ ] **Step 2: 跑,确认红**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user