Browse Source

1.增加登录绑定仓库 增加 feign的远程调用

pull/1/head
pref_mail@163.com 2 years ago
parent
commit
65fda5ee29
  1. 10
      blade-auth/pom.xml
  2. 2
      blade-auth/src/main/java/org/springblade/auth/AuthApplication.java
  3. 25
      blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetailsServiceImpl.java

10
blade-auth/pom.xml

@ -117,11 +117,11 @@
</dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springblade</groupId>-->
<!-- <artifactId>logpm-basicdata-api</artifactId>-->
<!-- <version>3.1.0.RELEASE</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springblade</groupId>
<artifactId>logpm-basicdata-api</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
</dependencies>
<build>

2
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) {

25
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());
}
// 成功则清除登录错误次数

Loading…
Cancel
Save