更新数字基座
build / build-push (push) Successful in 1m3s

This commit is contained in:
chenxing
2026-08-24 09:29:31 +08:00
parent 4ed43dbc05
commit a7539a4cf0
48 changed files with 2983 additions and 3 deletions
@@ -0,0 +1,84 @@
package com.yunhai.userhome.controller.api;
import com.yunhai.platform.utils.model.BoaUser;
import com.yunhai.userhome.config.Config;
import com.yunhai.userhome.entity.SchSettings;
import com.yunhai.userhome.service.ISchSettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.Optional;
/**
* 学校设置接口(CAS 登录态,路径 {@code /{platform}/}),对齐旧 UserHome SchSettingsController。
* <p>getSchSettings 实际跨仓调用 schConfig(见 SchSettingsServiceImpl);
* saveSchTheme/saveSchLogo(P1)本期写入本地 sch_settings 表(跨仓回写可后续对接)。</p>
*/
@RestController
@RequestMapping(value = Config.API_PATH)
public class SchSettingsController {
@Autowired
private ISchSettingsService schSettingsService;
private Integer resolveSchId(BoaUser user) {
if (user.getSchool() != null) {
return user.getSchool().getId();
}
if (user.getBureau() != null) {
return user.getBureau().getId();
}
return 0;
}
@PostMapping("saveSchTheme")
public void saveSchTheme(BoaUser authUserWithDept, String themeName, @RequestParam(name = "schId", defaultValue = "0") Integer schId) {
if (schId == null || schId == 0) {
schId = resolveSchId(authUserWithDept);
}
SchSettings schSettings = new SchSettings();
Optional<SchSettings> model = schSettingsService.findBySchId(schId);
if (model.isPresent()) {
schSettings = model.get();
}
schSettings.setCDate(new Date());
schSettings.setSchId(schId);
schSettings.setCId(authUserWithDept.getId());
schSettings.setThemeName(themeName);
schSettingsService.save(schSettings);
}
@PostMapping("saveSchLogo")
public void saveSchLogo(BoaUser authUserWithDept, String logoUrl, @RequestParam(name = "schId", defaultValue = "0") Integer schId) {
if (schId == null || schId == 0) {
schId = resolveSchId(authUserWithDept);
}
SchSettings schSettings = newSchSettingsOrLoad(schId, authUserWithDept);
schSettings.setLogoUrl(logoUrl);
schSettingsService.save(schSettings);
}
/** getSchSettings:schId=0 时按 主学校→主归属组→0 推断(对齐旧 SchSettingsController)。 */
@GetMapping("getSchSettings")
public Optional<SchSettings> getSchSettings(BoaUser authUserWithDept,
@RequestParam(name = "schId", defaultValue = "0") Integer schId) {
if (schId == null || schId == 0) {
schId = resolveSchId(authUserWithDept);
}
return schSettingsService.findBySchId(schId);
}
private SchSettings newSchSettingsOrLoad(Integer schId, BoaUser user) {
Optional<SchSettings> model = schSettingsService.findBySchId(schId);
SchSettings schSettings = model.orElseGet(SchSettings::new);
schSettings.setCDate(new Date());
schSettings.setSchId(schId);
schSettings.setCId(user.getId());
return schSettings;
}
}