fix(appearance): 503 改 sendError 直写——绕过 GlobalExceptionHandler 兜底(线上实测发现)
build / build-push (push) Successful in 2m9s

This commit is contained in:
chenxing
2026-10-09 00:39:51 +08:00
parent 54682cb72b
commit f84ce9c822
@@ -5,12 +5,12 @@ import com.yunhai.platform.openapi.core.YschOpenCall;
import com.yunhai.platform.utils.model.BoaUser; import com.yunhai.platform.utils.model.BoaUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -45,15 +45,17 @@ public class AppearanceProxyController {
} }
@GetMapping("appearance") @GetMapping("appearance")
public JsonNode appearance(BoaUser authUserWithDept) { public JsonNode appearance(BoaUser authUserWithDept, HttpServletResponse response) throws IOException {
try { try {
Map<String, String> q = new HashMap<>(); Map<String, String> q = new HashMap<>();
q.put("userId", String.valueOf(authUserWithDept.getId())); // 服务端取登录人,不收前端参数 q.put("userId", String.valueOf(authUserWithDept.getId())); // 服务端取登录人,不收前端参数
return openCall.get(TARGET_USERHOME, "/oapi/appearance", q, JsonNode.class); return openCall.get(TARGET_USERHOME, "/oapi/appearance", q, JsonNode.class);
} catch (Exception e) { } catch (Exception e) {
// 降级铁律:sendError 直写 503 绕过 GlobalExceptionHandler(否则被兜成 200+code:6 信封)
log.warn("[appearance] UserHome 外观偏好不可达(503,init 侧静默不动本地键)userId={}:{}", log.warn("[appearance] UserHome 外观偏好不可达(503,init 侧静默不动本地键)userId={}:{}",
authUserWithDept.getId(), e.toString()); authUserWithDept.getId(), e.toString());
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, "appearance unavailable"); response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "appearance unavailable");
return null;
} }
} }
} }