fix(appearance): 生效值合成统一紧凑编码——级联命中的 ThemeState JSON 转回 theme|0|1|1 形态
build / build-push (push) Successful in 53s
build / build-push (push) Successful in 53s
线上验证发现:readThemeWithFallback 返回 ThemeState JSON(schTheme 端点口径),而 oapi 契约/init 收敛只认紧凑编码——层间编码不一致会让学校/平台档被 init 当脏值跳过。合成层补 encodeThemeState 转换(读侧宽松:转换失败降 null 不抛)。
This commit is contained in:
@@ -125,7 +125,16 @@ public class AppearanceServiceImpl implements IAppearanceService {
|
||||
String avatar = myAvatar;
|
||||
try {
|
||||
if (theme == null) {
|
||||
theme = schSettingsService.readThemeWithFallback(schId).getValue();
|
||||
// readThemeWithFallback 命中值是 ThemeState JSON(schTheme 端点口径);oapi 契约统一出
|
||||
// 紧凑编码(init 侧 compactThemeToJson 只认紧凑形态),脏值宽松降 null 不抛
|
||||
String hit = schSettingsService.readThemeWithFallback(schId).getValue();
|
||||
if (hit != null) {
|
||||
try {
|
||||
theme = ThemeCodec.encodeThemeState(hit);
|
||||
} catch (DException e) {
|
||||
theme = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (avatar == null) {
|
||||
avatar = schSettingsService.readAvatarWithFallback(schId).getValue();
|
||||
|
||||
@@ -254,18 +254,19 @@ class AppearanceServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("生效值:个人未设 → 学校/平台级联(缺陷 C 修复验证:合成链走 readThemeWithFallback)")
|
||||
@DisplayName("生效值:个人未设 → 学校/平台级联(缺陷 C 修复验证:合成链走 readThemeWithFallback),层间编码统一紧凑形态")
|
||||
void effective_fallsToCascade() {
|
||||
stubCurrentRole(3);
|
||||
when(userAppearanceRepository.findByUserId(10133)).thenReturn(Optional.empty());
|
||||
// 级联命中值是 ThemeState JSON(schTheme 端点口径)——合成层须转回紧凑编码
|
||||
when(schSettingsService.readThemeWithFallback(3))
|
||||
.thenReturn(new ISchSettingsService.LayerValue("ink|0|1|1", 0));
|
||||
.thenReturn(new ISchSettingsService.LayerValue("{\"theme\":\"ink\",\"sideDeep\":false,\"gradOn\":true,\"sideFollow\":false}", 0));
|
||||
when(schSettingsService.readAvatarWithFallback(3))
|
||||
.thenReturn(new ISchSettingsService.LayerValue("text", 3));
|
||||
when(logoRepository.findBySchIdAndType(any(), any())).thenReturn(Collections.emptyList());
|
||||
|
||||
Map<String, Object> out = service.getEffectiveAppearance(10133);
|
||||
assertEquals("ink|0|1|1", out.get("theme"), "本校空回落平台档(hitSchId=0)");
|
||||
assertEquals("ink|0|1|0", out.get("theme"), "级联 JSON 转紧凑编码,init 侧才可收敛");
|
||||
assertEquals("text", out.get("avatar"), "本校已配直接生效(hitSchId=本校)");
|
||||
// 出参只三字段,不外露 my/sch 拆分
|
||||
assertTrue(out.containsKey("theme") && out.containsKey("avatar") && out.containsKey("logoUrl"));
|
||||
|
||||
Reference in New Issue
Block a user