add remote firmInfo
parent
fc0c17ea0c
commit
2d2844b6e8
|
@ -20,7 +20,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.dragon</groupId>
|
<groupId>com.dragon</groupId>
|
||||||
<artifactId>dragon-common-core</artifactId>
|
<artifactId>dragon-common-core</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -22,5 +22,10 @@
|
||||||
<artifactId>vehicle-firm-common</artifactId>
|
<artifactId>vehicle-firm-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.dragon</groupId>
|
||||||
|
<artifactId>dragon-common-core</artifactId>
|
||||||
|
<version>3.6.4</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,10 +1,21 @@
|
||||||
package dragon.vehicle.firm.remote;
|
package dragon.vehicle.firm.remote;
|
||||||
|
|
||||||
|
import com.dragon.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.dragon.common.core.domain.Result;
|
||||||
|
import com.dragon.vehicle.firm.domain.cache.FirmInfoCache;
|
||||||
|
import dragon.vehicle.firm.remote.factory.RemoteFirmServiceFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 冯凯
|
* @author 冯凯
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @description:
|
* @description:
|
||||||
* @date 2023/11/20 13:40
|
* @date 2023/11/20 13:40
|
||||||
*/
|
*/
|
||||||
|
@FeignClient(contextId = "remoteFirmService",value = ServiceNameConstants.COMPANY_SERVICE,fallbackFactory = RemoteFirmServiceFallbackFactory.class)
|
||||||
public interface RemoteFirmService {
|
public interface RemoteFirmService {
|
||||||
|
|
||||||
|
@GetMapping("/by/userId")
|
||||||
|
public Result<FirmInfoCache> getFirmInfoByUserId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package dragon.vehicle.firm.remote.factory;
|
package dragon.vehicle.firm.remote.factory;
|
||||||
|
|
||||||
|
import com.dragon.common.core.domain.Result;
|
||||||
|
import com.dragon.vehicle.firm.domain.cache.FirmInfoCache;
|
||||||
import dragon.vehicle.firm.remote.RemoteFirmService;
|
import dragon.vehicle.firm.remote.RemoteFirmService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,5 +15,18 @@ import org.springframework.stereotype.Component;
|
||||||
* @date 2023/11/20 13:40
|
* @date 2023/11/20 13:40
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class RemoteFirmServiceFallbackFactory implements RemoteFirmService {
|
public class RemoteFirmServiceFallbackFactory implements FallbackFactory<RemoteFirmService> {
|
||||||
|
|
||||||
|
public static final Logger logger=LoggerFactory.getLogger(RemoteFirmService.class);
|
||||||
|
@Override
|
||||||
|
public RemoteFirmService create(Throwable throwable) {
|
||||||
|
logger.error("用户服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemoteFirmService(){
|
||||||
|
@Override
|
||||||
|
public Result<FirmInfoCache> getFirmInfoByUserId() {
|
||||||
|
return Result.error("获取企业信息失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package com.dragon.vehicle.firm.server.controller;
|
package com.dragon.vehicle.firm.server.controller;
|
||||||
|
|
||||||
import com.dragon.common.core.domain.Result;
|
import com.dragon.common.core.domain.Result;
|
||||||
|
import com.dragon.common.security.utils.SecurityUtils;
|
||||||
import com.dragon.vehicle.firm.domain.cache.FirmInfoCache;
|
import com.dragon.vehicle.firm.domain.cache.FirmInfoCache;
|
||||||
import com.dragon.vehicle.firm.server.service.FirmInfoService;
|
import com.dragon.vehicle.firm.server.service.FirmInfoService;
|
||||||
|
import org.apache.catalina.security.SecurityUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -34,7 +36,7 @@ public class FirmInfoController {
|
||||||
@GetMapping("/by/userId")
|
@GetMapping("/by/userId")
|
||||||
public Result<FirmInfoCache> getFirmInfoByUserId(){
|
public Result<FirmInfoCache> getFirmInfoByUserId(){
|
||||||
|
|
||||||
Long userId = 6L;
|
Long userId = SecurityUtils.getUserId();//获取当前登录人的userId
|
||||||
FirmInfoCache firmInfoCache=firmService.getFirmInfoByUserId(userId);
|
FirmInfoCache firmInfoCache=firmService.getFirmInfoByUserId(userId);
|
||||||
return Result.success(firmInfoCache);
|
return Result.success(firmInfoCache);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue