暂时支持q参数

This commit is contained in:
2023-11-21 11:07:58 +08:00
parent 121cddf493
commit 41db1d9911
3 changed files with 33 additions and 5 deletions

View File

@@ -6,6 +6,7 @@
using JNPF.Common.Security;
using Mapster;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using Tnb.Core;
namespace Tnb.Vengine.Domain;
@@ -44,16 +45,22 @@ public class VmGetInput : VmBaseInput
public void LoadFromHttpContext(HttpContext? context)
{
if (context == null) return;
var qStr = context.Request.Query["q"].ToString();
if (!string.IsNullOrEmpty(qStr))
{
var arg = JsonConvert.DeserializeObject<DObject>(qStr);
q.AddRange(arg);
}
string[] filter = new string[] { "id", "q", "o" };
foreach (var item in context.Request.Query.Where(a => !filter.Contains(a.Key)))
{
if (item.Value.Count > 1)
{
q.Add(item.Key, item.Value.ToArray());
q[item.Key] = item.Value.ToArray();
}
else
{
q.Add(item.Key, item.Value.ToString());
q[item.Key] = item.Value.ToString();
}
}
}
@@ -101,16 +108,22 @@ public class VmQueryInput : VmBaseInput
public void LoadFromHttpContext(HttpContext? context)
{
if (context == null) return;
var qStr = context.Request.Query["q"].ToString();
if (!string.IsNullOrEmpty(qStr))
{
var arg = JsonConvert.DeserializeObject<DObject>(qStr);
q.AddRange(arg);
}
string[] filter = new string[] { "pnum", "psize", "sort", "k", "q", "o" };
foreach (var item in context.Request.Query.Where(a => !filter.Contains(a.Key)))
{
if (item.Value.Count > 1)
{
q.Add(item.Key, item.Value.ToArray());
q[item.Key] = item.Value.ToArray();
}
else
{
q.Add(item.Key, item.Value.ToString());
q[item.Key] = item.Value.ToString();
}
}
}