feat(账号到期+公司超管): 级联过期判定、过期停任务巡检与两端续费提醒弹窗
需求两条:站点超管可开设其他公司的超级管理员(站点超管看全站、公司超管只看本公司、 组内管理员仍只看本组);账号要有过期时间,管理员过期后名下普通账户一并停用、 正在跑的任务也要停掉。落库只有 users.expires_at(V146,NULL=永不过期),级联一律现算, 不写"上级过期就把下级置成过期"那种续费也救不回来的数据。 - AccountExpiryService:生效到期 = min(自身, 本公司公司超管, 成员表组长, 创建人)。 登录拦 403(文案给续费提示)、每次请求鉴权拦 401(前端按下线踢回登录页),super_admin 永不适用。级联口径与数据可见范围同源(成员表基本未用、实际按 created_by_id 派生)。 - ExpiredAccountTaskStopService:每分钟把过期账号(含级联成员)名下 biz_file_task PENDING/SCHEDULED/RUNNING → FAILED,含未领取的 PENDING(防内部通道继续派发)。原因文案 刻意不以「客户端异常中断」开头,否则会被 TaskResumeService 自动复活。品牌采集与跟价循环 不在那张表上,经 ExpiredAccountTaskStopSpi 由各自模块停:品牌 pending/running→cancelled 且 UPDATE 的 WHERE 二次核对状态(抢到行后被客户端推进成完成的行不得误杀),跟价循环只置 stop_requested=1、沿用用户点「停止循环」那条收尾路径,绝不动 status。任务心跳接口保持匿名 不走 requireUser,所以过期账号的客户端仍能拿到 alive=false 协作停止。 - 角色 company_super_admin:由站点超管开设(唯一要显式选公司的建号场景),建号/授菜单/改用户/ 看数据四条链路都按"本公司"收口;公司超管之间、以及公司超管与站点超管互相碰不得。 - 续费提醒:剩余 <5 天在数富后台与用户端弹窗,只能收起不能关闭(无关闭按钮,收起态是右下角 浮标),续费到 ≥5 天自动消失。后台读 /api/admin/current-user 的 expiresAt/daysToExpire; 用户端无 Pinia,走 localStorage 的 account_expires_at(登录/check_login 落键、被顶下线清键, 换账号不残留)。只反映账号自身到期,弹窗不做任何级联推断。 - V146 撞掉了 V145 那批的一条护栏:它按"db/ 里不许出现 V146__ 前缀"编死号位,被一条正常的 前向迁移占用就红。改成钉动作——剥注释后的可执行 SQL 不得写 flyway_schema_history(回滚 一律是扫描路径外的人工补丁),并把盘点文档改 V146 时丢掉的 V145 文件名补回去。 验证(本会话亲跑,不是转述):后端定向 14 类 123/0(同一轮 mvn 里连批次③的 4 类 53 例、以及既有 ShopDataCrawl/SimilarAsin 两条回归对照 21 例一起跑,合计 197 例 0 红);admin-frontend-vue 本批定向 44/0(弹窗 7 + 公司建号/列表/入口/日期默认 21 + 角色 task-48/task-251 16),全量 1726 例里那 1 支红是另一条 会话刻意留的「公司 tab 接线缺口」尺子(点名 admin_task_center 等 6 页,与本批无关); frontend-vue 弹窗 9/0、全量 710/0。变异自证两批共 34 点:弹窗语义 16 点全杀(阈值 5、只能收起 不能关闭、挂载点含"注释掉挂载"、落键/清键链路),本批 SPI+迁移护栏 17 点全杀(含 G2 反向: 前向迁移只在注释里提 flyway_schema_history 必须照样绿),注入文件还原 dirty=0、探针残留 0。
This commit is contained in:
+29
-3
@@ -19,6 +19,7 @@ import com.nanri.aiimage.common.mapper.AdminUserMapper;
|
||||
import com.nanri.aiimage.common.model.entity.AdminUserEntity;
|
||||
import com.nanri.aiimage.common.mapper.ShopManageGroupMapper;
|
||||
import com.nanri.aiimage.common.model.entity.ShopManageGroupEntity;
|
||||
import com.nanri.aiimage.common.service.CompanyScopeSupport;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
@@ -80,6 +81,7 @@ public class DedupeTotalDataService {
|
||||
private final DedupeTotalDataMapper dedupeTotalDataMapper;
|
||||
private final AdminUserMapper adminUserMapper;
|
||||
private final ShopManageGroupMapper shopManageGroupMapper;
|
||||
private final CompanyScopeSupport companyScopeSupport;
|
||||
private final PlatformTransactionManager transactionManager;
|
||||
|
||||
// 2026-09 全维度审查 D2:进度/归属/分组改由 NodeSharedStore 承载(本地快路径 + Redis 跨节点),
|
||||
@@ -96,12 +98,14 @@ public class DedupeTotalDataService {
|
||||
public DedupeTotalDataService(DedupeTotalDataMapper dedupeTotalDataMapper,
|
||||
AdminUserMapper adminUserMapper,
|
||||
ShopManageGroupMapper shopManageGroupMapper,
|
||||
CompanyScopeSupport companyScopeSupport,
|
||||
PlatformTransactionManager transactionManager,
|
||||
org.springframework.data.redis.core.StringRedisTemplate stringRedisTemplate,
|
||||
ObjectMapper objectMapper) {
|
||||
this.dedupeTotalDataMapper = dedupeTotalDataMapper;
|
||||
this.adminUserMapper = adminUserMapper;
|
||||
this.shopManageGroupMapper = shopManageGroupMapper;
|
||||
this.companyScopeSupport = companyScopeSupport;
|
||||
this.transactionManager = transactionManager;
|
||||
this.importProgressMap = progressStore("aiimage:dedupe:import:progress", stringRedisTemplate, objectMapper);
|
||||
this.deleteImportProgressMap = progressStore("aiimage:dedupe:delete-import:progress", stringRedisTemplate, objectMapper);
|
||||
@@ -1179,7 +1183,18 @@ public class DedupeTotalDataService {
|
||||
private AccessScope resolveAccessScope(Long operatorId) {
|
||||
AdminUserEntity operator = getOperator(operatorId);
|
||||
if (isSuperAdmin(operator)) {
|
||||
return new AccessScope(true, Set.of(), Set.of());
|
||||
return new AccessScope(true, Set.of(), Set.of(), false);
|
||||
}
|
||||
if ("company_super_admin".equals(operator.getRole() == null
|
||||
? "" : operator.getRole().trim().toLowerCase(Locale.ROOT))) {
|
||||
LinkedHashSet<Long> companyUserIds = new LinkedHashSet<>();
|
||||
companyUserIds.add(operator.getId());
|
||||
for (Long memberId : companyScopeSupport.memberUserIds(operator.getCompanyId())) {
|
||||
if (memberId != null && memberId > 0) {
|
||||
companyUserIds.add(memberId);
|
||||
}
|
||||
}
|
||||
return new AccessScope(false, Set.of(), Set.copyOf(companyUserIds), true);
|
||||
}
|
||||
List<Long> accessibleGroupIds = shopManageGroupMapper.selectAccessibleGroupIds(operator.getId());
|
||||
LinkedHashSet<Long> visibleUserIds = new LinkedHashSet<>();
|
||||
@@ -1201,7 +1216,8 @@ public class DedupeTotalDataService {
|
||||
return new AccessScope(
|
||||
false,
|
||||
Set.copyOf(accessibleGroupIds == null ? List.of() : accessibleGroupIds),
|
||||
Set.copyOf(visibleUserIds));
|
||||
Set.copyOf(visibleUserIds),
|
||||
false);
|
||||
}
|
||||
|
||||
private void applyGroupScope(LambdaQueryWrapper<DedupeTotalDataEntity> query,
|
||||
@@ -1221,6 +1237,11 @@ public class DedupeTotalDataService {
|
||||
if (scope.allUsers()) {
|
||||
return;
|
||||
}
|
||||
if (scope.wholeCompany()) {
|
||||
// 公司超管:整家公司成员上传的行全可见,不再按 group_id 切
|
||||
query.in(DedupeTotalDataEntity::getUploaderUserId, scope.userIds());
|
||||
return;
|
||||
}
|
||||
query.and(wrapper -> {
|
||||
if (!scope.groupIds().isEmpty()) {
|
||||
wrapper.in(DedupeTotalDataEntity::getGroupId, scope.groupIds())
|
||||
@@ -1402,6 +1423,11 @@ public class DedupeTotalDataService {
|
||||
return vo;
|
||||
}
|
||||
|
||||
private record AccessScope(boolean allUsers, Set<Long> groupIds, Set<Long> userIds) {
|
||||
/**
|
||||
* @param allUsers 超管直通
|
||||
* @param wholeCompany 公司超管:不做分组维度裁剪,userIds = 本公司全体成员,
|
||||
* 查询条件退化为 uploader_user_id IN (成员)——公司超管的"组"就是整家公司
|
||||
*/
|
||||
private record AccessScope(boolean allUsers, Set<Long> groupIds, Set<Long> userIds, boolean wholeCompany) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user