diff --git a/APIJSON.NET/APIJSON.NET.sln b/APIJSON.NET/APIJSON.NET.sln
index bf956bf..4c1e774 100644
--- a/APIJSON.NET/APIJSON.NET.sln
+++ b/APIJSON.NET/APIJSON.NET.sln
@@ -1,12 +1,14 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27703.2035
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.28803.202
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "APIJSON.NET", "APIJSON.NET\APIJSON.NET.csproj", "{FF647576-A104-4D54-954D-3547B4FDCDB2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "APIJSON.NET.Test", "APIJSON.NET.Test\APIJSON.NET.Test.csproj", "{0828346E-207E-49F8-AD57-E1AB6B6E4077}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiJson.Common", "APIJSONCommon\ApiJson.Common.csproj", "{3B79D4FD-0BC7-49FD-A3DD-E514433B4B35}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
{0828346E-207E-49F8-AD57-E1AB6B6E4077}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0828346E-207E-49F8-AD57-E1AB6B6E4077}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0828346E-207E-49F8-AD57-E1AB6B6E4077}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3B79D4FD-0BC7-49FD-A3DD-E514433B4B35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3B79D4FD-0BC7-49FD-A3DD-E514433B4B35}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3B79D4FD-0BC7-49FD-A3DD-E514433B4B35}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3B79D4FD-0BC7-49FD-A3DD-E514433B4B35}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj b/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj
index 01fe4ec..634243e 100644
--- a/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj
+++ b/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj
@@ -4,6 +4,10 @@
netcoreapp2.2
+
+
+
+
@@ -16,7 +20,7 @@
-
+
@@ -24,12 +28,15 @@
-
+
+
+
+
diff --git a/APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs b/APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs
index 709aa4a..1fd8d2e 100644
--- a/APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs
+++ b/APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs
@@ -12,6 +12,10 @@
using APIJSON.NET.Services;
using System.Reflection;
using Microsoft.AspNetCore.Cors;
+ using System.Threading.Tasks;
+ using System.IO;
+ using System.Text;
+ using System.Net.Http;
[Route("api/[controller]")]
[ApiController]
@@ -22,14 +26,28 @@ public class JsonController : ControllerBase
private SelectTable selectTable;
private DbContext db;
private readonly IIdentityService _identitySvc;
- public JsonController(SelectTable _selectTable, DbContext _db,IIdentityService identityService)
- {
+ private ITableMapper _tableMapper;
- selectTable = _selectTable;
+ public JsonController(IIdentityService identityService, ITableMapper tableMapper, DbContext _db)
+ {
db = _db;
+ _tableMapper = tableMapper;
_identitySvc = identityService;
+ selectTable = new SelectTable(_identitySvc, _tableMapper, _db.Db);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("/test")]
+ public ActionResult Test()
+ {
+ string str = "{\"page\":1,\"count\":3,\"query\":2,\"Org\":{\"@column\":\"Id,Name\"}}";
+ var content = new StringContent(str);
+ return Ok(content);
}
-
+
///
/// 查询
///
@@ -37,138 +55,43 @@ public JsonController(SelectTable _selectTable, DbContext _db,IIdentityService i
///
[HttpPost("/get")]
- public ActionResult Query([FromBody] JObject jobject)
+ public async Task Query([FromBody] JObject jobject)
{
- JObject ht = new JObject();
- ht.Add("code", "200");
- ht.Add("msg", "success");
- try
- {
- int page = 0, count = 0, query = 0, total = 0;
- foreach (var item in jobject)
- {
- string key = item.Key.Trim();
- JObject jb;
- if (key.Equals("[]"))
- {
- jb = JObject.Parse(item.Value.ToString());
- page = jb["page"] == null ? 0 : int.Parse(jb["page"].ToString());
- count = jb["count"] == null ? 0 : int.Parse(jb["count"].ToString());
- query = jb["query"] == null ? 0 : int.Parse(jb["query"].ToString());
- jb.Remove("page"); jb.Remove("count"); jb.Remove("query");
- var htt = new JArray();
- List tables = new List(), where = new List();
- foreach (var t in jb)
- {
- tables.Add(t.Key); where.Add(t.Value.ToString());
- }
- if (tables.Count > 0)
- {
- string table = tables[0];
- var temp = selectTable.GetTableData(table, page, count, where[0], null);
- if (query > 0)
- {
- total = temp.Item2;
- }
-
- foreach (var dd in temp.Item1)
- {
- var zht = new JObject();
- zht.Add(table, JToken.FromObject(dd));
- for (int i = 1; i < tables.Count; i++)
- {
- string subtable = tables[i];
- if (subtable.EndsWith("[]"))
- {
- subtable = subtable.TrimEnd("[]".ToCharArray());
- var jbb = JObject.Parse(where[i]);
- page = jbb["page"] == null ? 0 : int.Parse(jbb["page"].ToString());
- count = jbb["count"] == null ? 0 : int.Parse(jbb["count"].ToString());
+ JObject resultJobj = new SelectTable(_identitySvc, _tableMapper, db.Db).Query(jobject);
+ return Ok(resultJobj);
+ }
- var lt = new JArray();
- foreach (var d in selectTable.GetTableData(subtable, page, count, jbb[subtable].ToString(), zht).Item1)
- {
- lt.Add(JToken.FromObject(d));
- }
- zht.Add(tables[i], lt);
- }
- else
- {
- var ddf = selectTable.GetFirstData(subtable, where[i].ToString(), zht);
- if (ddf != null)
- {
- zht.Add(subtable, JToken.FromObject(ddf));
+ [HttpPost("/{table}")]
+ public async Task QueryByTable([FromRoute]string table)
+ {
+ string json = string.Empty;
+ using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
+ {
+ json = await reader.ReadToEndAsync();
+ }
- }
- }
- }
- htt.Add(zht);
- }
+ json = HttpUtility.UrlDecode(json);
+ JObject ht = new JObject();
- }
- if (query != 1)
- {
- ht.Add("[]", htt);
- }
- }
- else if (key.EndsWith("[]"))
- {
- jb = JObject.Parse(item.Value.ToString());
- page = jb["page"] == null ? 0 : int.Parse(jb["page"].ToString());
- count = jb["count"] == null ? 0 : int.Parse(jb["count"].ToString());
- query = jb["query"] == null ? 0 : int.Parse(jb["query"].ToString());
- jb.Remove("page"); jb.Remove("count"); jb.Remove("query");
- var htt = new JArray();
- foreach (var t in jb)
- {
- foreach (var d in selectTable.GetTableData(t.Key, page, count, t.Value.ToString(), null).Item1)
- {
- htt.Add(JToken.FromObject(d));
- }
- }
- ht.Add(key, htt);
- }
- else if (key.Equals("func"))
- {
- jb = JObject.Parse(item.Value.ToString());
- Type type = typeof(FuncList);
- Object obj = Activator.CreateInstance(type);
- var bb = new JObject();
- foreach (var f in jb)
- {
- var types = new List();
- var param = new List