feat(admin): 公司tab条按平台分侧+京东分组作用域只认jd档(2026-11-17 用户口径「亚马逊侧别挂京东-团队,同理京东那边也是」)
- company-tab store:目录按当前平台 tab 拉(loadedPlatform 对撞早退),切台重拉;旧选中仍在新清单则保住,不在回落 id 最小启用公司;新增 refresh() 强制档(公司翻档/启停后 18 页 tab 条同步)
This commit is contained in:
+77
-1
@@ -30,7 +30,8 @@ import static org.mockito.Mockito.when;
|
||||
/**
|
||||
* 京东数据库分类「当前分组」作用域判据(V203;2026-11-16 用户口径)。
|
||||
*
|
||||
* <p>四档矩阵:平台超管=全部公司全部组可读可写;公司超管=本公司全部组;
|
||||
* <p>四档矩阵(2026-11-17 起各档可见集最后统一过「只留京东档 platform='jd' 分组」的平台闸):
|
||||
* 平台超管=全部公司全部组可读可写;公司超管=本公司全部组;
|
||||
* 管理员(组长)=自己带的组可写、自己所属组的组长带的分组只读;
|
||||
* 普通号=与管理员同可见、<b>零可写</b>(能开弹窗看,不能增删改分类、不能归类)。
|
||||
* 另钉三条收敛语义:不可见组读 403(不做空结果降级)、无分组上下文读回 null(页面照常可用)、
|
||||
@@ -86,6 +87,70 @@ class JdCategoryScopeServiceTest {
|
||||
assertThat(scope.canWrite(20L)).isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 2026-11-17 用户口径「同理京东那边也是」:京东侧下拉只认京东档(platform='jd')分组。
|
||||
* 亚马逊档与 NULL 档(未翻档的存量)一律滤掉,可写集跟着收缩;过滤后只剩一家公司 ⇒
|
||||
* 组名不带公司前缀(既有「单公司不啰嗦」口径不变)。
|
||||
*/
|
||||
@Test
|
||||
void 平台超管_只显示京东档分组_亚马逊档与NULL档不进下拉() {
|
||||
AdminUserEntity operator = user(USER_ID, COMPANY_ID);
|
||||
when(adminAuthSupport.currentRole(operator)).thenReturn("super_admin");
|
||||
when(dataReadScope.isPlatformSuperAdmin(operator)).thenReturn(true);
|
||||
when(shopManageGroupMapper.selectAllGroups()).thenReturn(List.of(
|
||||
group(10L, 1L, "A组"),
|
||||
amazonGroup(20L, 2L, "B组"),
|
||||
groupOfPlatform(30L, 3L, "C组", null)));
|
||||
CompanyEntity first = new CompanyEntity();
|
||||
first.setId(1L);
|
||||
first.setCompanyName("甲公司");
|
||||
when(companyMapper.selectBatchIds(any())).thenReturn(List.of(first));
|
||||
|
||||
JdCategoryScopeService.JdCategoryScope scope = service.resolve(operator);
|
||||
|
||||
assertThat(scope.visibleGroupIds()).containsExactly(10L);
|
||||
assertThat(scope.writableGroupIds()).containsExactly(10L);
|
||||
assertThat(scope.defaultGroupId()).isEqualTo(10L);
|
||||
assertThat(scope.groups()).extracting(JdCategoryGroupOptionVo::getLabel)
|
||||
.containsExactly("A组");
|
||||
// 亚马逊档组读/写双拒(不是 403,是压根不可见)。
|
||||
assertThat(scope.canRead(20L)).isFalse();
|
||||
assertThat(scope.canWrite(20L)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void 公司超管_本公司亚马逊档组同样被滤掉() {
|
||||
AdminUserEntity operator = user(USER_ID, COMPANY_ID);
|
||||
when(adminAuthSupport.currentRole(operator)).thenReturn("company_super_admin");
|
||||
when(dataReadScope.isPlatformSuperAdmin(operator)).thenReturn(false);
|
||||
when(shopManageGroupMapper.selectList(any())).thenReturn(List.of(
|
||||
group(10L, COMPANY_ID, "A组"), amazonGroup(11L, COMPANY_ID, "B组")));
|
||||
|
||||
JdCategoryScopeService.JdCategoryScope scope = service.resolve(operator);
|
||||
|
||||
assertThat(scope.visibleGroupIds()).containsExactly(10L);
|
||||
assertThat(scope.writableGroupIds()).containsExactly(10L);
|
||||
assertThat(scope.groups()).extracting(JdCategoryGroupOptionVo::getLabel)
|
||||
.containsExactly("A组");
|
||||
verify(companyMapper, never()).selectBatchIds(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void 组长_带的组全是亚马逊档时空作用域不报错() {
|
||||
AdminUserEntity operator = user(USER_ID, COMPANY_ID);
|
||||
when(adminAuthSupport.currentRole(operator)).thenReturn("admin");
|
||||
when(dataReadScope.isPlatformSuperAdmin(operator)).thenReturn(false);
|
||||
when(shopManageGroupMapper.selectLedGroups(USER_ID))
|
||||
.thenReturn(List.of(amazonGroup(10L, COMPANY_ID, "自己的组")));
|
||||
when(shopManageGroupMapper.selectLeaderIdsByMemberUserId(USER_ID)).thenReturn(List.of());
|
||||
|
||||
JdCategoryScopeService.JdCategoryScope scope = service.resolve(operator);
|
||||
|
||||
assertThat(scope.visibleGroupIds()).isEmpty();
|
||||
assertThat(scope.writableGroupIds()).isEmpty();
|
||||
assertThat(scope.defaultGroupId()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void 公司超管_本公司全部组可读可写() {
|
||||
AdminUserEntity operator = user(USER_ID, COMPANY_ID);
|
||||
@@ -319,10 +384,20 @@ class JdCategoryScopeServiceTest {
|
||||
}
|
||||
|
||||
private static ShopManageGroupEntity group(long id, long companyId, String name) {
|
||||
return groupOfPlatform(id, companyId, name, "jd");
|
||||
}
|
||||
|
||||
/** 亚马逊档组(V206 存量默认档):2026-11-17 起不进京东侧作用域。 */
|
||||
private static ShopManageGroupEntity amazonGroup(long id, long companyId, String name) {
|
||||
return groupOfPlatform(id, companyId, name, "amazon");
|
||||
}
|
||||
|
||||
private static ShopManageGroupEntity groupOfPlatform(long id, long companyId, String name, String platform) {
|
||||
ShopManageGroupEntity group = new ShopManageGroupEntity();
|
||||
group.setId(id);
|
||||
group.setCompanyId(companyId);
|
||||
group.setGroupName(name);
|
||||
group.setPlatform(platform);
|
||||
return group;
|
||||
}
|
||||
|
||||
@@ -331,6 +406,7 @@ class JdCategoryScopeServiceTest {
|
||||
ShopManageGroupEntity group = new ShopManageGroupEntity();
|
||||
group.setId(id);
|
||||
group.setGroupName(name);
|
||||
group.setPlatform("jd");
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user