删除 EmoneyRequestConfig 和 ProxyConfig 设置,改为数据库(SQLite)配置。默认配置的设置和删除逻辑由

SQLite 触发器配置。
This commit is contained in:
2025-11-15 14:57:02 +08:00
parent 6ccfe67aff
commit edcbfd4ffd
77 changed files with 1240 additions and 1620 deletions

View File

@@ -34,9 +34,9 @@ import okhttp3.Response;
import quant.rich.emoney.EmoneyAutoApplication;
import quant.rich.emoney.client.EmoneyClient;
import quant.rich.emoney.client.OkHttpClientProvider;
import quant.rich.emoney.entity.config.EmoneyRequestConfig;
import quant.rich.emoney.pojo.dto.NonParamsIndexDetail;
import quant.rich.emoney.pojo.dto.NonParamsIndexDetail.NonParamsIndexDetailData;
import quant.rich.emoney.service.sqlite.RequestInfoService;
@SpringBootTest
@ContextConfiguration(classes = EmoneyAutoApplication.class)
@@ -47,7 +47,7 @@ public class EmoneyIndexScraper {
private static final ObjectMapper MAPPER = new ObjectMapper();
@Autowired
EmoneyRequestConfig emoneyRequestConfig;
RequestInfoService requestInfoService;
static {
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -58,7 +58,7 @@ public class EmoneyIndexScraper {
urlBuilder.append("https://appstatic.emoney.cn/html/emapp/stock/note/?name=");
urlBuilder.append(indexCode.toString());
urlBuilder.append("&emoneyScaleType=0&emoneyLandMode=0&token=");
urlBuilder.append(emoneyRequestConfig.getAuthorization());
urlBuilder.append(requestInfoService.getDefaultRequestInfo().getAuthorization());
return urlBuilder.toString();
}
@@ -75,7 +75,7 @@ public class EmoneyIndexScraper {
.header("Host", "appstatic.emoney.cn")
.header("Connection", "keep-alive")
.header("Upgrade-Insecure-Requests", "1")
.header("User-Agent", emoneyRequestConfig.getWebviewUserAgent())
.header("User-Agent", requestInfoService.getDefaultRequestInfo().getWebviewUserAgent())
.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
.header("X-Request-With", "cn.emoney.emstock")
.header("Sec-Fetch-Site", "none")
@@ -124,7 +124,7 @@ public class EmoneyIndexScraper {
Request.Builder scriptBuilder = new Request.Builder()
.header("Host", "appstatic.emoney.cn")
.header("Connection", "keep-alive")
.header("User-Agent", emoneyRequestConfig.getWebviewUserAgent())
.header("User-Agent", requestInfoService.getDefaultRequestInfo().getWebviewUserAgent())
.header("Accept", "*/*")
.header("X-Request-With", "cn.emoney.emstock")
.header("Sec-Fetch-Site", "same-origin")
@@ -160,7 +160,6 @@ public class EmoneyIndexScraper {
// 将每个 jsonString 转换为 jsonArray进一步转换成 IndexDetail
List<NonParamsIndexDetail> valid = new ArrayList<>();
List<ArrayNode> arrayNodes = new ArrayList<>();
for (String jsonString : matchGroups) {
try {
JsonNode root = MAPPER.readTree(jsonString);
@@ -189,7 +188,7 @@ public class EmoneyIndexScraper {
Request.Builder imageBuilder = new Request.Builder()
.header("Host", "appstatic.emoney.cn")
.header("Connection", "keep-alive")
.header("User-Agent", emoneyRequestConfig.getWebviewUserAgent())
.header("User-Agent", requestInfoService.getDefaultRequestInfo().getWebviewUserAgent())
.header("Accept", "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8")
.header("X-Request-With", "cn.emoney.emstock")
.header("Sec-Fetch-Site", "same-origin")

View File

@@ -31,7 +31,7 @@ public class PatchOkHttpTest {
.or(c -> c.hostContains("localhost"))
.or(a -> a.hostContains("emapp"))
.or(b -> b.hasHeaderName("X-Protocol-Id"))
.overrideIf("User-Agent", "okhttp/3.12.2")
.overrideHeader("User-Agent", "okhttp/3.12.2")
.build();
context = new RequestContext(new Request.Builder()