lihong vor 1 Jahr
Ursprung
Commit
ffe8131e94

+ 20 - 2
src/main/java/cn/hnthyy/thmz/controller/NavigationController.java

@@ -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;
     }
 
     /**

+ 5 - 2
src/main/java/cn/hnthyy/thmz/controller/mz/RoleController.java

@@ -87,14 +87,17 @@ public class RoleController {
     @GetMapping("/checkDoctorRoleByUser")
     public R checkDoctorRoleByUser(){
         User user = TokenUtil.getUser();
+        if("9994".equals(user.getUserCode())){
+            return R.ok().put("data",0);
+        }
         List<UserRoleRelation> userRoleRelations = userRoleRelationService.queryByUserId(user.getId());
         if(CollUtil.isNotEmpty(userRoleRelations)){
             //10 为 门诊医生角色id
             if (userRoleRelations.stream().anyMatch(o -> o.getRoleId() != null && o.getRoleId() == 10)) {
-                    return R.ok().put("data",true);
+                    return R.ok().put("data",1);
             }
         }
-        return R.ok().put("data", false);
+        return R.ok().put("data", 2);
     }
 
     /**

+ 19 - 2
src/main/resources/static/js/menu.js

@@ -8,6 +8,20 @@ var patientIdFullForNucleicAcid=null;
 //挂号读取身份证定时任务
 var readIcCardTimerForRegistration=null;
 $(function () {
+    if(localStorage.getItem("token") == undefined){
+        var tokenId = $("#tokenId").val()
+        if(tokenId){
+            localStorage.setItem("token",tokenId)
+            localStorage.setItem("fileType","0")
+            localStorage.setItem("userID","9994");
+            //员工编号
+            localStorage.setItem("userIdCode","99994");
+            //员工医保赋码
+            localStorage.setItem("ybCode","");
+            localStorage.setItem("userName","发药排队");
+            window.location.href='/thmz/menu/view';
+        }
+    }
     if (localStorage.getItem("token") == undefined) {
         window.location.href = '/thmz/login/view'
     }
@@ -69,9 +83,12 @@ $(function () {
         url: "/thmz/checkDoctorRoleByUser",
         dataType: 'json',
         success: function(res) {
-            if(res.data == true) {
+            if(res.data == 1) {
                 changeContent('/thmz/doctorIndex');
-            }else {
+            }else if(res.data == 0) {
+                changeContent('/thmz/pharmacy-cell');
+            }
+            else {
                 changeContent('/thmz/index');
             }
         }

+ 1 - 0
src/main/resources/templates/menu.html

@@ -145,6 +145,7 @@
                                 <span class=" fa fa-angle-down"></span>
                             </a>
                             <ul class="dropdown-menu dropdown-usermenu pull-right">
+                                <input id ="tokenId" th:value="${token}" hidden />
                                 <li><a href="javascript:;" onclick="editProfile()">个人信息</a></li>
                                 <li><a href="javascript:;" onclick="editProfileImage()">头像修改</a></li>
                                 <li><a href="javascript:;" onclick="editPassword()">密码重置</a></li>