commit
This commit is contained in:
@@ -3,11 +3,13 @@ package quant.rich.emoney;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@EnableAsync
|
||||
@EnableScheduling
|
||||
@EnableFeignClients
|
||||
@SpringBootApplication
|
||||
@EnableCaching(proxyTargetClass=true)
|
||||
public class EmoneyAutoApplication {
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.jdbc.UncategorizedSQLException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@@ -50,7 +51,8 @@ public class EmoneyAutoPlatformExceptionHandler {
|
||||
@ExceptionHandler({
|
||||
BindException.class,
|
||||
ConstraintViolationException.class,
|
||||
MethodArgumentNotValidException.class })
|
||||
MethodArgumentNotValidException.class,
|
||||
MissingServletRequestParameterException.class})
|
||||
@ResponseBody
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public <Ex extends BindException> R<?> handleBindException(Ex ex) {
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
|
||||
import quant.rich.emoney.interceptor.BaseInterceptor;
|
||||
import quant.rich.emoney.interceptor.EnumOptionsInterceptor;
|
||||
import quant.rich.emoney.service.ConfigService;
|
||||
|
||||
@@ -22,9 +21,6 @@ import quant.rich.emoney.service.ConfigService;
|
||||
@Configuration
|
||||
@Import(ConfigAutoRegistrar.class)
|
||||
public class EmoneyAutoConfig implements WebMvcConfigurer {
|
||||
|
||||
@Autowired
|
||||
BaseInterceptor baseInterceptor;
|
||||
|
||||
@Autowired
|
||||
EnumOptionsInterceptor enumOptionsInterceptor;
|
||||
@@ -39,7 +35,6 @@ public class EmoneyAutoConfig implements WebMvcConfigurer {
|
||||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(baseInterceptor).addPathPatterns("/**");
|
||||
registry.addInterceptor(enumOptionsInterceptor).addPathPatterns("/**");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package quant.rich.emoney.interceptor;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 后台系统身份验证拦截器 Modify by Doghole 2025/3/11
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class BaseInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package quant.rich.emoney.interceptor;
|
||||
|
||||
import org.reflections.Reflections;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
28
src/main/java/quant/rich/emoney/tushare/ITsStockInfo.java
Normal file
28
src/main/java/quant/rich/emoney/tushare/ITsStockInfo.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package quant.rich.emoney.tushare;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public interface ITsStockInfo {
|
||||
/**
|
||||
* 获取 Tushare 代码
|
||||
* @return
|
||||
*/
|
||||
String getTsCode();
|
||||
/**
|
||||
* 获取名称
|
||||
* @return
|
||||
*/
|
||||
String getName();
|
||||
/**
|
||||
* 获取上市(成立)日期
|
||||
* @return
|
||||
*/
|
||||
LocalDateTime getListDate();
|
||||
/**
|
||||
* 获取退市(终止)日期
|
||||
* @return
|
||||
*/
|
||||
default LocalDateTime getDelistDate() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
26
src/main/java/quant/rich/emoney/tushare/StockInfo.java
Normal file
26
src/main/java/quant/rich/emoney/tushare/StockInfo.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package quant.rich.emoney.tushare;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Accessors(chain=true)
|
||||
public class StockInfo implements ITsStockInfo {
|
||||
|
||||
private String tsCode;
|
||||
private String name;
|
||||
private LocalDateTime listDate;
|
||||
private LocalDateTime delistDate;
|
||||
|
||||
public Integer getGoodsId() {
|
||||
if (tsCode.endsWith("SH")) {
|
||||
return Integer.valueOf(tsCode.substring(0, 6));
|
||||
}
|
||||
if (tsCode.endsWith("SZ") || tsCode.endsWith("BJ")) {
|
||||
return Integer.valueOf("1" + tsCode.substring(0, 6));
|
||||
}
|
||||
throw new RuntimeException("无法将指定的 tsCode " + tsCode + " 转换成 goodsId");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package quant.rich.emoney.tushare;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 对接 TushareDataService 的 Feign 客户端
|
||||
*/
|
||||
@FeignClient(name="tushare-data-service-client", url="http://localhost:9999")
|
||||
public interface TushareDataServiceClient {
|
||||
|
||||
@GetMapping("/api/v1/common/stockInfo/list")
|
||||
public List<StockInfo> list(
|
||||
@RequestParam(name="listStatus", required=false) String listStatus,
|
||||
@RequestParam(name="stockMarket", required=false) String[] stockMarket,
|
||||
@RequestParam(name="ths", required=false, defaultValue="false") Boolean ths
|
||||
);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user