feat(公司tab): 批次 2/3/4 再接 8 页,注册表收到 16 页——用户页回流 company_id 按新边界改写反向钉
「切 tab 数据还一样」的根因一直是分母小于现实:批次 1 只登记 8 页,本轮按控制方 三次点名扩到 16 页(company-scope.ts 是唯一清单,routes.ts 的 companyScoped 逐页对平)。 批次 2(五页 ASIN 中心):去重总数据 / 不符合ASIN / 查询ASIN / 最低价ASIN / 商品类目。 批次 3(两页店铺中心):撞款监控、店铺数据记录。这两页没有归属列可筛,归属口径是 「本公司账号名下的店铺」——后端由 DataReadScope 推公司 → 成员账号 → biz_shop_manage. created_by_id,前端只把 activeId 当 company_id 送下去。空成员集必须交空集合,绝不能 退化成 null(null 在这里=全量,那样第二家会看到全部数据)。 批次 4(用户管理):后端早就认 company_id(只对站点超管生效,公司超管恒锁本公司), 断的是前端——UserListQuery 里连这个字段都没有,三家 tab 看的是同一份全量列表。 三处口径改动,逐条说明: 1)company-user-list.test.ts 的反向钉被改写。2026-10-04 定案把公司维度从用户页整体摘掉, 那条钉的原文是「列表查询/筛选/行渲染不允许出现公司维度」。控制方 2026-10-05 明确要 用户管理区分公司 tab,所以钉的边界收窄成两半:渲染层(行级公司列、「所属公司」标签、 筛选状态、顶栏公司名)仍不得回流;请求层的 company_id 是这次加回来的,尺子换成 「取值口唯一」——页面每处 companyId 都必须等于 companyTab.requestCompanyId,且 normalizeUserPageParams/toUserListQuery 两只白名单构造器体内不许出现公司值。 新增一支行为钉:往归一化里传 companyId 必须被丢掉,这是 users.ts 读原始入参的全部理由 (写成 normalized.companyId 时 TS 照样绿、运行时恒 undefined)。 2)align-dup-console 那条 watch 看守的 token 扩到含 reload。变异自证里「删掉 void loadConsole()」当场全绿:体里的清筛选项守住了,重新取数那半没人守。批次 3/4 三对 token 一起写到 reload 为止(批次 1/2 的老条目不动)。 3)公司管理页补正/反向两把尺子:company-config-entry-super-only 新增「吃公司 tab 的页面 集合恰好等于 COMPANY_SCOPED_PAGES 的 pageFiles」——按代码真值比,不按清单比,所以 清单不改一字而往 CompaniesPage.vue 里塞 store 也会红。谓词带括号,否则 import 行也算消费者。 菜单权限(admin_columns)本轮不动:MenusPage 只消费 /api/admin/permission-menus 这一份全局 菜单字典,切 tab 一样是数据本身全局,不是筛选坏了。真问题在写侧——PermissionMenuService create/update/delete 只有 ensureAdminOperatorIfPresent(isAdmin 即放行),公司管理员改的是 全平台的菜单行。收窄为仅站点超管 vs 给 permission_menu 加归属列,两种改法代价差一个量级, 留给控制方定档。 护栏:G1 发送口 22 个 / 页面分组 17、watch 体看守 10 对、operation-guide 的 tab 文案 15 页 (撞款监控是显式豁免,另有一条自检盯「豁免落空」)。 变异自证 12/12 全杀(前端 10 + 公司管理反向钉 2),分母钉死在 27 例。 门禁:后端全量 3823 例 / 0 失败 / 0 错误 / 7 skipped,BUILD SUCCESS;admin-frontend-vue 1741 例 / 0 红;vue-tsc rc=0。首轮后端 4 红是另一路 task_partial 改动与本轮编译抢跑, 单跑 13 例已绿,本笔不含他们的任何文件。 未上线:jar 与 admin-vue 都没出包,V147 未在生产执行。
This commit is contained in:
@@ -49,6 +49,26 @@ public class CompanyScopeSupport {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台自动写入路径(货源 chunk 回传、品牌补测调度器)专用的宽容版:账号已经不存在时返回 null,
|
||||
* 而不是像 {@link #requireCompanyId(Long)} 那样抛。
|
||||
*
|
||||
* <p>这两个入口的锚点是 {@code biz_file_task.user_id},而账号是**物理删**的:2026-10-05 生产只读
|
||||
* 取证,2026-06 以来的 716 条任务里 108 条的 user_id 在 users 里查不到(货源 174 条里 2 条)。
|
||||
* 在这里抛等于让整单采集提交失败——比归属失真更糟。调用方拿到 null 必须记一条可巡检的日志、
|
||||
* 并放弃这批写入,不许把 null 传进实体让 DEFAULT 1 静默兜住。</p>
|
||||
*/
|
||||
public Long companyIdOrNull(Long userId) {
|
||||
if (userId == null || userId <= 0) {
|
||||
return null;
|
||||
}
|
||||
AdminUserEntity user = adminUserMapper.selectById(userId);
|
||||
if (user == null || user.getCompanyId() == null || user.getCompanyId() <= 0) {
|
||||
return null;
|
||||
}
|
||||
return user.getCompanyId();
|
||||
}
|
||||
|
||||
/** 行级归属闸门:跨公司写/删的第一道,消息由调用方给(前端按它显示,别在这里编文案)。 */
|
||||
public void assertSameCompany(Long operatorCompanyId, Long rowCompanyId, String deniedMessage) {
|
||||
if (rowCompanyId == null || !rowCompanyId.equals(operatorCompanyId)) {
|
||||
|
||||
@@ -39,4 +39,26 @@ public class DataReadScope {
|
||||
List<Long> base = userDataScopeSupport.resolveVisibleUserIds(operator.getId());
|
||||
return ReadScope.users(ReadScope.users(companyScope.memberUserIds(own)).userIdsOr(base));
|
||||
}
|
||||
|
||||
/**
|
||||
* 归属已经**物化成 company_id 列**的表(品牌库 biz_invalid_asin_data)用的谓词出口:
|
||||
* 返回要筛的公司 id,null = 不筛。
|
||||
*
|
||||
* <p>这些表不能走 {@link #readScope} 的账号集合:2026-10-05 生产只读取证,品牌库 14,801 行里
|
||||
* {@code uploader_user_id} 非空的有 <b>0</b> 行(实体没这字段、批量 INSERT 的列清单也没带,
|
||||
* V145 补的列一直是空的),按账号筛等于把全部历史从每一个公司 tab 里静默删掉。
|
||||
* 而 {@code company_id} 那一列虽然是被 DEFAULT 1 盖上去的,对历史却是诚实的:
|
||||
* 第 2 家公司 10-04 14:55 才开通,它名下账号历史任务 0 条、去重库上传 0 行,
|
||||
* 所以「建号之前存在的行都归第 1 家」是可证的事实,不是猜。</p>
|
||||
*
|
||||
* <p>非超管返回 null(不筛):他们的可见集本来就锁在自己的分组上,叠一层公司会把
|
||||
* 「靠分组可见」的行整批删掉(同 {@code ShopManageController} 的口径)。
|
||||
* 超管的 company_id 是视图开关不是安全边界(spec §4),所以这里不需要再校验它属于谁。</p>
|
||||
*/
|
||||
public Long readCompanyId(AdminUserEntity operator, Long requestedCompanyId) {
|
||||
if (!SUPER_ADMIN.equals(adminAuthSupport.currentRole(operator))) {
|
||||
return null;
|
||||
}
|
||||
return requestedCompanyId != null && requestedCompanyId > 0 ? requestedCompanyId : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,12 +44,38 @@ public final class ExcelStreamReader {
|
||||
} else {
|
||||
EasyExcel.read(inputStream, listener).sheet(0).headRowNumber(1).doRead();
|
||||
}
|
||||
} catch (WrappedRuntimeException ex) {
|
||||
if (ex.getCause() instanceof IOException ioException) {
|
||||
} catch (RuntimeException ex) {
|
||||
// EasyExcel/POI 的解析异常是 RuntimeException,原样冒到接口层会变成 HTTP 500;
|
||||
// 本工具的契约是 IOException,调用方已按 IOException 给用户回 400。
|
||||
throw toContractException(listener.handlerFailure(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static IOException toContractException(Exception handlerFailure, RuntimeException readFailure) throws IOException {
|
||||
if (handlerFailure != null) {
|
||||
// 调用方自己抛的不算"文件坏了":运行时异常原样透传,保住 BusinessException 的 400 语义。
|
||||
if (handlerFailure instanceof IOException ioException) {
|
||||
throw ioException;
|
||||
}
|
||||
throw ex;
|
||||
if (handlerFailure instanceof RuntimeException runtimeException) {
|
||||
throw runtimeException;
|
||||
}
|
||||
throw new IOException("Excel 行处理失败:" + describe(handlerFailure), handlerFailure);
|
||||
}
|
||||
throw new IOException("Excel 解析失败:" + describe(readFailure), readFailure);
|
||||
}
|
||||
|
||||
private static String describe(Throwable ex) {
|
||||
Throwable deepest = ex;
|
||||
String message = ex.getMessage();
|
||||
while (deepest.getCause() != null) {
|
||||
deepest = deepest.getCause();
|
||||
String current = deepest.getMessage();
|
||||
if (current != null && !current.isBlank()) {
|
||||
message = current;
|
||||
}
|
||||
}
|
||||
return message == null || message.isBlank() ? ex.getClass().getSimpleName() : message;
|
||||
}
|
||||
|
||||
public interface SheetRowHandler {
|
||||
@@ -70,11 +96,27 @@ public final class ExcelStreamReader {
|
||||
|
||||
private final SheetRowHandler handler;
|
||||
private Map<Integer, String> currentHeaderMap = Map.of();
|
||||
private Exception handlerFailure;
|
||||
|
||||
private StreamingListener(SheetRowHandler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
private Exception handlerFailure() {
|
||||
return handlerFailure;
|
||||
}
|
||||
|
||||
/** 记下调用方抛出的异常,好让 runRead 分得清「文件解析坏了」和「行处理被调用方拒了」。 */
|
||||
private RuntimeException recordHandlerFailure(Exception ex) {
|
||||
if (handlerFailure == null) {
|
||||
handlerFailure = ex;
|
||||
}
|
||||
if (ex instanceof RuntimeException runtimeException) {
|
||||
return runtimeException;
|
||||
}
|
||||
return new WrappedRuntimeException(ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
|
||||
Map<Integer, String> normalizedHeadMap = new LinkedHashMap<>();
|
||||
@@ -85,10 +127,8 @@ public final class ExcelStreamReader {
|
||||
try {
|
||||
handler.onHeader(sheetName(context), sheetNo(context), currentHeaderMap);
|
||||
handler.onSheetTotal(sheetName(context), sheetNo(context), approximateTotalRows(context));
|
||||
} catch (RuntimeException ex) {
|
||||
throw ex;
|
||||
} catch (Exception ex) {
|
||||
throw new WrappedRuntimeException(ex);
|
||||
throw recordHandlerFailure(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,10 +146,8 @@ public final class ExcelStreamReader {
|
||||
currentHeaderMap,
|
||||
normalizedRow
|
||||
);
|
||||
} catch (RuntimeException ex) {
|
||||
throw ex;
|
||||
} catch (Exception ex) {
|
||||
throw new WrappedRuntimeException(ex);
|
||||
throw recordHandlerFailure(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user