From aa2e136585979d4aa707ad48d20ab6b32519bb22 Mon Sep 17 00:00:00 2001
From: infrasys00 <blackdancers@163.com>
Date: 星期二, 22 十二月 2020 18:25:32 +0800
Subject: [PATCH] Merge branch 'master' of http://gitlab.nhys.cdnhxx.com/root/zhihuishequ

---
 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/controller/BaseController.java |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/controller/BaseController.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/controller/BaseController.java
index 52c8a0b..1e0e849 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/controller/BaseController.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/controller/BaseController.java
@@ -1,14 +1,19 @@
 package com.panzhihua.common.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.panzhihua.common.constants.Constants;
 import com.panzhihua.common.constants.TokenConstant;
 import com.panzhihua.common.constants.UserConstants;
 import com.panzhihua.common.exceptions.UnAuthenticationException;
 import com.panzhihua.common.model.vos.LoginUserInfoVO;
+import com.panzhihua.common.utlis.AES;
 import io.swagger.models.auth.In;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.util.ObjectUtils;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
+import sun.security.krb5.internal.crypto.Aes256;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -18,6 +23,7 @@
  * @author: huang.hongfa weixin hhf9596 qq 959656820
  * @create: 2020-11-24 09:31
  **/
+@Slf4j
 public class BaseController {
     /**
      * 获取request对象
@@ -47,6 +53,16 @@
     }
 
     /**
+     * 获取登录对象所在小区
+     * @return 小区id
+     */
+    public Long getAreaId(){
+        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
+        Long areaId = loginUserInfo.getAreaId();
+        return areaId;
+    }
+
+    /**
      * 获取登录token
      * @return token
      */
@@ -60,13 +76,20 @@
      * 获取登录对象所有信息
      * @return 所有信息
      */
+    @SneakyThrows
     public LoginUserInfoVO getLoginUserInfo(){
         HttpServletRequest request = this.getRequest();
-        String userInfo = request.getHeader(UserConstants.LOGIN_USER_INFO);
+        String userInfo = request.getHeader(TokenConstant.TOKEN_USERINFO);
         boolean empty = ObjectUtils.isEmpty(userInfo);
         if (empty) {
             throw new UnAuthenticationException("获取登录人信息失败");
         }
+        log.info("userInfo【{}】",userInfo);
+        byte[] bytes = AES.parseHexStr2Byte(userInfo);
+        log.info("bytes【{}】",bytes);
+        byte[] decrypt = AES.decrypt(bytes, Constants.AES_KEY);
+        log.info("decrypt【{}】",decrypt);
+        userInfo=new String(decrypt);
         LoginUserInfoVO loginUserInfoVO= JSONObject.parseObject(userInfo,LoginUserInfoVO.class);
         return loginUserInfoVO;
     }

--
Gitblit v1.7.1