Commit 252dc1de by 刘宇峰

新e盾标准接口提供给外部的api依赖

0 parents
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>glsx-ne-shield</artifactId>
<groupId>com.glsx</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ne-shield-standard-interfaces-api</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<!-- feign -->
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-feign</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Local Nexus Releases Repository</name>
<url>http://192.168.3.233/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Local Nexus Snapshots Repository</name>
<url>http://192.168.3.233/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
\ No newline at end of file
package cn.com.glsx.stdinterface.api;
import cn.com.glsx.stdinterface.dto.StatisticsDriveDto;
import cn.com.glsx.stdinterface.factory.StatisticsDriveFallbackFactory;
import com.glsx.plat.core.web.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @author zhouhaibao
* @date 2021/5/24 9:49
*/
@FeignClient(name = "ne-shield-standard-interfaces", path = "/stdinterface/statisticsdrive", fallbackFactory = StatisticsDriveFallbackFactory.class, decode404 = true)
public interface StatisticsDriveClient {
/**
* 获取数据集合
*
* @return R
*/
@GetMapping(value = "/drivedatalist")
R statisticsDriveDataEveryDay();
/**
* 插入数据
*
* @param statisticsDriveDtoList
* @return R
*/
@PostMapping(value = "/insertstatisticsdrivelist")
R insertStatisticsDriveList(@RequestBody List<StatisticsDriveDto> statisticsDriveDtoList);
}
package cn.com.glsx.stdinterface.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 试驾统计数据
*/
@Data
public class StatisticsDriveDto implements Serializable {
/**
* 设备号
*/
private String sn;
/**
* 当天有效试驾次数
*/
private Integer driveNum;
/**
* 当天试驾总次数
*/
private Integer driveTotal;
/**
* 试驾日期
*/
private String driveTime;
}
\ No newline at end of file
package cn.com.glsx.stdinterface.factory;
import cn.com.glsx.stdinterface.api.StatisticsDriveClient;
import cn.com.glsx.stdinterface.fallback.StatisticsDriveFallbackImpl;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* 项目名:ne-shield-insurancenter-api
* 包名: cn.com.glsx.insurance.factory
* 作者: Yanglinlong
* 日期: 2021/7/5 16:15
*/
@Component
public class StatisticsDriveFallbackFactory implements FallbackFactory<StatisticsDriveClient> {
@Override
public StatisticsDriveClient create(Throwable throwable) {
StatisticsDriveFallbackImpl fallback = new StatisticsDriveFallbackImpl();
fallback.setCause(throwable);
return fallback;
}
}
package cn.com.glsx.stdinterface.fallback;
import cn.com.glsx.stdinterface.api.StatisticsDriveClient;
import cn.com.glsx.stdinterface.dto.StatisticsDriveDto;
import com.glsx.plat.core.web.R;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 项目名:ne-shield-insurancenter-api
* 包名: cn.com.glsx.insurance.fallback
* 作者: Yanglinlong
* 日期: 2021/7/5 16:16
*/
@Slf4j
@Component
public class StatisticsDriveFallbackImpl implements StatisticsDriveClient {
@Setter
private Throwable cause;
@Override
public R statisticsDriveDataEveryDay() {
log.warn("statisticsDriveDataEveryDay 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
@Override
public R insertStatisticsDriveList(List<StatisticsDriveDto> statisticsDriveDtoList) {
log.warn("insertStatisticsDriveList 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
}
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
cn.com.glsx.stdinterface.fallback.StatisticsDriveFallbackImpl,\
cn.com.glsx.stdinterface.factory.StatisticsDriveFallbackFactory
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!