MySQL支持, 其他优化

This commit is contained in:
QAIU
2025-02-06 16:52:06 +08:00
parent e839f56a91
commit 5b666e1fec
14 changed files with 465 additions and 62 deletions

View File

@@ -21,13 +21,13 @@ public class ApiStatisticsInfo implements ToJson {
/**
* pan type 单独拿出来便于统计.
*/
@Length(varcharSize = 4)
@Length(varcharSize = 16)
private String panType;
/**
* 分享key type:key
*/
@Length(varcharSize = 4096)
@Length(varcharSize = 1024)
private String shareKey;
/**

View File

@@ -23,7 +23,7 @@ public class CacheLinkInfo implements ToJson {
/**
* 缓存key: type:ShareKey; e.g. lz:xxxx
*/
@Length(varcharSize = 4096)
@Length(varcharSize = 1024)
private String shareKey;
/**

View File

@@ -48,10 +48,11 @@ public class DbServiceImpl implements DbService {
JDBCPool client = JDBCPoolInit.instance().getPool();
Promise<StatisticsInfo> promise = Promise.promise();
String sql = """
select sum(api_parser_total) parserTotal,sum("cache_hit_total") cacheTotal,
sum(api_parser_total) + sum("cache_hit_total") total
from "api_statistics_info";
select sum(api_parser_total) as parserTotal, sum(cache_hit_total) as cacheTotal,
sum(api_parser_total) + sum(cache_hit_total) as total
from api_statistics_info;
""";
SqlTemplate.forQuery(client, sql).mapTo(StatisticsInfo.class).execute(new HashMap<>()).onSuccess(row -> {
StatisticsInfo info;
if ((info = row.iterator().next()) != null) {
@@ -59,7 +60,10 @@ public class DbServiceImpl implements DbService {
} else {
promise.fail("t_parser_log_info查询为空");
}
}).onFailure(promise::fail);
}).onFailure(e->{
log.error("getStatisticsInfo: ", e);
promise.fail(e);
});
return promise.future();
}
}