Files
UserhomeService/src/main/java/com/yunhai/userhome/service/impl/OpenApiAppRemoteServiceImpl.java
T
chenxing 71c571f884
build / build-push (push) Successful in 57s
fix(应用列表): schId 非正数哨兵边界归一——超管 GetUserApp 恢复豁免
前端 getCurSchId 对无学校身份(超管/平台账号)下发哨兵 -1(store: schId || -1),
UserBase 2026-10-12 学校单点开通硬闸门对显式 schoolId 先过 assertSchoolId,
-1 非合法学校主键被拒("学校分组不存在"),且超管豁免(isSuperAdmin bypass)
在校验之后根本走不到。OpenApiAppRemoteServiceImpl 边界归一:schoolId<=0 → null,
交 UserBase 按激活身份/主归属兜底——超管恢复全量豁免,GetAppInfoById 同口径覆盖。
2026-10-13 14:27:39 +08:00

59 lines
2.3 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.yunhai.userhome.service.impl;
import com.yunhai.platform.openapi.base.YschBaseOpenApi;
import com.yunhai.platform.utils.enums.ClientEnum;
import com.yunhai.platform.utils.model.BoaApp;
import com.yunhai.platform.utils.model.BoaAppType;
import com.yunhai.platform.utils.model.BoaUser;
import com.yunhai.userhome.service.AppRemoteService;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
/**
* {@link AppRemoteService} 真实实现:经 yh-platform {@code YschBaseOpenApi} 调 UserBase
* {@code GET /oapi/app/list?userId=&clientType=}(自动带 app-auth 签名)。
*/
@Service
public class OpenApiAppRemoteServiceImpl implements AppRemoteService {
@Override
public List<BoaAppType> getUserApps(BoaUser user) {
return getUserApps(user, null);
}
@Override
public List<BoaAppType> getUserApps(BoaUser user, Integer schoolId) {
if (user == null || user.getId() == null) {
return Collections.emptyList();
}
// 前端 getCurSchId 对无学校身份(超管/平台账号)下发哨兵 -1(store: schId || -1),非合法学校主键;
// UserBase 2026-10-12 硬闸门对显式 schoolId 先过 assertSchoolId,-1 会被拒("学校分组不存在"),
// 且超管豁免(isSuperAdmin bypass)在校验之后根本走不到——边界归一为 null 交服务端按激活身份/主归属兜底。
if (schoolId != null && schoolId <= 0) {
schoolId = null;
}
// PC 浏览器端;schoolId 透传 UserBase 做学校单点开通收窄(为空则服务端按身份/主归属兜底)
return YschBaseOpenApi.getUserApp(user.getId(), ClientEnum.PC_BROWSER, schoolId);
}
@Override
public Optional<BoaApp> getAppById(BoaUser user, Integer appId) {
return getAppById(user, appId, null);
}
@Override
public Optional<BoaApp> getAppById(BoaUser user, Integer appId, Integer schoolId) {
if (appId == null) {
return Optional.empty();
}
return getUserApps(user, schoolId).stream()
.filter(t -> t.getApps() != null)
.flatMap(t -> t.getApps().stream())
.filter(a -> appId.equals(a.getId()))
.findFirst();
}
}