@PostMapping("/getdepainfo") @Operation(summary = "查询部门信息") public JsonResponse<JsonObject> getdepaInfo() throws IOException { JsonObject jsonObject = null; try { jsonObject = new JsonObject(HttpClientUtil.doGet("http://202.104.122.106:8080/usercenter/v1/department/getAllDepartments"));//部门信息接口 } catch (Exception e) { log.error("查询部门上异常:{}",LogExceptionStackUtil.logExceptionStack(e)); return JsonResponse.error("失败"); } return JsonResponse.ok(jsonObject); }
package com.sf.gis.common.utils; import java.io.PrintWriter; import java.io.StringWriter; public class LogExceptionStackUtil { public static String logExceptionStack(Throwable e) { StringWriter errorsWriter = new StringWriter(); e.printStackTrace(new PrintWriter(errorsWriter)); return errorsWriter.toString(); } }