外观偏好异步补齐A:用户外观偏好服务端真源(user_appearance 实体+Appearance 三端点)
- 新实体 user_appearance(per-user 一行,theme_state/avatar_style 紧凑编码,NULL=跟随学校默认) - 新增 GET appearance 聚合出参 + saveMyTheme/saveMyAvatarStyle 双写端点(登录态 /api/** 链路) - 聚合读永不抛:个人段/学校段独立降级(identity 跨仓故障→学校段 null),脏值视同未配置 - Logo 择优复用 findLogoList 口径(本校 type=1 → 系统 type=0 → null),URL 拼法对齐 getLogoList - ThemeCodec 编解码下沉 + resolveThemeSchId/resolveSchId 下沉 SchSettingsService(行为等价重构,供共享) - 单测:ThemeCodecTest 5 例 + AppearanceServiceTest 9 例(聚合降级/upsert 置 NULL/择优/校验从严)
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package com.yunhai.userhome.service.impl;
|
||||
|
||||
import com.yunhai.platform.utils.model.BoaUser;
|
||||
import com.yunhai.userhome.entity.SchSettings;
|
||||
import com.yunhai.userhome.entity.UserCurrentRole;
|
||||
import com.yunhai.userhome.repository.SchSettingsRepository;
|
||||
import com.yunhai.userhome.service.ISchSettingsService;
|
||||
import com.yunhai.userhome.service.IUserCurrentRoleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -18,6 +21,9 @@ public class SchSettingsServiceImpl implements ISchSettingsService {
|
||||
@Autowired
|
||||
private SchSettingsRepository schSettingsRepository;
|
||||
|
||||
@Autowired
|
||||
private IUserCurrentRoleService userCurrentRoleService;
|
||||
|
||||
@Override
|
||||
public void save(SchSettings schSettings) {
|
||||
schSettingsRepository.save(schSettings);
|
||||
@@ -46,4 +52,26 @@ public class SchSettingsServiceImpl implements ISchSettingsService {
|
||||
public java.util.List<SchSettings> findBySchIds(java.util.List<Integer> schId) {
|
||||
return schSettingsRepository.getSchSettingList(schId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer resolveSchId(BoaUser user) {
|
||||
if (user.getSchool() != null) {
|
||||
return user.getSchool().getId();
|
||||
}
|
||||
if (user.getBureau() != null) {
|
||||
return user.getBureau().getId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer resolveThemeSchId(BoaUser user, Integer explicitSchId) {
|
||||
if (user.getType() != null && user.getType() == 1) {
|
||||
return explicitSchId == null ? 0 : explicitSchId;
|
||||
}
|
||||
return userCurrentRoleService.findById(user.getId())
|
||||
.map(UserCurrentRole::getSchId)
|
||||
.filter(schId -> schId != null && schId > 0)
|
||||
.orElseGet(() -> resolveSchId(user));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user