|
@@ -1,7 +1,9 @@
|
|
|
package com.mokasz.sample.admin.controller;
|
|
package com.mokasz.sample.admin.controller;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.mokasz.sample.common.exception.CommonBizException;
|
|
import com.mokasz.sample.common.exception.CommonBizException;
|
|
|
import com.mokasz.sample.common.model.ApiResponse;
|
|
import com.mokasz.sample.common.model.ApiResponse;
|
|
|
|
|
+import com.mokasz.sample.manager.SpaceClient;
|
|
|
import com.xxl.sso.core.conf.Conf;
|
|
import com.xxl.sso.core.conf.Conf;
|
|
|
import com.xxl.sso.core.login.SsoWebLoginHelper;
|
|
import com.xxl.sso.core.login.SsoWebLoginHelper;
|
|
|
import com.xxl.sso.core.user.XxlSsoUser;
|
|
import com.xxl.sso.core.user.XxlSsoUser;
|
|
@@ -9,11 +11,17 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
|
|
+import org.springframework.http.HttpMethod;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
+import org.springframework.web.bind.annotation.CookieValue;
|
|
|
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.client.RestTemplate;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -28,6 +36,11 @@ public class HomeController {
|
|
|
|
|
|
|
|
@Value("${xxl.sso.server}")
|
|
@Value("${xxl.sso.server}")
|
|
|
private String ssoLoginUrl;
|
|
private String ssoLoginUrl;
|
|
|
|
|
+ @Value("${space.system.id}")
|
|
|
|
|
+ private Integer systemId;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SpaceClient spaceClient;
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "获取登陆用户信息")
|
|
@ApiOperation(value = "获取登陆用户信息")
|
|
@@ -48,4 +61,18 @@ public class HomeController {
|
|
|
return ApiResponse.ok(ssoLoginUrl);
|
|
return ApiResponse.ok(ssoLoginUrl);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @ApiOperation(value = "获取菜单")
|
|
|
|
|
+ @GetMapping("/getMenu")
|
|
|
|
|
+ public ApiResponse<?> getMenu(HttpServletRequest request, @CookieValue(Conf.SSO_SESSIONID) String sessionId){
|
|
|
|
|
+ XxlSsoUser xxlSsoUser = (XxlSsoUser) request.getAttribute(Conf.SSO_USER);
|
|
|
|
|
+ String userid = xxlSsoUser.getUserid();
|
|
|
|
|
+ String cookieValue = Conf.SSO_SESSIONID.concat("=").concat(sessionId);
|
|
|
|
|
+ JSONObject jsonObject = spaceClient.getMenu(systemId, userid, cookieValue);
|
|
|
|
|
+
|
|
|
|
|
+ if ("200".equals(jsonObject.getString("code"))) {
|
|
|
|
|
+ return ApiResponse.ok(jsonObject.get("data"));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return ApiResponse.fail("无法获取菜单及权限信息");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|