|
|
@@ -39,9 +39,12 @@ namespace molilian.core
|
|
|
return Math.Max(0, RedisHelper.Get<int>(SamplingRemainingKey));
|
|
|
}
|
|
|
|
|
|
- public static async Task TrySampleAsync(string imageBase64, string responseJson)
|
|
|
+ public static async Task TrySampleAsync(string imageBase64, string ip, string oaid, string responseJson)
|
|
|
{
|
|
|
- if (string.IsNullOrWhiteSpace(imageBase64) && string.IsNullOrWhiteSpace(responseJson))
|
|
|
+ if (string.IsNullOrWhiteSpace(imageBase64)
|
|
|
+ && string.IsNullOrWhiteSpace(ip)
|
|
|
+ && string.IsNullOrWhiteSpace(oaid)
|
|
|
+ && string.IsNullOrWhiteSpace(responseJson))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
@@ -58,13 +61,15 @@ namespace molilian.core
|
|
|
using var conn = DBContext.GetOpenConnection();
|
|
|
const string sql = @"
|
|
|
INSERT INTO promotion_query_samples
|
|
|
- (id, image_base64, response_json, create_time)
|
|
|
+ (id, ip, oaid, image_base64, response_json, create_time)
|
|
|
VALUES
|
|
|
- (@id, @image_base64, @response_json, @create_time);";
|
|
|
+ (@id, @ip, @oaid, @image_base64, @response_json, @create_time);";
|
|
|
|
|
|
await conn.ExecuteAsync(sql, new
|
|
|
{
|
|
|
id = sampleId,
|
|
|
+ ip = ip ?? string.Empty,
|
|
|
+ oaid = oaid ?? string.Empty,
|
|
|
image_base64 = imageBase64 ?? string.Empty,
|
|
|
response_json = responseJson ?? string.Empty,
|
|
|
create_time = DateTime.Now
|
|
|
@@ -115,7 +120,7 @@ FROM promotion_query_samples
|
|
|
args.Add("offset", offset);
|
|
|
|
|
|
string sql = $@"
|
|
|
-SELECT id, image_base64, response_json, create_time
|
|
|
+SELECT id, ip, oaid, image_base64, response_json, create_time
|
|
|
FROM promotion_query_samples
|
|
|
{where}
|
|
|
ORDER BY create_time DESC
|
|
|
@@ -139,6 +144,8 @@ LIMIT @offset, @count";
|
|
|
fileName = $"{item.id}.log",
|
|
|
writeTime = item.create_time.ToString("yyyy-MM-dd HH:mm:ss.fff"),
|
|
|
content = BuildLegacyContent(item),
|
|
|
+ ip = item.ip,
|
|
|
+ oaid = item.oaid,
|
|
|
imageBase64 = item.image_base64,
|
|
|
responseJson = item.response_json
|
|
|
};
|
|
|
@@ -151,7 +158,18 @@ LIMIT @offset, @count";
|
|
|
{
|
|
|
string clientPost = JsonSerializer.Serialize(new
|
|
|
{
|
|
|
- img = item.image_base64
|
|
|
+ img = item.image_base64,
|
|
|
+ ip = item.ip,
|
|
|
+ oaid = item.oaid
|
|
|
+ }, JsonOptions);
|
|
|
+ AppendSection(builder, item.create_time, "clientPost", clientPost);
|
|
|
+ }
|
|
|
+ else if (!string.IsNullOrWhiteSpace(item.ip) || !string.IsNullOrWhiteSpace(item.oaid))
|
|
|
+ {
|
|
|
+ string clientPost = JsonSerializer.Serialize(new
|
|
|
+ {
|
|
|
+ ip = item.ip,
|
|
|
+ oaid = item.oaid
|
|
|
}, JsonOptions);
|
|
|
AppendSection(builder, item.create_time, "clientPost", clientPost);
|
|
|
}
|
|
|
@@ -231,6 +249,8 @@ LIMIT @offset, @count";
|
|
|
const string sql = @"
|
|
|
CREATE TABLE IF NOT EXISTS promotion_query_samples (
|
|
|
id VARCHAR(80) NOT NULL PRIMARY KEY COMMENT '采样日志ID',
|
|
|
+ ip VARCHAR(64) NOT NULL DEFAULT '' COMMENT '请求IP',
|
|
|
+ oaid VARCHAR(128) NOT NULL DEFAULT '' COMMENT '请求OAID',
|
|
|
image_base64 LONGTEXT NOT NULL COMMENT '入参图片base64',
|
|
|
response_json LONGTEXT NOT NULL COMMENT '返回JSON',
|
|
|
create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|