Compare commits
2 Commits
76d498b9a3
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 52f4dd5e83 | |||
| e323aa38ac |
@@ -55,7 +55,7 @@
|
||||
|
||||
测试环境需要配置好 Clash、Fiddler。Clash 部分,需要对益盟网址 Phaser 进行设置,强制使用代理访问。
|
||||
|
||||
目前,平台已经提供代理设置界面,程序调用 okhttp、Playwright 的地方基本上已经可以经由配置代理进行网络活动,故大部分确保平台访问能过代理的部分需要在 Clash 上的规则进行配置。
|
||||
目前,平台已经提供代理设置界面,程序调用 okhttp 的地方基本上已经可以经由配置代理进行网络活动,故大部分确保平台访问能过代理的部分需要在 Clash 上的规则进行配置。
|
||||
|
||||
以 Clash Verge 为例:打开主界面——订阅——全局扩展脚本,编辑脚本如下:
|
||||
|
||||
|
||||
41
pom.xml
41
pom.xml
@@ -21,6 +21,17 @@
|
||||
<maven.compiler.source>22</maven.compiler.source>
|
||||
<maven.compiler.target>22</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>2023.0.5</version> <!-- 或最新的 2023.0.x -->
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -66,6 +77,13 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<!-- 排除 org.skyscreamer 以规避 Feign 自动装配 fake jackson 的问题 -->
|
||||
<groupId>org.skyscreamer</groupId>
|
||||
<artifactId>jsonassert</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -90,6 +108,11 @@
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-openfeign -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.redisson/redisson -->
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
@@ -103,11 +126,6 @@
|
||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||
<version>3.26.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
@@ -302,6 +320,19 @@
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.20.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 排除 org.skyscreamer 以规避 Feign 自动装配 fake jackson 的问题 -->
|
||||
<dependency>
|
||||
<groupId>org.skyscreamer</groupId>
|
||||
<artifactId>jsonassert</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.vaadin.external.google</groupId>
|
||||
<artifactId>android-json</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -9,6 +9,11 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 注解在方法上以获取对 EmoneyProtocol 的额外操作
|
||||
* <p>
|
||||
* 目前方法必须是受 spring 管理类下的公共成员方法,且接受参数为单参数 JsonNode.
|
||||
* <p>
|
||||
* 例:
|
||||
* {@code StrategyAndPoolService#updateByQueryResponse(JsonNode)}
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
|
||||
@@ -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("/**");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,31 +2,17 @@ package quant.rich.emoney.controller.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.protobuf.nano.MessageNano;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import nano.BaseResponse.Base_Response;
|
||||
import quant.rich.emoney.entity.sqlite.ProtocolMatch;
|
||||
import quant.rich.emoney.exception.RException;
|
||||
import quant.rich.emoney.interfaces.IQueryableEnum;
|
||||
import quant.rich.emoney.pojo.dto.EmoneyConvertResult;
|
||||
import quant.rich.emoney.pojo.dto.EmoneyProtobufBody;
|
||||
import quant.rich.emoney.service.sqlite.ProtocolMatchService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/common")
|
||||
|
||||
@@ -452,7 +452,7 @@ public class RequestInfo extends Model<RequestInfo> {
|
||||
}
|
||||
|
||||
public boolean isAnonymous() {
|
||||
return !StringUtils.isAnyBlank(getUsername(), getPassword());
|
||||
return StringUtils.isAnyBlank(getUsername(), getPassword());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -23,7 +23,6 @@ public class PatchOkHttp {
|
||||
private static final Random random = new Random();
|
||||
private static final Logger log = LoggerFactory.getLogger(PatchOkHttp.class);
|
||||
private static final Set<PatchOkHttpRule> rules = new CopyOnWriteArraySet<>();
|
||||
private static boolean logOnce = false;
|
||||
|
||||
private static boolean isHooked = false;
|
||||
|
||||
|
||||
@@ -3,10 +3,7 @@ package quant.rich.emoney.service.sqlite;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
package quant.rich.emoney;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import quant.rich.emoney.tushare.StockInfo;
|
||||
import quant.rich.emoney.tushare.TushareDataServiceClient;
|
||||
|
||||
@SpringBootTest
|
||||
@ContextConfiguration(classes = EmoneyAutoApplication.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@Slf4j
|
||||
public class TushareDataServiceClientTest {
|
||||
|
||||
@Autowired
|
||||
TushareDataServiceClient tushareDataServiceClient;
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
List<StockInfo> stockInfos = tushareDataServiceClient.list("LIST", new String[] {"SZ", "SH"}, null);
|
||||
for(StockInfo stockInfo : stockInfos) {
|
||||
log.info("{} {}", stockInfo.getGoodsId(), stockInfo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user