feat(appearance-patent): 顶部全量「导出」摘掉+每张主管卡加「删除」(2026-11-11 客户「这个可以不要 有下载就行了」「也要加个删除按钮」)
删除走新 DELETE /api/admin/appearance-patent-clean-items/supervisors?supervisor_user_id=…:谓词与卡片「下载」逐字同源(共享 cleanItemConds + supervisorScopeConds,Same SQL 下推),所见即所删;supervisor_user_id 必填、服务侧先挡空值(缺值会让 <if> 不生效=退化成整表删除),日期倒挂同全站口径拒;同一 requireCleanItemsAccess+readCompanyIdOrOwn 正门(非超管只能删本公司行),并打一条带 operatorId/主管/过滤面/删除行数的日志留痕;只删快照明细,不碰结果文件与任务记录。前端破坏性动作先 openAdminConfirm(点名主管与条数、danger),删完回读并在删掉本页最后一张卡时回退页;读不到主管的卡两钮都禁用。护栏:XML_STATEMENT_TOTAL 155→156、NOT_MIGRATED 登记 deleteSupervisorItems、controller 只读判据改为「无 POST/PUT+DELETE 必须在位」、wiring 新增第 4 个发送口(26 处/19 组)。
This commit is contained in:
+38
-4
@@ -20,10 +20,12 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -34,10 +36,11 @@ import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* 后管「外观专利无侵权数据」只读页(v1.3 R2/R3)。数据由出表成功点自动同步落表
|
||||
* ({@code AppearancePatentCleanSyncService}),本页只读——无写/删接口,下载走既有结果直链/
|
||||
* 任务中心;另有 GET 导出端点(2026-11-11 客户需求「数据得导出来」):与分页查询同一过滤面
|
||||
* (含公司隔离正门),服务侧卡导出上限,主管列为读侧现算列,无写/删/导入;分组筛选同日落地
|
||||
* 后管「外观专利无侵权数据」页(v1.3 R2/R3)。数据由出表成功点自动同步落表
|
||||
* ({@code AppearancePatentCleanSyncService}),本页不出表、不改明细内容——下载走导出端点、
|
||||
* 删除走 {@code DELETE /supervisors}(2026-11-11 客户「也要加个删除按钮」,按主管删快照明细行,
|
||||
* 不碰结果文件与任务记录);另有 GET 导出端点(2026-11-11 客户需求「数据得导出来」):与分页查询
|
||||
* 同一过滤面(含公司隔离正门),服务侧卡导出上限,主管列为读侧现算列,无导入;分组筛选同日落地
|
||||
* (客户口径「主管就是组长,可以筛选组长来导出,就是分组」)——group_id 参数(biz_shop_manage_group.id)
|
||||
* 在分页与导出同面生效,服务侧按 selectUserIdsByGroupId 解析「组长本人+名下子账户」整集后
|
||||
* SQL 侧下推;下拉选项复用既有 GET /shop-manages/groups(与去重页/店铺管理同源),不下新端点。
|
||||
@@ -48,6 +51,7 @@ import java.time.format.DateTimeFormatter;
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@RequestMapping("/api/admin/appearance-patent-clean-items")
|
||||
@Tag(name = "外观专利无侵权数据", description = "后管只读页:出表成功自动同步的「结论=无侵权」明细,按分公司隔离分页查询与导出。")
|
||||
public class AdminAppearancePatentCleanItemsController {
|
||||
@@ -157,6 +161,36 @@ public class AdminAppearancePatentCleanItemsController {
|
||||
.body(bytes);
|
||||
}
|
||||
|
||||
@DeleteMapping("/supervisors")
|
||||
@Operation(summary = "删除某位主管名下的外观专利数据库明细", description = "卡片上的「删除」(2026-11-11 客户"
|
||||
+ "「也要加个删除按钮」):谓词与卡片「下载」逐字同源(同一过滤面+同一主管归属表达式),"
|
||||
+ "supervisor_user_id 必填——缺值不按主管收窄就等于删整个过滤面,直接按业务错误拒绝。"
|
||||
+ "只删快照明细行,不动结果文件与任务记录。返回实际删除行数。")
|
||||
public ApiResponse<Integer> deleteBySupervisor(
|
||||
@Parameter(description = "主管用户 id(必填,卡片归属口径)")
|
||||
@RequestParam(name = "supervisor_user_id") Long supervisorUserId,
|
||||
@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();
|
||||
// 删除与查询/导出同一公司隔离正门:非超管只能删本公司的行(忽略请求传参)。
|
||||
Long scopedCompanyId = dataReadScope.readCompanyIdOrOwn(user, companyId);
|
||||
int deleted = cleanItemQueryService.deleteBySupervisor(supervisorUserId, country, startDate, endDate,
|
||||
groupId, scopedCompanyId);
|
||||
// 管理端真删必须留痕(谁、删了哪位主管、什么过滤面、删了多少行):日志是唯一的取证面。
|
||||
log.info("[appearance-patent-clean] 按主管删除明细 operatorId={} supervisorUserId={} country={} "
|
||||
+ "start={} end={} groupId={} companyId={} deleted={}",
|
||||
operator.id(), supervisorUserId, country, startDate, endDate, groupId, scopedCompanyId, deleted);
|
||||
return ApiResponse.success(deleted);
|
||||
}
|
||||
|
||||
private RequestOperator requireCleanItemsAccess(HttpServletRequest request) {
|
||||
AdminUserEntity operator = resolveOperator(request);
|
||||
if (operator == null || operator.getId() == null || operator.getId() <= 0) {
|
||||
|
||||
+16
@@ -111,4 +111,20 @@ public interface AppearancePatentCleanItemMapper extends BaseMapper<CleanItemEnt
|
||||
@Param("supervisorUserId") Long supervisorUserId,
|
||||
@Param("offset") long offset,
|
||||
@Param("limit") int limit);
|
||||
|
||||
/**
|
||||
* 删除单个主管名下明细(2026-11-11 卡片上的「删除」)。
|
||||
*
|
||||
* <p>谓词与 {@link #selectSupervisorItems} 逐字同源(共享 {@code cleanItemConds} +
|
||||
* {@code supervisorScopeConds}):所见即所删。{@code supervisorUserId} 为 null 时那条
|
||||
* {@code <if>} 不生效=退化成整表删除,所以调用方(Service)必须先挡空值。</p>
|
||||
*/
|
||||
int deleteSupervisorItems(@Param("companyId") Long companyId,
|
||||
@Param("taskId") Long taskId,
|
||||
@Param("asin") String asin,
|
||||
@Param("country") String country,
|
||||
@Param("startDate") LocalDate startDate,
|
||||
@Param("endDate") LocalDate endDate,
|
||||
@Param("userIds") List<Long> userIds,
|
||||
@Param("supervisorUserId") Long supervisorUserId);
|
||||
}
|
||||
|
||||
+31
@@ -301,6 +301,37 @@ public class AppearancePatentCleanItemQueryService {
|
||||
return writeExportWorkbook(items);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除<b>单个主管</b>名下明细(2026-11-11 客户「也要加个删除按钮」):谓词与
|
||||
* {@link #exportBySupervisor} 逐字同源(同一过滤面 + 同一归属表达式),所以「看到的条数」
|
||||
* 与「删掉的条数」不会分叉。
|
||||
*
|
||||
* <p>{@code supervisorUserId} 必须是显式传入的主管 id:SQL 里那条 {@code <if>} 缺值时不生效,
|
||||
* 等于删掉整个过滤面(最坏是全表),所以这里先挡空值/非法值并抛业务错误——宁可拒绝,不接
|
||||
* 「不按主管收窄的删除」。本方法只删快照明细行,不碰结果文件与任务记录(与同步链的
|
||||
* {@code deleteByResultId} 覆盖式重写互不影响:下一次同步会按 result_id 重新写入)。</p>
|
||||
*
|
||||
* @return 实际删除行数(前端拿它做「已删除 N 条」的反馈,不猜)
|
||||
*/
|
||||
public int deleteBySupervisor(Long supervisorUserId, String country, LocalDate startDate,
|
||||
LocalDate endDate, Long groupId, Long scopedCompanyId) {
|
||||
if (supervisorUserId == null || supervisorUserId <= 0) {
|
||||
throw new BusinessException("缺少主管,无法按主管删除");
|
||||
}
|
||||
if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
|
||||
throw new BusinessException("开始日期不能晚于结束日期");
|
||||
}
|
||||
Long companyId = scopedCompanyId != null && scopedCompanyId > 0 ? scopedCompanyId : null;
|
||||
String safeCountry = trimToNull(country);
|
||||
List<Long> groupUserIds = groupUserIds(groupId);
|
||||
if (groupUserIds != null && groupUserIds.isEmpty()) {
|
||||
// 与导出同口径:分组解析不出用户集 ⇒ 过滤面本身是空的,没有可删的行。
|
||||
return 0;
|
||||
}
|
||||
return cleanItemMapper.deleteSupervisorItems(companyId, null, null, safeCountry, startDate, endDate,
|
||||
groupUserIds, supervisorUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组筛选 → 该分组「组长本人+名下子账户」的用户 id 集({@code null} = 没选分组、不过滤);
|
||||
* id 非法(≤0)按没选处理,不把它当全量之外的第三档。解析交给
|
||||
|
||||
Reference in New Issue
Block a user