fix(appearance): 503 改 sendError 直写——绕过 GlobalExceptionHandler 兜成 200+code:6 信封(线上实测发现)
This commit is contained in:
@@ -6,12 +6,12 @@ import com.yunhai.platform.openapi.core.YschOpenCall;
|
||||
import com.yunhai.platform.utils.model.BoaUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
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.Map;
|
||||
|
||||
@@ -47,15 +47,18 @@ public class AppearanceProxyController {
|
||||
}
|
||||
|
||||
@GetMapping("appearance")
|
||||
public JsonNode appearance(BoaUser authUserWithDept) {
|
||||
public JsonNode appearance(BoaUser authUserWithDept, HttpServletResponse response) throws IOException {
|
||||
try {
|
||||
Map<String, String> q = new HashMap<>();
|
||||
q.put("userId", String.valueOf(authUserWithDept.getId())); // 服务端取登录人,不收前端参数
|
||||
return openCall.get(TARGET_USERHOME, "/oapi/appearance", q, JsonNode.class);
|
||||
} catch (Exception e) {
|
||||
// 降级铁律:sendError 直写 503 绕过 GlobalExceptionHandler(否则被兜成 200+code:6 信封,
|
||||
// init 侧靠信封防御兜底,但语义上必须让浏览器拿到非 2xx)
|
||||
log.warn("[appearance] UserHome 外观偏好不可达(503,init 侧静默不动本地键)userId={}:{}",
|
||||
authUserWithDept.getId(), e.toString());
|
||||
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, "appearance unavailable");
|
||||
response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "appearance unavailable");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user