From 65fda5ee290a5fc3826aed77e77699a1555a84a5 Mon Sep 17 00:00:00 2001
From: "pref_mail@163.com" <123456>
Date: Wed, 6 Sep 2023 19:05:46 +0800
Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E7=99=BB=E5=BD=95=E7=BB=91?=
=?UTF-8?q?=E5=AE=9A=E4=BB=93=E5=BA=93=20=E5=A2=9E=E5=8A=A0=20feign?=
=?UTF-8?q?=E7=9A=84=E8=BF=9C=E7=A8=8B=E8=B0=83=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
blade-auth/pom.xml | 10 ++++----
.../org/springblade/auth/AuthApplication.java | 2 ++
.../service/BladeUserDetailsServiceImpl.java | 25 ++++++++++---------
3 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/blade-auth/pom.xml b/blade-auth/pom.xml
index c85b55b8..e8411ca1 100644
--- a/blade-auth/pom.xml
+++ b/blade-auth/pom.xml
@@ -117,11 +117,11 @@
-->
-
-
-
-
-
+
+ org.springblade
+ logpm-basicdata-api
+ 3.1.0.RELEASE
+
diff --git a/blade-auth/src/main/java/org/springblade/auth/AuthApplication.java b/blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
index f465d7fa..6d77f0a3 100644
--- a/blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
+++ b/blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
@@ -20,6 +20,7 @@ package org.springblade.auth;
import org.springblade.core.cloud.client.BladeCloudApplication;
import org.springblade.core.launch.BladeApplication;
import org.springblade.core.launch.constant.AppConstant;
+import org.springframework.cloud.openfeign.EnableFeignClients;
import java.util.Base64;
@@ -29,6 +30,7 @@ import java.util.Base64;
* @author Chill
*/
@BladeCloudApplication
+@EnableFeignClients({"org.springblade", "com.logpm"})
public class AuthApplication {
public static void main(String[] args) {
diff --git a/blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetailsServiceImpl.java b/blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetailsServiceImpl.java
index d9910305..22e771f1 100644
--- a/blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetailsServiceImpl.java
+++ b/blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetailsServiceImpl.java
@@ -18,6 +18,9 @@ package org.springblade.auth.service;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.StringUtils;
+import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
+import com.logpm.basicdata.entity.WarehouseParcelListEntity;
+import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import io.jsonwebtoken.Claims;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
@@ -67,6 +70,8 @@ public class BladeUserDetailsServiceImpl implements UserDetailsService {
private final BladeRedis bladeRedis;
private final JwtProperties jwtProperties;
+ private final IBasicdataWarehouseClient basicdataWarehouseClient;
+
@Override
@SneakyThrows
public BladeUserDetails loadUserByUsername(String username) {
@@ -156,19 +161,15 @@ public class BladeUserDetailsServiceImpl implements UserDetailsService {
throw new UserDeniedAuthorizationException(TokenUtil.ACCOUNT_DISABLE);
}
- // 绑定仓库
- String key = CacheNames.tenantKeyObj(tenantId, CacheNames.USER_WAREHOUSE_KEY, user.getId());
- try{
- Object json = bladeRedis.getRedisTemplate().opsForValue().get(key);
- if(ObjectUtil.isNotEmpty(json)){
- JSONObject jsonObject = JSONObject.parseObject(json.toString());
- if(ObjectUtil.isNotEmpty(jsonObject)){
- userInfo.getDetail().put("warehouse_id",jsonObject.get("id"));
- userInfo.getDetail().put("warehouse_name",jsonObject.get("name"));
- }
+ // 绑定仓库
+ try {
+ BasicdataWarehouseEntity bls = basicdataWarehouseClient.addWarehouseSingle(user.getDeptId(), user.getTenantId(), user.getId());
+ if (ObjectUtil.isNotEmpty(bls)) {
+ userInfo.getDetail().put("warehouse_id", bls.getId());
+ userInfo.getDetail().put("warehouse_name", bls.getName());
}
- }catch (Exception e){
- log.error("登录获取仓库信息报错 {}",e.getMessage());
+ } catch ( Exception e) {
+ log.error("登录获取仓库信息报错 {}", e.getMessage());
}
// 成功则清除登录错误次数