|
|
@@ -1,18 +1,25 @@
|
|
|
package cn.hnthyy.thmz.controller;
|
|
|
|
|
|
+import cn.hnthyy.thmz.Utils.DateUtil;
|
|
|
import cn.hnthyy.thmz.Utils.HttpUtil;
|
|
|
+import cn.hnthyy.thmz.Utils.JsonUtil;
|
|
|
import cn.hnthyy.thmz.Utils.TokenUtil;
|
|
|
+import cn.hnthyy.thmz.common.Constants;
|
|
|
import cn.hnthyy.thmz.entity.thmz.*;
|
|
|
import cn.hnthyy.thmz.service.thmz.MenuService;
|
|
|
import cn.hnthyy.thmz.service.thmz.RoleMenuRelationService;
|
|
|
import cn.hnthyy.thmz.service.thmz.UserRoleRelationService;
|
|
|
+import cn.hnthyy.thmz.service.thmz.UserService;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
@@ -30,6 +37,8 @@ public class NavigationController {
|
|
|
private RoleMenuRelationService roleMenuRelationService;
|
|
|
@Autowired
|
|
|
private UserRoleRelationService userRoleRelationService;
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
|
|
|
/**
|
|
|
* 打开登录页面
|
|
|
@@ -48,8 +57,17 @@ public class NavigationController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/menu/view")
|
|
|
- public String menuView() {
|
|
|
- return "menu";
|
|
|
+ public ModelAndView menuView(HttpServletRequest httpServletRequest) {
|
|
|
+ ModelAndView modelAndView = new ModelAndView();
|
|
|
+ String code = httpServletRequest.getParameter("code");
|
|
|
+ if(StrUtil.isNotBlank(code)){
|
|
|
+ User user = userService.queryUserByCode(code);
|
|
|
+ Date deadTime = DateUtil.getDate(Constants.JWT_TTL*365);
|
|
|
+ String token =TokenUtil.createJWT(JsonUtil.object2Json(user),deadTime);
|
|
|
+ modelAndView.addObject("token", token);
|
|
|
+ }
|
|
|
+ modelAndView.setViewName("menu");
|
|
|
+ return modelAndView;
|
|
|
}
|
|
|
|
|
|
/**
|