feat(admin): 公司tab条按平台分侧+京东分组作用域只认jd档(2026-11-17 用户口径「亚马逊侧别挂京东-团队,同理京东那边也是」)

- company-tab store:目录按当前平台 tab 拉(loadedPlatform 对撞早退),切台重拉;旧选中仍在新清单则保住,不在回落 id 最小启用公司;新增 refresh() 强制档(公司翻档/启停后 18 页 tab 条同步)
This commit is contained in:
2026-11-17 11:50:13 +08:00
parent dc3e7f3b37
commit ee613db05b
7 changed files with 307 additions and 46 deletions
@@ -8,6 +8,7 @@ import com.nanri.aiimage.common.model.entity.AdminUserEntity;
import com.nanri.aiimage.common.model.entity.ShopManageGroupEntity;
import com.nanri.aiimage.common.security.AdminAuthSupport;
import com.nanri.aiimage.common.security.DeviceSessionPolicy;
import com.nanri.aiimage.common.service.AdminPlatformScope;
import com.nanri.aiimage.common.service.DataReadScope;
import com.nanri.aiimage.modules.company.mapper.CompanyMapper;
import com.nanri.aiimage.modules.company.model.entity.CompanyEntity;
@@ -27,11 +28,13 @@ import java.util.Set;
* 京东数据库分类的「当前分组」作用域解析(V203,2026-11-16 用户口径)。
*
* <p>口径:「组」=公司内的<b>数据权限分组</b>({@code biz_shop_manage_group}),公司→组两级隔离。
* 四档:</p>
* 2026-11-17 用户口径「同理京东那边也是」加一条平台闸:<b>只有京东档({@code platform='jd'},
* V206 列)的分组才进京东侧作用域</b>——亚马逊档与 NULL 一律不进下拉(四档角色先各自圈完
* 可见集,最后统一过这道闸)。四档:</p>
* <ul>
* <li><b>平台超管</b>:全部公司全部组可读可写;</li>
* <li><b>公司超管</b>:本公司全部组可读可写(与「公司超管看本公司全部成员」同源);</li>
* <li><b>管理员(组长)</b>:可见=自己带的组 + 自己所属组的组长;可写=自己带的组;</li>
* <li><b>平台超管</b>:全部公司全部<b>京东档</b>组可读可写;</li>
* <li><b>公司超管</b>:本公司全部<b>京东档</b>组可读可写(与「公司超管看本公司全部成员」同源);</li>
* <li><b>管理员(组长)</b>:可见=自己带的组 + 自己所属组的组长(过平台闸后);可写=自己带的组;</li>
* <li><b>普通号</b>:可见同上,可写空(能开弹窗看,不能增删改分类、不能归类)。</li>
* </ul>
*
@@ -144,39 +147,49 @@ public class JdCategoryScopeService {
String role = adminAuthSupport.currentRole(user);
Map<Long, ShopManageGroupEntity> visible = new LinkedHashMap<>();
Set<Long> writable = new LinkedHashSet<>();
if (dataReadScope.isPlatformSuperAdmin(user)) {
boolean platformSuperAdmin = dataReadScope.isPlatformSuperAdmin(user);
if (platformSuperAdmin) {
collect(visible, shopManageGroupMapper.selectAllGroups());
writable.addAll(visible.keySet());
return assemble(true, user.getCompanyId(), visible, writable);
}
if (DeviceSessionPolicy.isCompanySuperAdmin(role)) {
} else if (DeviceSessionPolicy.isCompanySuperAdmin(role)) {
Long companyId = user.getCompanyId();
if (companyId != null && companyId > 0) {
collect(visible, companyGroups(companyId));
writable.addAll(visible.keySet());
}
return assemble(false, companyId, visible, writable);
}
// 管理员(组长):自己带的组可写;自己所属组的组长带的分组只读可见。
List<ShopManageGroupEntity> led = ledGroups(user.getId());
collect(visible, led);
if ("admin".equals(role)) {
for (ShopManageGroupEntity group : led) {
if (group.getId() != null) {
writable.add(group.getId());
} else {
// 管理员(组长):自己带的组可写;自己所属组的组长带的分组只读可见。
List<ShopManageGroupEntity> led = ledGroups(user.getId());
collect(visible, led);
if ("admin".equals(role)) {
for (ShopManageGroupEntity group : led) {
if (group.getId() != null) {
writable.add(group.getId());
}
}
}
if (user.getCreatedById() != null && user.getCreatedById() > 0) {
collect(visible, ledGroups(user.getCreatedById()));
}
List<Long> memberOfLeaders = shopManageGroupMapper.selectLeaderIdsByMemberUserId(user.getId());
if (memberOfLeaders != null) {
for (Long leaderId : memberOfLeaders) {
collect(visible, ledGroups(leaderId));
}
}
}
if (user.getCreatedById() != null && user.getCreatedById() > 0) {
collect(visible, ledGroups(user.getCreatedById()));
}
List<Long> memberOfLeaders = shopManageGroupMapper.selectLeaderIdsByMemberUserId(user.getId());
if (memberOfLeaders != null) {
for (Long leaderId : memberOfLeaders) {
collect(visible, ledGroups(leaderId));
}
}
return assemble(false, user.getCompanyId(), visible, writable);
// 2026-11-17 用户口径「同理京东那边也是」:京东侧作用域只认京东档(platform='jd')的
// 数据权限分组——亚马逊档与 NULL 一律不进下拉。V206 存量默认 amazon、京东侧数据由编辑
// 弹窗翻档,这里不做「NULL/缺列当 jd」的宽判:宽了会把没翻档的存量整批带进京东侧,
// 等于平台分侧白做。
retainJdPlatformGroups(visible, writable);
return assemble(platformSuperAdmin, user.getCompanyId(), visible, writable);
}
/** 只留京东档分组,并让可写集跟着可见集收缩(writable ⊆ visible 的既有不变量保持)。 */
private static void retainJdPlatformGroups(Map<Long, ShopManageGroupEntity> visible, Set<Long> writable) {
visible.values().removeIf(group -> !AdminPlatformScope.JD.equals(group.getPlatform()));
writable.retainAll(visible.keySet());
}
private List<ShopManageGroupEntity> companyGroups(Long companyId) {