增加 StockStrategy 服务,数据表建立及批量更新方法重写。解决多数据源配置 mapper-locations

无法识别并读取到对应数据源的 mapper.xml 及其 statement 方法的问题
This commit is contained in:
2026-01-10 14:26:04 +08:00
parent 52f4dd5e83
commit b0093ccccb
27 changed files with 653 additions and 280 deletions

View File

@@ -0,0 +1,44 @@
package quant.rich.emoney;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
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 com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import quant.rich.emoney.service.postgre.StockStrategyService;
/**
* 测试从本地读取包含 stock strategy 的 json, 转换为列表并更新到数据库中
*/
@SpringBootTest
@ContextConfiguration(classes = EmoneyAutoApplication.class)
@RunWith(SpringJUnit4ClassRunner.class)
@Slf4j
public class StockStrategyJsonParseAndUpdateLocalTest {
@Autowired
ObjectMapper objectMapper;
@Autowired
StockStrategyService stockStrategyService;
@Test
void test() throws IOException, InterruptedException, ExecutionException {
String str = Files.readString(Path.of("C:\\Users\\Administrator\\Desktop\\stock_strategy.json"));
JsonNode node = objectMapper.readTree(str);
Future<Boolean> future = stockStrategyService.updateByQueryResponseAsync(node);
future.get();
}
}