feat(appearance-patent): 外观专利数据库主管列+导出+分组筛选——后管只读页补「所属主管」读侧现算列(owner 是主管取自己、普通账户取创建人,铁律 30 读不到不猜名)、GET /export 与分页共用同一过滤面与正门出 xlsx(SXSSF,上限 5 万行超限拒)、分组筛选 group_id 按 selectUserIdsByGroupId 解析「组长本人+名下子账户」整集 SQL 下推(铁律 20,选项复用既有 GET /shop-manages/groups 不下新端点);前端加主管列/分组下拉/导出按钮(blob 落盘+业务错误信封解包),wiring 护栏补导出发送口钉与 watch token(25 处发送口);棘轮 1073→1074 一枚记名,「无侵权」白名单登记导出上限文案
This commit is contained in:
+51
-4
@@ -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.common.support.DownloadHeaderUtil;
|
||||
import com.nanri.aiimage.modules.appearancepatent.model.vo.AppearancePatentCleanItemPageVo;
|
||||
import com.nanri.aiimage.modules.appearancepatent.service.AppearancePatentCleanItemQueryService;
|
||||
import com.nanri.aiimage.modules.permission.service.PermissionMenuService;
|
||||
@@ -19,17 +20,26 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* 后管「外观专利无侵权数据」只读页(v1.3 R2/R3)。数据由出表成功点自动同步落表
|
||||
* ({@code AppearancePatentCleanSyncService}),本页只读——无写/删/导出接口,
|
||||
* 下载走既有结果直链/任务中心。
|
||||
* ({@code AppearancePatentCleanSyncService}),本页只读——无写/删接口,下载走既有结果直链/
|
||||
* 任务中心;另有 GET 导出端点(2026-11-11 客户需求「数据得导出来」):与分页查询同一过滤面
|
||||
* (含公司隔离正门),服务侧卡导出上限,主管列为读侧现算列,无写/删/导入;分组筛选同日落地
|
||||
* (客户口径「主管就是组长,可以筛选组长来导出,就是分组」)——group_id 参数(biz_shop_manage_group.id)
|
||||
* 在分页与导出同面生效,服务侧按 selectUserIdsByGroupId 解析「组长本人+名下子账户」整集后
|
||||
* SQL 侧下推;下拉选项复用既有 GET /shop-manages/groups(与去重页/店铺管理同源),不下新端点。
|
||||
*
|
||||
* <p>鉴权照去重页私有 {@code requireXxxAccess} 形状:JWT → 内部令牌回退 → 超管放行 →
|
||||
* 非超管菜单权限(column_key/route_path 双匹配)。菜单行由 V190 只插 columns 不预授权
|
||||
@@ -38,11 +48,14 @@ import java.time.LocalDate;
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/admin/appearance-patent-clean-items")
|
||||
@Tag(name = "外观专利无侵权数据", description = "后管只读页:出表成功自动同步的「结论=无侵权」明细,按分公司隔离分页查询。")
|
||||
@Tag(name = "外观专利无侵权数据", description = "后管只读页:出表成功自动同步的「结论=无侵权」明细,按分公司隔离分页查询与导出。")
|
||||
public class AdminAppearancePatentCleanItemsController {
|
||||
|
||||
private static final String CLEAN_ITEMS_COLUMN_KEY = "admin_appearance_patent_clean_items";
|
||||
private static final String CLEAN_ITEMS_ROUTE_PATH = "patent-center/clean-items";
|
||||
private static final String XLSX_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
/** 导出文件名时间戳(同 QueryAsinController 口径),中文文件名的 ASCII 回退由 DownloadHeaderUtil 兜底。 */
|
||||
private static final DateTimeFormatter EXPORT_FILENAME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmm");
|
||||
|
||||
private final AppearancePatentCleanItemQueryService cleanItemQueryService;
|
||||
private final AdminAuthSupport adminAuthSupport;
|
||||
@@ -65,6 +78,8 @@ public class AdminAppearancePatentCleanItemsController {
|
||||
@RequestParam(name = "start_date", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
||||
@Parameter(description = "同步结束日期(包含)")
|
||||
@RequestParam(name = "end_date", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate,
|
||||
@Parameter(description = "分组 id:按该分组「组长本人+名下子账户」的用户集过滤(主管=组长)")
|
||||
@RequestParam(name = "group_id", required = false) Long groupId,
|
||||
@Parameter(description = "公司 ID") @RequestParam(name = "company_id", required = false) Long companyId,
|
||||
HttpServletRequest request) {
|
||||
RequestOperator operator = requireCleanItemsAccess(request);
|
||||
@@ -75,7 +90,39 @@ public class AdminAppearancePatentCleanItemsController {
|
||||
// 等于把整张表交给每一家(该方法 javadoc 点名的越权形状),不是本表该走的门。
|
||||
Long scopedCompanyId = dataReadScope.readCompanyIdOrOwn(user, companyId);
|
||||
return ApiResponse.success(cleanItemQueryService.page(page, pageSize, taskId, asin, country,
|
||||
startDate, endDate, scopedCompanyId));
|
||||
startDate, endDate, groupId, scopedCompanyId));
|
||||
}
|
||||
|
||||
@GetMapping("/export")
|
||||
@Operation(summary = "导出外观专利数据库 Excel", description = "与分页查询同一过滤面(任务号/ASIN/国家/同步起止日期/分组),"
|
||||
+ "公司隔离走同一正门:company_id 只对站点超管生效(显式传才收窄,不传全量),非超管强制本公司。"
|
||||
+ "含所属主管列;超过导出上限按业务错误拒绝(QueryAsinController 导出 javadoc 点名的越权形状在此不成立:"
|
||||
+ "页签筛了公司、导出就只导该公司)。")
|
||||
public ResponseEntity<byte[]> export(
|
||||
@Parameter(description = "任务号") @RequestParam(name = "task_id", required = false) Long taskId,
|
||||
@Parameter(description = "ASIN 前缀") @RequestParam(name = "asin", required = false) String asin,
|
||||
@Parameter(description = "国家代码(如 DE、UK)") @RequestParam(name = "country", required = false) String country,
|
||||
@Parameter(description = "同步开始日期(包含)")
|
||||
@RequestParam(name = "start_date", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
||||
@Parameter(description = "同步结束日期(包含)")
|
||||
@RequestParam(name = "end_date", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate,
|
||||
@Parameter(description = "分组 id:按该分组「组长本人+名下子账户」的用户集过滤(主管=组长)")
|
||||
@RequestParam(name = "group_id", required = false) Long groupId,
|
||||
@Parameter(description = "公司 ID") @RequestParam(name = "company_id", required = false) Long companyId,
|
||||
HttpServletRequest request) {
|
||||
RequestOperator operator = requireCleanItemsAccess(request);
|
||||
AdminUserEntity user = operator.user();
|
||||
// 导出与分页共用 readCompanyIdOrOwn 正门(同 page 的口径注释):超管显式传才收窄、
|
||||
// 不传全量;非超管强制本公司(忽略请求传参),绝不让导出绕过页签的公司隔离。
|
||||
Long scopedCompanyId = dataReadScope.readCompanyIdOrOwn(user, companyId);
|
||||
byte[] bytes = cleanItemQueryService.export(taskId, asin, country, startDate, endDate, groupId,
|
||||
scopedCompanyId);
|
||||
String filename = "外观专利数据库-" + LocalDateTime.now().format(EXPORT_FILENAME_FORMATTER) + ".xlsx";
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, DownloadHeaderUtil.contentDisposition(filename))
|
||||
.contentType(MediaType.parseMediaType(XLSX_CONTENT_TYPE))
|
||||
.contentLength(bytes.length)
|
||||
.body(bytes);
|
||||
}
|
||||
|
||||
private RequestOperator requireCleanItemsAccess(HttpServletRequest request) {
|
||||
|
||||
+7
-1
@@ -15,6 +15,10 @@ import java.util.List;
|
||||
* 覆盖式落表({@link #deleteByResultId} + {@link #insertBatch});后管只读页
|
||||
* (Phase 3)走 {@link #countCleanItems}/{@link #selectCleanItemPage}。SQL 全部落
|
||||
* {@code mapper/appearancepatent/AppearancePatentCleanItemMapper.xml}(铁律 1)。</p>
|
||||
*
|
||||
* <p>{@code userIds}(2026-11-11 分组筛选,主管=组长):服务侧由 {@code ShopManageGroupMapper
|
||||
* #selectUserIdsByGroupId} 按分组解析出「组长本人+名下子账户」的 id 集后整集传入,
|
||||
* <b>SQL 侧下推</b>——不得在 Java 侧对已取页做过滤(铁律 20:先 limit 再过滤会饿死另一档)。</p>
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppearancePatentCleanItemMapper extends BaseMapper<CleanItemEntity> {
|
||||
@@ -36,7 +40,8 @@ public interface AppearancePatentCleanItemMapper extends BaseMapper<CleanItemEnt
|
||||
@Param("asin") String asin,
|
||||
@Param("country") String country,
|
||||
@Param("startDate") LocalDate startDate,
|
||||
@Param("endDate") LocalDate endDate);
|
||||
@Param("endDate") LocalDate endDate,
|
||||
@Param("userIds") List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 只读页分页查询(synced_at 倒序)。
|
||||
@@ -51,6 +56,7 @@ public interface AppearancePatentCleanItemMapper extends BaseMapper<CleanItemEnt
|
||||
@Param("country") String country,
|
||||
@Param("startDate") LocalDate startDate,
|
||||
@Param("endDate") LocalDate endDate,
|
||||
@Param("userIds") List<Long> userIds,
|
||||
@Param("offset") long offset,
|
||||
@Param("limit") int limit);
|
||||
}
|
||||
|
||||
+7
-1
@@ -8,7 +8,9 @@ import java.time.LocalDateTime;
|
||||
/**
|
||||
* 外观专利无侵权数据明细行(后管只读页,v1.3 R3)。字段与 {@code biz_appearance_patent_clean_item}
|
||||
* 表列(V189)一一对应——行值是同步服务从 chunk payload 原样落的(不 trim、不转写,AC-1
|
||||
* 「与 payload 一致」),读侧只做搬运不做二次加工。
|
||||
* 「与 payload 一致」),读侧只搬运不做二次加工。唯一例外是 {@code supervisorName}:
|
||||
* 表里没有这一列,查询服务在读侧按「行属用户 → 归属主管」现算补上(2026-11-11 客户需求
|
||||
* 「显示哪一个主管的」),不落库、不回写同步链。
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "外观专利无侵权数据明细行")
|
||||
@@ -26,6 +28,10 @@ public class AppearancePatentCleanItemVo {
|
||||
@Schema(description = "任务 owner 用户 id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "所属主管(读侧现算:owner 是主管/公司超管=自己的用户名,普通账户=创建人的用户名;"
|
||||
+ "用户读不到为空,前端展示 -)")
|
||||
private String supervisorName;
|
||||
|
||||
@Schema(description = "物化归属分公司 id")
|
||||
private Long companyId;
|
||||
|
||||
|
||||
+249
-6
@@ -2,18 +2,32 @@ package com.nanri.aiimage.modules.appearancepatent.service;
|
||||
|
||||
import com.nanri.aiimage.common.api.PageDefaults;
|
||||
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.modules.appearancepatent.mapper.AppearancePatentCleanItemMapper;
|
||||
import com.nanri.aiimage.modules.appearancepatent.model.entity.CleanItemEntity;
|
||||
import com.nanri.aiimage.modules.appearancepatent.model.vo.AppearancePatentCleanItemPageVo;
|
||||
import com.nanri.aiimage.modules.appearancepatent.model.vo.AppearancePatentCleanItemVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 后管「外观专利无侵权数据」只读查询(v1.3 R2)。
|
||||
* 后管「外观专利无侵权数据」只读查询(v1.3 R2)+ 导出(2026-11-11 客户需求「数据得导出来」)。
|
||||
*
|
||||
* <p>分页钳制是本服务的职责(铁律 15):mapper 的 {@code offset}/{@code limit} 只收钳制后的值
|
||||
* (Phase 1 定下的单一出口,mapper 不做第二次换算)。钳制形状照关键词服务 CR-18 先例:
|
||||
@@ -24,7 +38,29 @@ import java.util.List;
|
||||
* <p>{@code scopedCompanyId} 由控制器经 {@code DataReadScope#readCompanyIdOrOwn} 算好传入
|
||||
* (本表与店铺密钥同形状:归属物化在行 {@code company_id} 列、可见集不靠账号/分组):
|
||||
* {@code null} = 超管没选公司、查全量;正数 = 只查该公司(非超管恒为自己的公司)。</p>
|
||||
*
|
||||
* <p><b>所属主管(supervisorName)</b>是唯一的读侧加工列(表 V189 没有该列,同步链一字不动):
|
||||
* 批量取行属用户后按 {@link DeviceSessionPolicy#resolveRole} 分档——owner 是 admin/公司超管/
|
||||
* 站点超管=主管本人,取自己的用户名;普通账户(role 为 null)=创建人({@code users.created_by_id},
|
||||
* 与密钥管理页「所属主管(创建人)」同口径,AccountExpiryService 也认这条为「普通账户的归属主管」)
|
||||
* 的用户名。用户读不到=展示为空(铁律 30:读不出≠没有,不猜名字),全程两次批量查询,无逐行查询。</p>
|
||||
*
|
||||
* <p><b>分组(主管)筛选</b>(2026-11-11 客户口径「主管就是组长,可以筛选组长来导出,就是分组」):
|
||||
* {@code groupId} 是分组管理里那一行的 {@code biz_shop_manage_group.id},服务侧经
|
||||
* {@link ShopManageGroupMapper#selectUserIdsByGroupId} 一次取出「该分组创建人(组长)本人+
|
||||
* 其名下子账户」的 id 集(与数据可见范围同源:组长旧字段 user_id/新字段 created_by_id 都算,
|
||||
* 成员表基本未使用)后<b>整集下推 SQL</b>({@code user_id IN},铁律 20:不得取页后 Java 过滤)。
|
||||
* 选项不下新端点:后管下拉直接复用既有 {@code GET /shop-manages/groups}(与去重页/店铺管理
|
||||
* 共用同一分组集)。行上「所属主管」列的展示口径与它同源:组长本人行=自己,名下子账户行=
|
||||
* 创建人(创建人即组长,AccountExpiryService 同一口径)。</p>
|
||||
*
|
||||
* <p><b>导出</b>与分页共用同一过滤面与 {@code selectCleanItemPage} 这一条 SQL(offset=0、
|
||||
* limit=导出上限,不另写导出查询),先 {@code countCleanItems} 卡 {@link #EXPORT_MAX_ROWS}
|
||||
* 上限防内存,行集经同一 {@code toVo}+主管富化后按后管页面的列序写 xlsx(SXSSF 流式,
|
||||
* 口径同 {@code QueryAsinService.export} 的 byte[] 形状)。国家列落中文标签,
|
||||
* 字典与前端 {@code asin-country.ts}(ASIN 数据中心共享国家字典)同表。</p>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AppearancePatentCleanItemQueryService {
|
||||
@@ -33,17 +69,35 @@ public class AppearancePatentCleanItemQueryService {
|
||||
private static final long MAX_PAGE = 10_000;
|
||||
/** 每页条数上限(蓝图 §3.2)。 */
|
||||
private static final long MAX_PAGE_SIZE = 100;
|
||||
/** 单次导出行数上限:超限按业务错误拒(提示缩小筛选面),不把无界内存写进一次 HTTP 响应。 */
|
||||
public static final long EXPORT_MAX_ROWS = 50_000;
|
||||
/** 导出同步时间列的展示格式。 */
|
||||
private static final DateTimeFormatter EXPORT_SYNCED_AT_FORMATTER =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
/** 导出列序(与后管页面同序,主管列插在结论后、同步时间前)。 */
|
||||
private static final List<String> EXPORT_HEADERS = List.of(
|
||||
"任务号", "ASIN", "国家", "SKU", "品牌", "价格", "标题", "结论", "所属主管", "同步时间");
|
||||
/** 国家码 → 中文标签:与前端 asin-country.ts 同表,不在字典的原样回显(读侧不加工未知值)。 */
|
||||
private static final Map<String, String> COUNTRY_LABELS = Map.of(
|
||||
"DE", "德国",
|
||||
"UK", "英国",
|
||||
"FR", "法国",
|
||||
"IT", "意大利",
|
||||
"ES", "西班牙");
|
||||
|
||||
private final AppearancePatentCleanItemMapper cleanItemMapper;
|
||||
private final AdminUserMapper adminUserMapper;
|
||||
private final ShopManageGroupMapper shopManageGroupMapper;
|
||||
|
||||
/**
|
||||
* 分页查询只读明细({@code synced_at} 倒序)。
|
||||
*
|
||||
* <p>过滤面:公司(物化列 eq)、任务号、ASIN 前缀(保 {@code idx_asin} 可用,同去重页口径)、
|
||||
* 国家、同步起止日期(闭区间,含 end 当天)。</p>
|
||||
* 国家、同步起止日期(闭区间,含 end 当天)、分组({@code user_id IN 组长名下用户集})。</p>
|
||||
*/
|
||||
public AppearancePatentCleanItemPageVo page(Long page, Long pageSize, Long taskId, String asin,
|
||||
String country, LocalDate startDate, LocalDate endDate, Long scopedCompanyId) {
|
||||
String country, LocalDate startDate, LocalDate endDate, Long groupId, Long scopedCompanyId) {
|
||||
if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
|
||||
throw new BusinessException("开始日期不能晚于结束日期");
|
||||
}
|
||||
@@ -53,18 +107,207 @@ public class AppearancePatentCleanItemQueryService {
|
||||
Long companyId = scopedCompanyId != null && scopedCompanyId > 0 ? scopedCompanyId : null;
|
||||
String safeAsin = trimToNull(asin);
|
||||
String safeCountry = trimToNull(country);
|
||||
long total = cleanItemMapper.countCleanItems(companyId, taskId, safeAsin, safeCountry, startDate, endDate);
|
||||
List<Long> groupUserIds = groupUserIds(groupId);
|
||||
if (groupUserIds != null && groupUserIds.isEmpty()) {
|
||||
// 分组读不出任何用户(如分组已被删):结果必为空,短路不碰 mapper。
|
||||
return emptyPage(safePage, safeSize);
|
||||
}
|
||||
long total = cleanItemMapper.countCleanItems(companyId, taskId, safeAsin, safeCountry, startDate, endDate,
|
||||
groupUserIds);
|
||||
List<CleanItemEntity> rows = total <= 0 ? List.of()
|
||||
: cleanItemMapper.selectCleanItemPage(companyId, taskId, safeAsin, safeCountry, startDate, endDate,
|
||||
(safePage - 1) * safeSize, (int) safeSize);
|
||||
groupUserIds, (safePage - 1) * safeSize, (int) safeSize);
|
||||
List<AppearancePatentCleanItemVo> items = rows.stream().map(AppearancePatentCleanItemQueryService::toVo).toList();
|
||||
fillSupervisorNames(items);
|
||||
AppearancePatentCleanItemPageVo vo = new AppearancePatentCleanItemPageVo();
|
||||
vo.setItems(rows.stream().map(AppearancePatentCleanItemQueryService::toVo).toList());
|
||||
vo.setItems(items);
|
||||
vo.setTotal(total);
|
||||
vo.setPage(safePage);
|
||||
vo.setPageSize(safeSize);
|
||||
return vo;
|
||||
}
|
||||
|
||||
private static AppearancePatentCleanItemPageVo emptyPage(long page, long pageSize) {
|
||||
AppearancePatentCleanItemPageVo vo = new AppearancePatentCleanItemPageVo();
|
||||
vo.setItems(List.of());
|
||||
vo.setTotal(0L);
|
||||
vo.setPage(page);
|
||||
vo.setPageSize(pageSize);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出当前过滤面全量明细为 xlsx 字节(控制器直接回 {@code ResponseEntity<byte[]>},
|
||||
* 口径同 {@code QueryAsinService.export})。
|
||||
*
|
||||
* <p>先 count 卡 {@link #EXPORT_MAX_ROWS} 上限再取数;取数复用 {@code selectCleanItemPage}
|
||||
* 这一条 SQL(offset=0、limit=上限),不另写导出查询——过滤面永远和分页页签同源,
|
||||
* 不会出现「页签筛了公司、导出全量」的越权形状(QueryAsinController 导出 javadoc 点名的语义)。</p>
|
||||
*/
|
||||
public byte[] export(Long taskId, String asin, String country, LocalDate startDate, LocalDate endDate,
|
||||
Long groupId, Long scopedCompanyId) {
|
||||
if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
|
||||
throw new BusinessException("开始日期不能晚于结束日期");
|
||||
}
|
||||
Long companyId = scopedCompanyId != null && scopedCompanyId > 0 ? scopedCompanyId : null;
|
||||
String safeAsin = trimToNull(asin);
|
||||
String safeCountry = trimToNull(country);
|
||||
List<Long> groupUserIds = groupUserIds(groupId);
|
||||
if (groupUserIds != null && groupUserIds.isEmpty()) {
|
||||
// 与分页同口径:分组读不出用户=空结果,导出只给表头(不碰 mapper)。
|
||||
return writeExportWorkbook(List.of());
|
||||
}
|
||||
long total = cleanItemMapper.countCleanItems(companyId, taskId, safeAsin, safeCountry, startDate, endDate,
|
||||
groupUserIds);
|
||||
if (total > EXPORT_MAX_ROWS) {
|
||||
throw new BusinessException("无侵权数据共 " + total + " 行,超过导出上限 " + EXPORT_MAX_ROWS
|
||||
+ " 行,请缩小筛选范围后重试");
|
||||
}
|
||||
List<CleanItemEntity> rows = total <= 0 ? List.of()
|
||||
: cleanItemMapper.selectCleanItemPage(companyId, taskId, safeAsin, safeCountry, startDate, endDate,
|
||||
groupUserIds, 0L, (int) EXPORT_MAX_ROWS);
|
||||
List<AppearancePatentCleanItemVo> items = rows.stream().map(AppearancePatentCleanItemQueryService::toVo).toList();
|
||||
fillSupervisorNames(items);
|
||||
return writeExportWorkbook(items);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组筛选 → 该分组「组长本人+名下子账户」的用户 id 集({@code null} = 没选分组、不过滤);
|
||||
* id 非法(≤0)按没选处理,不把它当全量之外的第三档。解析交给
|
||||
* {@link ShopManageGroupMapper#selectUserIdsByGroupId}(组长旧字段 user_id/新字段
|
||||
* created_by_id 都算,与数据可见范围同源),分组不存在/无成员返回空集由调用方短路。
|
||||
*/
|
||||
private List<Long> groupUserIds(Long groupId) {
|
||||
if (groupId == null || groupId <= 0) {
|
||||
return null;
|
||||
}
|
||||
List<Long> userIds = shopManageGroupMapper.selectUserIdsByGroupId(groupId);
|
||||
return userIds == null ? List.of() : userIds;
|
||||
}
|
||||
|
||||
private byte[] writeExportWorkbook(List<AppearancePatentCleanItemVo> items) {
|
||||
try (SXSSFWorkbook workbook = new SXSSFWorkbook(100);
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
Sheet sheet = workbook.createSheet("外观专利数据库");
|
||||
Row header = sheet.createRow(0);
|
||||
for (int c = 0; c < EXPORT_HEADERS.size(); c++) {
|
||||
header.createCell(c).setCellValue(EXPORT_HEADERS.get(c));
|
||||
}
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
writeExportRow(sheet, i + 1, items.get(i));
|
||||
}
|
||||
// 标题列放宽,其余走默认窄列;与页面列宽观感对齐即可,不追求逐像素。
|
||||
sheet.setColumnWidth(6, 46 * 256);
|
||||
sheet.setColumnWidth(2, 10 * 256);
|
||||
workbook.write(outputStream);
|
||||
workbook.dispose();
|
||||
return outputStream.toByteArray();
|
||||
} catch (Exception ex) {
|
||||
// 落盘/序列化失败必须给可读业务错误(用户手里的导出请求不能变成 500 裸堆栈),
|
||||
// 细节进日志;CatchSilenceRatchetTest 基线随本支 +1(RETHROW 形状)。
|
||||
log.warn("[appearance-patent-clean] 导出 xlsx 失败 rows={} msg={}", items.size(), ex.getMessage());
|
||||
throw new BusinessException("导出外观专利数据库失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeExportRow(Sheet sheet, int rowIndex, AppearancePatentCleanItemVo item) {
|
||||
Row row = sheet.createRow(rowIndex);
|
||||
row.createCell(0).setCellValue(item.getTaskId() == null ? "" : String.valueOf(item.getTaskId()));
|
||||
row.createCell(1).setCellValue(safe(item.getAsin()));
|
||||
row.createCell(2).setCellValue(countryLabel(item.getCountry()));
|
||||
row.createCell(3).setCellValue(safe(item.getSku()));
|
||||
row.createCell(4).setCellValue(safe(item.getBrand()));
|
||||
row.createCell(5).setCellValue(safe(item.getPrice()));
|
||||
row.createCell(6).setCellValue(safe(item.getTitle()));
|
||||
row.createCell(7).setCellValue(safe(item.getConclusion()));
|
||||
row.createCell(8).setCellValue(safe(item.getSupervisorName()));
|
||||
row.createCell(9).setCellValue(item.getSyncedAt() == null
|
||||
? "" : EXPORT_SYNCED_AT_FORMATTER.format(item.getSyncedAt()));
|
||||
}
|
||||
|
||||
private static String countryLabel(String country) {
|
||||
if (country == null || country.isBlank()) {
|
||||
return "";
|
||||
}
|
||||
return COUNTRY_LABELS.getOrDefault(country.trim(), country.trim());
|
||||
}
|
||||
|
||||
private static String safe(String value) {
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量补「所属主管」:行属用户一次取齐;普通账户的创建人再一次取齐(全程两次批量查询,
|
||||
* 同密钥管理页 fillRowGroups 的「用户→创建人→创建人用户名」形状)。读不到的用户/创建人
|
||||
* 不猜名字,supervisorName 留空由前端展示 -(铁律 30)。
|
||||
*/
|
||||
private void fillSupervisorNames(List<AppearancePatentCleanItemVo> items) {
|
||||
List<Long> userIds = items.stream()
|
||||
.map(AppearancePatentCleanItemVo::getUserId)
|
||||
.filter(id -> id != null)
|
||||
.distinct()
|
||||
.toList();
|
||||
if (userIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<Long, AdminUserEntity> ownersById = new LinkedHashMap<>();
|
||||
for (AdminUserEntity owner : adminUserMapper.selectBatchIds(userIds)) {
|
||||
if (owner.getId() != null) {
|
||||
ownersById.put(owner.getId(), owner);
|
||||
}
|
||||
}
|
||||
Map<Long, String> supervisorByUserId = new LinkedHashMap<>();
|
||||
Set<Long> creatorIds = new LinkedHashSet<>();
|
||||
for (Long userId : userIds) {
|
||||
AdminUserEntity owner = ownersById.get(userId);
|
||||
if (owner == null) {
|
||||
continue;
|
||||
}
|
||||
String username = trimmed(owner.getUsername());
|
||||
if (DeviceSessionPolicy.resolveRole(owner.getRole(), owner.getIsAdmin(), owner.getCreatedById()) != null) {
|
||||
// 主管本人(admin/公司超管/站点超管)跑的单:主管就是自己,不外指创建人。
|
||||
if (!username.isEmpty()) {
|
||||
supervisorByUserId.put(userId, username);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Long creatorId = owner.getCreatedById();
|
||||
if (creatorId == null || creatorId <= 0) {
|
||||
continue;
|
||||
}
|
||||
creatorIds.add(creatorId);
|
||||
}
|
||||
if (!creatorIds.isEmpty()) {
|
||||
Map<Long, String> creatorNames = new LinkedHashMap<>();
|
||||
for (AdminUserEntity creator : adminUserMapper.selectBatchIds(creatorIds)) {
|
||||
String username = trimmed(creator.getUsername());
|
||||
if (creator.getId() != null && !username.isEmpty()) {
|
||||
creatorNames.put(creator.getId(), username);
|
||||
}
|
||||
}
|
||||
for (Long userId : userIds) {
|
||||
AdminUserEntity owner = ownersById.get(userId);
|
||||
if (owner == null || creatorNames.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
Long creatorId = owner.getCreatedById();
|
||||
if (creatorId != null && creatorNames.containsKey(creatorId)
|
||||
&& !supervisorByUserId.containsKey(userId)) {
|
||||
supervisorByUserId.put(userId, creatorNames.get(creatorId));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (AppearancePatentCleanItemVo item : items) {
|
||||
if (item.getUserId() != null) {
|
||||
item.setSupervisorName(supervisorByUserId.get(item.getUserId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String trimmed(String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
|
||||
private static String trimToNull(String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
|
||||
+8
-1
@@ -3,7 +3,10 @@
|
||||
<mapper namespace="com.nanri.aiimage.modules.appearancepatent.mapper.AppearancePatentCleanItemMapper">
|
||||
<!-- 外观专利无侵权数据(V189,v1.3):SQL 全部落 XML(铁律 1)。
|
||||
只读页过滤面:公司(物化列 eq)、任务号、ASIN 前缀(同去重页形状,保证 idx_asin 可用)、
|
||||
国家、同步起止日期;全部走 #{} 占位符。offset/limit 必须是服务侧钳制后的值(铁律 15)。 -->
|
||||
国家、同步起止日期、组长名下用户集(2026-11-11 分组筛选,主管=组长:服务侧按
|
||||
ShopManageGroupMapper.selectUserIdsByGroupId 解析「组长本人+名下子账户」整集传入,
|
||||
SQL 侧下推——铁律 20,不得取页后 Java 过滤);
|
||||
全部走 #{} 占位符。offset/limit 必须是服务侧钳制后的值(铁律 15)。 -->
|
||||
|
||||
<sql id="cleanItemConds">
|
||||
<if test="companyId != null">AND company_id = #{companyId}</if>
|
||||
@@ -12,6 +15,10 @@
|
||||
<if test="country != null and country != ''">AND country = #{country}</if>
|
||||
<if test="startDate != null">AND synced_at >= #{startDate}</if>
|
||||
<if test="endDate != null">AND synced_at < DATE_ADD(#{endDate}, INTERVAL 1 DAY)</if>
|
||||
<if test="userIds != null and userIds.size() > 0">
|
||||
AND user_id IN
|
||||
<foreach collection="userIds" item="uid" open="(" separator="," close=")">#{uid}</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteByResultId">
|
||||
|
||||
@@ -318,7 +318,13 @@ class CatchSilenceRatchetTest {
|
||||
// 上层把原 401/403 原样抛回(回退失败必须显形,不吞)。
|
||||
// 本批复核办法:上限压 0/下限抬 99999 单跑一次,实测 total 1073、rethrow 406、
|
||||
// notRethrow 611、logOnly 193、empty 56(EMPTY 一格没涨)。
|
||||
static final int STRICT_TOTAL = 1073;
|
||||
// 11-11 外观专利数据库导出抬 1073 -> 1074,一枚逐处记名:
|
||||
// `AppearancePatentCleanItemQueryService.writeExportWorkbook`:SXSSF 落盘 catch Exception
|
||||
// → BusinessException「导出外观专利数据库失败,请稍后重试」(RETHROW 形状,rethrow 406 -> 407,
|
||||
// 本格与 NOT_RETHROW/LOG_ONLY/EMPTY 都不动)。误差方向:导出请求的 IO 失败必须给用户
|
||||
// 可读业务错误而不是 500 裸堆栈;反向对照——改成往外抛 IOException=前端拿到 Spring 兜底文案,
|
||||
// 改成吞掉返回空字节=用户拿到 0 字节 xlsx 还以为导出成功(比报错更贵)。
|
||||
static final int STRICT_TOTAL = 1074;
|
||||
/**
|
||||
* 重抛型 catch 的**下限**(不是上限):本轮把两处吞异常改成重抛之后实测 388。
|
||||
* 这一格只能涨不能跌——它是"异常会往外走"的总量,把它钉成"只许减"就等于拦着别人修吞异常。
|
||||
|
||||
+283
-23
@@ -3,6 +3,8 @@ package com.nanri.aiimage.modules.appearancepatent.controller;
|
||||
import com.nanri.aiimage.common.api.ApiResponse;
|
||||
import com.nanri.aiimage.common.api.PageDefaults;
|
||||
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.AdminAuthSupport;
|
||||
import com.nanri.aiimage.common.service.DataReadScope;
|
||||
@@ -13,28 +15,42 @@ import com.nanri.aiimage.modules.appearancepatent.model.vo.AppearancePatentClean
|
||||
import com.nanri.aiimage.modules.appearancepatent.service.AppearancePatentCleanItemQueryService;
|
||||
import com.nanri.aiimage.modules.permission.service.PermissionMenuService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
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.any;
|
||||
import static org.mockito.ArgumentMatchers.anyCollection;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -195,13 +211,13 @@ class AdminAppearancePatentCleanItemsControllerTest {
|
||||
pageVo.setTotal(0L);
|
||||
pageVo.setPage(1L);
|
||||
pageVo.setPageSize((long) PageDefaults.CLEAN_ITEMS_PAGE_SIZE_INT);
|
||||
when(queryService.page(1L, 10L, null, null, null, null, null, 5L)).thenReturn(pageVo);
|
||||
when(queryService.page(1L, 10L, null, null, null, null, null, null, 5L)).thenReturn(pageVo);
|
||||
|
||||
ApiResponse<AppearancePatentCleanItemPageVo> response =
|
||||
controller.page(1L, 10L, null, null, null, null, null, 5L, request);
|
||||
controller.page(1L, 10L, null, null, null, null, null, null, 5L, request);
|
||||
|
||||
verify(dataReadScope).readCompanyIdOrOwn(operator, 5L);
|
||||
verify(queryService).page(1L, 10L, null, null, null, null, null, 5L);
|
||||
verify(queryService).page(1L, 10L, null, null, null, null, null, null, 5L);
|
||||
assertEquals(Boolean.TRUE, response.isSuccess(), "拒绝走 403 业务码,放行必须是 success 信封(B80-03)");
|
||||
assertEquals(pageVo, response.getData());
|
||||
}
|
||||
@@ -209,24 +225,25 @@ class AdminAppearancePatentCleanItemsControllerTest {
|
||||
@Test
|
||||
void 查询服务分页钳制防溢出() {
|
||||
AppearancePatentCleanItemMapper mapper = mock(AppearancePatentCleanItemMapper.class);
|
||||
AppearancePatentCleanItemQueryService service = new AppearancePatentCleanItemQueryService(mapper);
|
||||
when(mapper.countCleanItems(any(), any(), any(), any(), any(), any())).thenReturn(1L);
|
||||
AppearancePatentCleanItemQueryService service = new AppearancePatentCleanItemQueryService(
|
||||
mapper, mock(AdminUserMapper.class), mock(ShopManageGroupMapper.class));
|
||||
when(mapper.countCleanItems(any(), any(), any(), any(), any(), any(), any())).thenReturn(1L);
|
||||
|
||||
// page=0 / size=null ⇒ 归一为第 1 页、默认 10 条;offset = 0。
|
||||
service.page(0L, null, null, null, null, null, null, null);
|
||||
// page=0 / size=null ⇒ 归一为第 1 页、默认 10 条;offset = 0(groupId 不传=不做分组过滤)。
|
||||
service.page(0L, null, null, null, null, null, null, null, null);
|
||||
ArgumentCaptor<Long> offset = ArgumentCaptor.forClass(Long.class);
|
||||
ArgumentCaptor<Integer> limit = ArgumentCaptor.forClass(Integer.class);
|
||||
verify(mapper).selectCleanItemPage(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(),
|
||||
offset.capture(), limit.capture());
|
||||
isNull(), offset.capture(), limit.capture());
|
||||
assertEquals(0L, offset.getValue());
|
||||
assertEquals(PageDefaults.CLEAN_ITEMS_PAGE_SIZE_INT, limit.getValue());
|
||||
|
||||
// page=Long.MAX_VALUE / size=500 ⇒ 钳到 10_000 页、100 条;乘积 999_900 不得变负(铁律 15,CR-18 同值)。
|
||||
service.page(Long.MAX_VALUE, 500L, null, null, null, null, null, null);
|
||||
service.page(Long.MAX_VALUE, 500L, null, null, null, null, null, null, null);
|
||||
ArgumentCaptor<Long> offsetMax = ArgumentCaptor.forClass(Long.class);
|
||||
ArgumentCaptor<Integer> limitMax = ArgumentCaptor.forClass(Integer.class);
|
||||
verify(mapper, org.mockito.Mockito.times(2)).selectCleanItemPage(any(), any(), any(), any(), any(), any(),
|
||||
offsetMax.capture(), limitMax.capture());
|
||||
any(), offsetMax.capture(), limitMax.capture());
|
||||
assertEquals(999_900L, offsetMax.getValue(), "(page-1)*page_size 最大 999_900,钳制后不得溢出变负");
|
||||
assertEquals(100, limitMax.getValue());
|
||||
}
|
||||
@@ -234,32 +251,77 @@ class AdminAppearancePatentCleanItemsControllerTest {
|
||||
@Test
|
||||
void 查询服务公司过滤原样直传() {
|
||||
AppearancePatentCleanItemMapper mapper = mock(AppearancePatentCleanItemMapper.class);
|
||||
AppearancePatentCleanItemQueryService service = new AppearancePatentCleanItemQueryService(mapper);
|
||||
when(mapper.countCleanItems(any(), any(), any(), any(), any(), any())).thenReturn(0L);
|
||||
AppearancePatentCleanItemQueryService service = new AppearancePatentCleanItemQueryService(
|
||||
mapper, mock(AdminUserMapper.class), mock(ShopManageGroupMapper.class));
|
||||
when(mapper.countCleanItems(any(), any(), any(), any(), any(), any(), any())).thenReturn(0L);
|
||||
|
||||
// 超管显式传 5 ⇒ 按公司 5 筛(收窄);null ⇒ 全量(AC-4 前半句)。
|
||||
service.page(1L, 10L, null, null, null, null, null, 5L);
|
||||
verify(mapper).countCleanItems(eq(5L), isNull(), isNull(), isNull(), isNull(), isNull());
|
||||
service.page(1L, 10L, null, null, null, null, null, null);
|
||||
verify(mapper).countCleanItems(isNull(), isNull(), isNull(), isNull(), isNull(), isNull());
|
||||
service.page(1L, 10L, null, null, null, null, null, null, 5L);
|
||||
verify(mapper).countCleanItems(eq(5L), isNull(), isNull(), isNull(), isNull(), isNull(), isNull());
|
||||
service.page(1L, 10L, null, null, null, null, null, null, null);
|
||||
verify(mapper).countCleanItems(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull());
|
||||
}
|
||||
|
||||
@Test
|
||||
void 查询服务日期倒挂拒绝() {
|
||||
AppearancePatentCleanItemMapper mapper = mock(AppearancePatentCleanItemMapper.class);
|
||||
AppearancePatentCleanItemQueryService service = new AppearancePatentCleanItemQueryService(mapper);
|
||||
AppearancePatentCleanItemQueryService service = new AppearancePatentCleanItemQueryService(
|
||||
mapper, mock(AdminUserMapper.class), mock(ShopManageGroupMapper.class));
|
||||
BusinessException ex = assertThrows(BusinessException.class,
|
||||
() -> service.page(1L, 10L, null, null, null,
|
||||
LocalDate.of(2026, 11, 9), LocalDate.of(2026, 11, 1), null));
|
||||
LocalDate.of(2026, 11, 9), LocalDate.of(2026, 11, 1), null, null));
|
||||
assertTrue(ex.getMessage().contains("开始日期不能晚于结束日期"),
|
||||
"倒挂日期按业务异常拒绝(同去重页文案口径)");
|
||||
verify(mapper, org.mockito.Mockito.never()).countCleanItems(any(), any(), any(), any(), any(), any());
|
||||
verify(mapper, org.mockito.Mockito.never()).countCleanItems(any(), any(), any(), any(), any(), any(), any());
|
||||
// 导出与分页共用同一过滤面校验(同一句文案,同一个拒绝时机:不碰 mapper)。
|
||||
BusinessException exportEx = assertThrows(BusinessException.class,
|
||||
() -> service.export(null, null, null,
|
||||
LocalDate.of(2026, 11, 9), LocalDate.of(2026, 11, 1), null, null));
|
||||
assertTrue(exportEx.getMessage().contains("开始日期不能晚于结束日期"),
|
||||
"导出端点必须同样拒绝倒挂日期,不得绕过分页页签的校验口径");
|
||||
}
|
||||
|
||||
@Test
|
||||
void 分组筛选按组长名下用户集下推SQL且空集短路() {
|
||||
AppearancePatentCleanItemMapper mapper = mock(AppearancePatentCleanItemMapper.class);
|
||||
AdminUserMapper adminUserMapper = mock(AdminUserMapper.class);
|
||||
ShopManageGroupMapper shopManageGroupMapper = mock(ShopManageGroupMapper.class);
|
||||
AppearancePatentCleanItemQueryService service =
|
||||
new AppearancePatentCleanItemQueryService(mapper, adminUserMapper, shopManageGroupMapper);
|
||||
when(mapper.countCleanItems(any(), any(), any(), any(), any(), any(), any())).thenReturn(2L);
|
||||
when(shopManageGroupMapper.selectUserIdsByGroupId(9L)).thenReturn(List.of(9L, 33L));
|
||||
|
||||
// 选了分组 9 ⇒ 解析出的「组长本人+名下子账户」整集传给 mapper(SQL 侧下推,铁律 20)。
|
||||
service.page(1L, 10L, null, null, null, null, null, 9L, 5L);
|
||||
verify(shopManageGroupMapper).selectUserIdsByGroupId(9L);
|
||||
verify(mapper).countCleanItems(eq(5L), isNull(), isNull(), isNull(), isNull(), isNull(),
|
||||
eq(List.of(9L, 33L)));
|
||||
|
||||
// 分组读不出任何用户(如分组已被删)⇒ 结果必为空:短路不碰 mapper(IN () 不是合法 SQL)。
|
||||
when(shopManageGroupMapper.selectUserIdsByGroupId(66L)).thenReturn(List.of());
|
||||
AppearancePatentCleanItemPageVo empty = service.page(1L, 10L, null, null, null, null, null, 66L, 5L);
|
||||
assertEquals(0L, empty.getTotal());
|
||||
assertTrue(empty.getItems().isEmpty(), "分组空集=空页,不碰 mapper");
|
||||
// 此刻 selectCleanItemPage 仍只有分组 9 那一页的 1 次调用(空集短路没有追加取数)。
|
||||
verify(mapper, org.mockito.Mockito.times(1)).selectCleanItemPage(any(), any(), any(), any(), any(), any(),
|
||||
any(), anyLong(), anyInt());
|
||||
|
||||
// 导出同口径:空集只给表头(不追加取数)。
|
||||
byte[] bytes = service.export(null, null, null, null, null, 66L, 5L);
|
||||
assertNotNull(bytes);
|
||||
verify(mapper, org.mockito.Mockito.times(1)).selectCleanItemPage(any(), any(), any(), any(), any(), any(),
|
||||
any(), anyLong(), anyInt());
|
||||
|
||||
// groupId ≤ 0 按没选分组处理(不当第三档):分组解析不新增调用(此前 9L×1+66L×2=3 次)。
|
||||
service.page(1L, 10L, null, null, null, null, null, 0L, 5L);
|
||||
verify(shopManageGroupMapper, org.mockito.Mockito.times(3)).selectUserIdsByGroupId(anyLong());
|
||||
}
|
||||
|
||||
@Test
|
||||
void 行字段与VO搬运一致不加工() {
|
||||
AppearancePatentCleanItemMapper mapper = mock(AppearancePatentCleanItemMapper.class);
|
||||
AppearancePatentCleanItemQueryService service = new AppearancePatentCleanItemQueryService(mapper);
|
||||
AppearancePatentCleanItemQueryService service = new AppearancePatentCleanItemQueryService(
|
||||
mapper, mock(AdminUserMapper.class), mock(ShopManageGroupMapper.class));
|
||||
CleanItemEntity entity = new CleanItemEntity();
|
||||
entity.setId(11L);
|
||||
entity.setResultId(901L);
|
||||
@@ -279,11 +341,11 @@ class AdminAppearancePatentCleanItemsControllerTest {
|
||||
entity.setSourceFilename("list.xlsx");
|
||||
LocalDateTime syncedAt = LocalDateTime.of(2026, 11, 10, 10, 30);
|
||||
entity.setSyncedAt(syncedAt);
|
||||
when(mapper.countCleanItems(any(), any(), any(), any(), any(), any())).thenReturn(1L);
|
||||
when(mapper.selectCleanItemPage(any(), any(), any(), any(), any(), any(), anyLong(),
|
||||
when(mapper.countCleanItems(any(), any(), any(), any(), any(), any(), any())).thenReturn(1L);
|
||||
when(mapper.selectCleanItemPage(any(), any(), any(), any(), any(), any(), any(), anyLong(),
|
||||
org.mockito.ArgumentMatchers.anyInt())).thenReturn(List.of(entity));
|
||||
|
||||
AppearancePatentCleanItemPageVo vo = service.page(1L, 10L, 33179L, null, null, null, null, 5L);
|
||||
AppearancePatentCleanItemPageVo vo = service.page(1L, 10L, 33179L, null, null, null, null, null, 5L);
|
||||
assertEquals(1L, vo.getTotal());
|
||||
AppearancePatentCleanItemVo row = vo.getItems().get(0);
|
||||
// 读侧只搬运不加工:标题两侧空格原样保留(AC-1「与 payload 一致」,后端不 trim 是与行值同口径)。
|
||||
@@ -297,6 +359,204 @@ class AdminAppearancePatentCleanItemsControllerTest {
|
||||
assertEquals("标题含品牌词", row.getTitleReason());
|
||||
assertEquals("list.xlsx", row.getSourceFilename());
|
||||
assertEquals(syncedAt, row.getSyncedAt());
|
||||
// 行属用户读不到(AdminUserMapper 未命中)时主管列不猜名字,留空由前端展示 -(铁律 30)。
|
||||
assertNull(row.getSupervisorName(), "用户读不到=supervisorName 为空,不得编造归属");
|
||||
}
|
||||
|
||||
// ===================== 2026-11-11 客户需求:主管列+导出 =====================
|
||||
|
||||
@Test
|
||||
void 导出端点就位且与分页共用同一正门() throws IOException {
|
||||
String source = stripComments(Files.readString(CONTROLLER));
|
||||
assertTrue(source.contains("\"/export\""),
|
||||
"导出必须是 GET /api/admin/appearance-patent-clean-items/export(2026-11-11 客户需求「数据得导出来」)");
|
||||
// 导出仍是只读:本页禁写/删/导入的判据由「控制器与只读端点就位」一格把守(无 Post/Put/Delete),
|
||||
// 导出落 GET 不破那格;导出与分页都必须各自调用 requireCleanItemsAccess+readCompanyIdOrOwn
|
||||
//(私有两支各调一次,缺一支即红——导出不许绕过页签的鉴权与公司隔离)。
|
||||
long gateCalls = source.split("requireCleanItemsAccess\\(request\\)", -1).length - 1;
|
||||
assertTrue(gateCalls >= 2, "分页与导出两支 handler 都必须过 requireCleanItemsAccess 正门,实得 " + gateCalls);
|
||||
long scopeCalls = source.split("readCompanyIdOrOwn\\(", -1).length - 1;
|
||||
assertTrue(scopeCalls >= 2, "分页与导出两支 handler 都必须走 readCompanyIdOrOwn 公司隔离,实得 " + scopeCalls);
|
||||
// 导出是全量导出(服务侧另有 EXPORT_MAX_ROWS 上限),不收 page/page_size:
|
||||
// 全文件 page_size 只允许出现一次(分页 handler 的参数声明)。
|
||||
long pageSizeParams = source.split("page_size", -1).length - 1;
|
||||
assertEquals(1, pageSizeParams, "导出不收分页参数,page_size 只许出现在分页 handler 的参数声明里");
|
||||
// 分组(主管=组长)筛选:group_id 在分页与导出两支都要收;选项不下新端点(复用
|
||||
// 既有 GET /shop-manages/groups,与去重页/店铺管理同源)。
|
||||
long groupParams = source.split("group_id", -1).length - 1;
|
||||
assertTrue(groupParams >= 2, "分页与导出都必须收 group_id(主管=组长,就是分组,2026-11-11 客户口径)");
|
||||
assertFalse(source.contains("\"/supervisors\""),
|
||||
"选项复用既有分组端点,本控制器不得再挂 /supervisors 第二份选项源");
|
||||
}
|
||||
|
||||
@Test
|
||||
void 控制器导出走同一鉴权正门并回Excel响应() {
|
||||
AppearancePatentCleanItemMapper mapper = mock(AppearancePatentCleanItemMapper.class);
|
||||
AppearancePatentCleanItemQueryService queryService = mock(AppearancePatentCleanItemQueryService.class);
|
||||
AdminAuthSupport authSupport = mock(AdminAuthSupport.class);
|
||||
PermissionMenuService permissionMenuService = mock(PermissionMenuService.class);
|
||||
DataReadScope dataReadScope = mock(DataReadScope.class);
|
||||
AdminAppearancePatentCleanItemsController controller = new AdminAppearancePatentCleanItemsController(
|
||||
queryService, authSupport, permissionMenuService, 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(dataReadScope.readCompanyIdOrOwn(operator, 5L)).thenReturn(5L);
|
||||
byte[] payload = "xlsx-bytes".getBytes(StandardCharsets.UTF_8);
|
||||
when(queryService.export(null, null, null, null, null, null, 5L)).thenReturn(payload);
|
||||
|
||||
ResponseEntity<byte[]> response = controller.export(null, null, null, null, null, null, 5L, request);
|
||||
|
||||
verify(dataReadScope).readCompanyIdOrOwn(operator, 5L);
|
||||
verify(queryService).export(null, null, null, null, null, null, 5L);
|
||||
assertEquals(MediaType.parseMediaType(
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
|
||||
response.getHeaders().getContentType(), "导出必须是 xlsx Content-Type(浏览器按扩展名/类型落盘)");
|
||||
assertTrue(response.getHeaders().getFirst(HttpHeaders.CONTENT_DISPOSITION).contains("filename*=UTF-8''"),
|
||||
"中文文件名必须带 filename* UTF-8 轨(DownloadHeaderUtil 双轨口径)");
|
||||
assertArrayEquals(payload, response.getBody(), "响应体必须原样是服务侧产出的字节");
|
||||
}
|
||||
|
||||
@Test
|
||||
void 导出超上限按业务错误拒绝且不取数() {
|
||||
AppearancePatentCleanItemMapper mapper = mock(AppearancePatentCleanItemMapper.class);
|
||||
AppearancePatentCleanItemQueryService service = new AppearancePatentCleanItemQueryService(
|
||||
mapper, mock(AdminUserMapper.class), mock(ShopManageGroupMapper.class));
|
||||
when(mapper.countCleanItems(any(), any(), any(), any(), any(), any(), any()))
|
||||
.thenReturn(AppearancePatentCleanItemQueryService.EXPORT_MAX_ROWS + 1);
|
||||
|
||||
BusinessException ex = assertThrows(BusinessException.class,
|
||||
() -> service.export(null, null, null, null, null, null, 5L));
|
||||
assertTrue(ex.getMessage().contains("超过导出上限"),
|
||||
"超上限必须给「缩小筛选范围」的可读文案,不能让用户等一次注定 OOM 的全量查询");
|
||||
verify(mapper, never()).selectCleanItemPage(any(), any(), any(), any(), any(), any(), any(),
|
||||
anyLong(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
void 分页行补所属主管按角色分档() {
|
||||
AppearancePatentCleanItemMapper mapper = mock(AppearancePatentCleanItemMapper.class);
|
||||
AdminUserMapper adminUserMapper = mock(AdminUserMapper.class);
|
||||
AppearancePatentCleanItemQueryService service = new AppearancePatentCleanItemQueryService(
|
||||
mapper, adminUserMapper, mock(ShopManageGroupMapper.class));
|
||||
|
||||
when(mapper.countCleanItems(any(), any(), any(), any(), any(), any(), any())).thenReturn(3L);
|
||||
when(mapper.selectCleanItemPage(any(), any(), any(), any(), any(), any(), any(), anyLong(), anyInt()))
|
||||
.thenReturn(List.of(rowEntity(1L, 33L), rowEntity(2L, 44L), rowEntity(3L, 55L)));
|
||||
|
||||
// owner 33=普通账户(role 空,创建人 9=主管甲);owner 44=admin 本人=主管就是自己;
|
||||
// owner 55=库里读不到(users 已删)=不猜名字。
|
||||
AdminUserEntity plainOwner = new AdminUserEntity();
|
||||
plainOwner.setId(33L);
|
||||
plainOwner.setUsername("sub-user-1");
|
||||
plainOwner.setCreatedById(9L);
|
||||
AdminUserEntity adminOwner = new AdminUserEntity();
|
||||
adminOwner.setId(44L);
|
||||
adminOwner.setUsername("leader-b");
|
||||
adminOwner.setRole("admin");
|
||||
AdminUserEntity creator = new AdminUserEntity();
|
||||
creator.setId(9L);
|
||||
creator.setUsername(" 主管甲 ");
|
||||
when(adminUserMapper.selectBatchIds(anyCollection())).thenAnswer(invocation -> {
|
||||
Collection<?> ids = invocation.getArgument(0);
|
||||
List<AdminUserEntity> out = new ArrayList<>();
|
||||
for (Object id : ids) {
|
||||
if (Long.valueOf(33L).equals(id)) out.add(plainOwner);
|
||||
if (Long.valueOf(44L).equals(id)) out.add(adminOwner);
|
||||
if (Long.valueOf(9L).equals(id)) out.add(creator);
|
||||
}
|
||||
return out;
|
||||
});
|
||||
|
||||
AppearancePatentCleanItemPageVo vo = service.page(1L, 10L, null, null, null, null, null, null, null);
|
||||
assertEquals("主管甲", vo.getItems().get(0).getSupervisorName(),
|
||||
"普通账户的主管=创建人(与密钥管理页「所属主管(创建人)」同口径),用户名两侧空白剥掉");
|
||||
assertEquals("leader-b", vo.getItems().get(1).getSupervisorName(),
|
||||
"admin 本人的单主管就是自己,不外指创建人(company_super_admin/super_admin 同支)");
|
||||
assertNull(vo.getItems().get(2).getSupervisorName(),
|
||||
"owner 用户读不到=不猜名字(铁律 30:读不出≠没有)");
|
||||
}
|
||||
|
||||
@Test
|
||||
void 导出xlsx行含主管列与国家中文标签() throws Exception {
|
||||
AppearancePatentCleanItemMapper mapper = mock(AppearancePatentCleanItemMapper.class);
|
||||
AdminUserMapper adminUserMapper = mock(AdminUserMapper.class);
|
||||
AppearancePatentCleanItemQueryService service = new AppearancePatentCleanItemQueryService(
|
||||
mapper, adminUserMapper, mock(ShopManageGroupMapper.class));
|
||||
|
||||
when(mapper.countCleanItems(any(), any(), any(), any(), any(), any(), any())).thenReturn(2L);
|
||||
CleanItemEntity deRow = rowEntity(1L, 33L);
|
||||
deRow.setCountry("DE");
|
||||
CleanItemEntity ukRow = rowEntity(2L, 44L);
|
||||
ukRow.setCountry("UK");
|
||||
ukRow.setSyncedAt(null);
|
||||
when(mapper.selectCleanItemPage(any(), any(), any(), any(), any(), any(), any(), eq(0L), anyInt()))
|
||||
.thenReturn(List.of(deRow, ukRow));
|
||||
AdminUserEntity plainOwner = new AdminUserEntity();
|
||||
plainOwner.setId(33L);
|
||||
plainOwner.setUsername("sub-user-1");
|
||||
plainOwner.setCreatedById(9L);
|
||||
AdminUserEntity adminOwner = new AdminUserEntity();
|
||||
adminOwner.setId(44L);
|
||||
adminOwner.setUsername("leader-b");
|
||||
adminOwner.setRole("admin");
|
||||
AdminUserEntity creator = new AdminUserEntity();
|
||||
creator.setId(9L);
|
||||
creator.setUsername("主管甲");
|
||||
when(adminUserMapper.selectBatchIds(anyCollection())).thenAnswer(invocation -> {
|
||||
Collection<?> ids = invocation.getArgument(0);
|
||||
List<AdminUserEntity> out = new ArrayList<>();
|
||||
for (Object id : ids) {
|
||||
if (Long.valueOf(33L).equals(id)) out.add(plainOwner);
|
||||
if (Long.valueOf(44L).equals(id)) out.add(adminOwner);
|
||||
if (Long.valueOf(9L).equals(id)) out.add(creator);
|
||||
}
|
||||
return out;
|
||||
});
|
||||
|
||||
byte[] bytes = service.export(null, null, null, null, null, null, 5L);
|
||||
try (XSSFWorkbook workbook = new XSSFWorkbook(new ByteArrayInputStream(bytes))) {
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
assertEquals(2, sheet.getLastRowNum(), "表头 + 2 行明细,不多不少");
|
||||
Row header = sheet.getRow(0);
|
||||
assertEquals("任务号", header.getCell(0).getStringCellValue());
|
||||
assertEquals("所属主管", header.getCell(8).getStringCellValue(), "主管列插在结论后、同步时间前");
|
||||
assertEquals("同步时间", header.getCell(9).getStringCellValue());
|
||||
Row row1 = sheet.getRow(1);
|
||||
assertEquals("德国", row1.getCell(2).getStringCellValue(),
|
||||
"国家列落中文标签(与前端 asin-country.ts 字典同表)");
|
||||
assertEquals("33179", row1.getCell(0).getStringCellValue(), "首列是任务号(owner 33 是行属用户,不上表)");
|
||||
assertEquals("主管甲", row1.getCell(8).getStringCellValue(),
|
||||
"普通账户 owner 的主管=创建人(创建人用户名两批查询后命中)");
|
||||
Row row2 = sheet.getRow(2);
|
||||
assertEquals("英国", row2.getCell(2).getStringCellValue());
|
||||
assertEquals("leader-b", row2.getCell(8).getStringCellValue());
|
||||
assertEquals("", row2.getCell(9).getStringCellValue(), "syncedAt 为空落空串,不出 'null' 字样");
|
||||
}
|
||||
}
|
||||
|
||||
/** 导出/分页用例共用的明细行夹具:task 归 owner,值非空便于按列对撞。 */
|
||||
private static CleanItemEntity rowEntity(long id, long userId) {
|
||||
CleanItemEntity entity = new CleanItemEntity();
|
||||
entity.setId(id);
|
||||
entity.setResultId(900 + id);
|
||||
entity.setTaskId(33179L);
|
||||
entity.setUserId(userId);
|
||||
entity.setCompanyId(5L);
|
||||
entity.setRowNo((int) id);
|
||||
entity.setAsin("B0AB8CDEF" + id);
|
||||
entity.setCountry("DE");
|
||||
entity.setSku("SKU-" + id);
|
||||
entity.setBrand("Anker");
|
||||
entity.setPrice("29.99");
|
||||
entity.setTitle("无侵权商品 " + id);
|
||||
entity.setConclusion("无侵权");
|
||||
entity.setSourceFilename("list.xlsx");
|
||||
entity.setSyncedAt(LocalDateTime.of(2026, 11, 11, 10, 30));
|
||||
return entity;
|
||||
}
|
||||
|
||||
private static Path findCleanItemMapperXml() throws IOException {
|
||||
|
||||
+16
-14
@@ -71,7 +71,9 @@ class AppearancePatentCleanSyncRoundTripTest {
|
||||
AppearancePatentCleanSyncService sync = new AppearancePatentCleanSyncService(
|
||||
cleanItemMapper, taskChunkMapper, adminUserMapper, json, storage,
|
||||
mock(org.springframework.transaction.PlatformTransactionManager.class));
|
||||
AppearancePatentCleanItemQueryService query = new AppearancePatentCleanItemQueryService(cleanItemMapper);
|
||||
AppearancePatentCleanItemQueryService query = new AppearancePatentCleanItemQueryService(
|
||||
cleanItemMapper, adminUserMapper,
|
||||
mock(com.nanri.aiimage.common.mapper.ShopManageGroupMapper.class));
|
||||
FileTaskEntity task = task(33001L, 77L);
|
||||
|
||||
// ⓪ 出表未成功(url 未回填):不写任何行,后管查不到
|
||||
@@ -84,7 +86,7 @@ class AppearancePatentCleanSyncRoundTripTest {
|
||||
assertEquals(0, table.rows.get(0).getRowNo(), "row_no 按 payload 全行序号计(含被过滤行)");
|
||||
|
||||
// ② 后管同一查询入口立即可见(超管全量),行值与 payload 一致(AC-1)、synced_at 倒序
|
||||
AppearancePatentCleanItemPageVo vo = query.page(null, null, null, null, null, null, null, null);
|
||||
AppearancePatentCleanItemPageVo vo = query.page(null, null, null, null, null, null, null, null, null);
|
||||
assertEquals(2L, vo.getTotal(), "后管全量 total=2");
|
||||
assertEquals("B0CLEAN002", vo.getItems().get(0).getAsin(), "synced_at 倒序=后同步的在前");
|
||||
assertEquals("英国", vo.getItems().get(0).getCountry());
|
||||
@@ -95,8 +97,8 @@ class AppearancePatentCleanSyncRoundTripTest {
|
||||
assertEquals(7L, vo.getItems().get(0).getCompanyId(), "company_id=任务 owner 公司(物化列)");
|
||||
|
||||
// ③ 分公司隔离:本公司(7)看得见,别家公司(9)看不见
|
||||
assertEquals(2L, query.page(null, null, null, null, null, null, null, 7L).getTotal());
|
||||
assertEquals(0L, query.page(null, null, null, null, null, null, null, 9L).getTotal(),
|
||||
assertEquals(2L, query.page(null, null, null, null, null, null, null, null, 7L).getTotal());
|
||||
assertEquals(0L, query.page(null, null, null, null, null, null, null, null, 9L).getTotal(),
|
||||
"别的公司查不到本公司同步行");
|
||||
|
||||
// ④ 补检重新出表 → 覆盖式重写:首行翻成侵权后全库只剩 1 行(uk(result_id,row_no) 零重复)
|
||||
@@ -104,20 +106,20 @@ class AppearancePatentCleanSyncRoundTripTest {
|
||||
assertEquals(1, table.rows.size(), "覆盖式重写后只剩仍满足严格口径的 1 行");
|
||||
assertEquals(1, table.rows.get(0).getRowNo());
|
||||
assertEquals("B0CLEAN002", table.rows.get(0).getAsin());
|
||||
assertEquals(1L, query.page(null, null, null, null, null, null, null, null).getTotal(),
|
||||
assertEquals(1L, query.page(null, null, null, null, null, null, null, null, null).getTotal(),
|
||||
"重出后后管立即可见新结果面");
|
||||
|
||||
// ⑤ 后管筛选面与 XML 同语义:任务号 eq、ASIN 前缀、同步日期半开区间
|
||||
assertEquals(1L, query.page(null, null, 33001L, null, null, null, null, null).getTotal());
|
||||
assertEquals(0L, query.page(null, null, 99999L, null, null, null, null, null).getTotal());
|
||||
assertEquals(1L, query.page(null, null, null, "B0CLEAN", null, null, null, null).getTotal(),
|
||||
assertEquals(1L, query.page(null, null, 33001L, null, null, null, null, null, null).getTotal());
|
||||
assertEquals(0L, query.page(null, null, 99999L, null, null, null, null, null, null).getTotal());
|
||||
assertEquals(1L, query.page(null, null, null, "B0CLEAN", null, null, null, null, null).getTotal(),
|
||||
"ASIN 前缀命中");
|
||||
assertEquals(0L, query.page(null, null, null, "B0NOPE", null, null, null, null).getTotal());
|
||||
assertEquals(0L, query.page(null, null, null, "B0NOPE", null, null, null, null, null).getTotal());
|
||||
LocalDate syncDay = table.lastSyncedAt.toLocalDate();
|
||||
assertEquals(1L, query.page(null, null, null, null, null, syncDay, syncDay, null).getTotal(),
|
||||
assertEquals(1L, query.page(null, null, null, null, null, syncDay, syncDay, null, null).getTotal(),
|
||||
"同步当天闭区间命中(synced_at < 次日 0 点)");
|
||||
assertEquals(0L, query.page(null, null, null, null, null,
|
||||
syncDay.plusDays(1), syncDay.plusDays(1), null).getTotal(),
|
||||
syncDay.plusDays(1), syncDay.plusDays(1), null, null).getTotal(),
|
||||
"同步日之后的一天查不到");
|
||||
assertTrue(vo.getPage() >= 1 && vo.getPageSize() >= 1, "分页归一形状随行");
|
||||
}
|
||||
@@ -221,13 +223,13 @@ class AppearancePatentCleanSyncRoundTripTest {
|
||||
.thenAnswer(inv -> table.deleteByResultId(inv.getArgument(0, Long.class)));
|
||||
when(mapper.insertBatch(any()))
|
||||
.thenAnswer(inv -> table.insertBatch(inv.getArgument(0)));
|
||||
when(mapper.countCleanItems(any(), any(), any(), any(), any(), any()))
|
||||
when(mapper.countCleanItems(any(), any(), any(), any(), any(), any(), any()))
|
||||
.thenAnswer(inv -> table.count(inv.getArgument(0), inv.getArgument(1), inv.getArgument(2),
|
||||
inv.getArgument(3), inv.getArgument(4), inv.getArgument(5)));
|
||||
when(mapper.selectCleanItemPage(any(), any(), any(), any(), any(), any(), anyLong(), anyInt()))
|
||||
when(mapper.selectCleanItemPage(any(), any(), any(), any(), any(), any(), any(), anyLong(), anyInt()))
|
||||
.thenAnswer(inv -> table.page(inv.getArgument(0), inv.getArgument(1), inv.getArgument(2),
|
||||
inv.getArgument(3), inv.getArgument(4), inv.getArgument(5),
|
||||
inv.getArgument(6, Long.class), inv.getArgument(7, Integer.class)));
|
||||
inv.getArgument(7, Long.class), inv.getArgument(8, Integer.class)));
|
||||
return mapper;
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -171,13 +171,17 @@ class AppearancePatentChunkRowContractTest {
|
||||
assertFalse(flagged.isEmpty(), "扫描空跑=判据失效:LlmClient 自身必须命中");
|
||||
// 结论值唯一来源仍是 LlmClient(NO_INFRINGEMENT 常量);白名单其余条目必须是页面名/文档
|
||||
// 文案,不得出现第二个"造结论"的出处。新增命中必须在此登记并说明为何不产结论值。
|
||||
// 2026-11-11 登记 service/AppearancePatentCleanItemQueryService:导出超上限的业务错误文案
|
||||
// 「无侵权数据共 N 行…」(页面名口径,与控制器 403 文案同族)——不产任何结论值,行集的
|
||||
// conclusion 原样搬运自 payload(toVo 只搬运不加工)。
|
||||
assertIterableEquals(List.of(
|
||||
"client/AppearancePatentLlmClient.java",
|
||||
"controller/AdminAppearancePatentCleanItemsController.java",
|
||||
"model/vo/AppearancePatentCleanItemPageVo.java",
|
||||
"model/vo/AppearancePatentCleanItemVo.java"), new ArrayList<>(flagged),
|
||||
"「无侵权」字面量只许落在登记白名单(LlmClient=结论值单一来源;控制器/VO 命中全是"
|
||||
+ "菜单名/Swagger/403 文案);同步/导出/查询侧产结论值一律引用 NO_INFRINGEMENT 常量,"
|
||||
"model/vo/AppearancePatentCleanItemVo.java",
|
||||
"service/AppearancePatentCleanItemQueryService.java"), new ArrayList<>(flagged),
|
||||
"「无侵权」字面量只许落在登记白名单(LlmClient=结论值单一来源;控制器/VO/查询服务命中全是"
|
||||
+ "菜单名/Swagger/403 文案/导出上限文案);同步/导出/查询侧产结论值一律引用 NO_INFRINGEMENT 常量,"
|
||||
+ "注释里的举例不算(本判据已剥离注释)");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user