logo,壁纸修复,加入小应用管理,样式待调整
build / build-push (push) Successful in 2m11s

This commit is contained in:
chenxing
2026-08-28 14:24:46 +08:00
parent 567c8b7786
commit 759b120f2a
22 changed files with 813 additions and 163 deletions
@@ -1,22 +1,16 @@
package com.yunhai.userhome.service.impl;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yunhai.userhome.entity.SchSettings;
import com.yunhai.userhome.repository.SchSettingsRepository;
import com.yunhai.userhome.service.ISchSettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.Optional;
/**
* 学校设置服务:行为对齐旧 UserHome SchSettingsService。
* <p>关键:{@code findBySchId} 不查本地表,而是跨仓调用 {@code SCH_CONF_URL/oapi/getSchSetting},
* 旧版如此(schConfig 服务为 homeImgUrl/isEnableDesktop/isLinkDesktop 等字段的权威来源),
* 因此本地 sch_settings 表变更类能力(saveSchTheme/saveSchLogo)本期仅保留 P1 占位写入本地表。</p>
* 学校设置服务:学校设置完全本地化(sch_settings 表),不再依赖跨仓 schConfig。
* <p>findBySchId 直接查本地表,查不到兜底默认主题;saveSchTheme/saveSchLogo 写本地表即可闭环。</p>
*/
@Service
public class SchSettingsServiceImpl implements ISchSettingsService {
@@ -24,12 +18,6 @@ public class SchSettingsServiceImpl implements ISchSettingsService {
@Autowired
private SchSettingsRepository schSettingsRepository;
@Value("${SCH_CONF_URL:}")
private String schConfUrl;
private final RestTemplate restTemplate = new RestTemplate();
private final ObjectMapper objectMapper = new ObjectMapper();
@Override
public void save(SchSettings schSettings) {
schSettingsRepository.save(schSettings);
@@ -37,41 +25,16 @@ public class SchSettingsServiceImpl implements ISchSettingsService {
@Override
public Optional<SchSettings> findBySchId(Integer schId) {
SchSettings model = new SchSettings();
try {
if (schConfUrl == null || schConfUrl.isEmpty()) {
return Optional.of(localFallbackBySchId(schId));
}
String apiPath = schConfUrl + "/oapi/getSchSetting?schId=" + schId;
String resultStr = restTemplate.getForObject(apiPath, String.class);
if (resultStr == null || resultStr.isEmpty()) {
return Optional.of(localFallbackBySchId(schId));
}
JsonNode root = objectMapper.readTree(resultStr);
JsonNode dataNode = root.get("data");
if (root.has("code") && "0".equals(root.get("code").asText()) && dataNode != null && !dataNode.isNull()) {
model = objectMapper.convertValue(dataNode, SchSettings.class);
} else {
return Optional.of(localFallbackBySchId(schId));
}
} catch (Exception e) {
return Optional.of(localFallbackBySchId(schId));
}
return Optional.of(model);
}
/** 跨仓不通时先查本地表,再兜底默认主题(对齐旧版异常分支)。 */
private SchSettings localFallbackBySchId(Integer schId) {
Optional<SchSettings> local = schSettingsRepository.findFirstBySchId(schId);
if (local.isPresent()) {
return local.get();
return local;
}
SchSettings def = new SchSettings();
def.setSchId(schId);
def.setThemeName("default-theme");
def.setAppBgUrl("");
def.setLogoUrl("");
return def;
return Optional.of(def);
}
@Override