diff --git a/APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj b/APIJSON.NET/APIJSON.Data/APIJSON.Data.csproj
similarity index 79%
rename from APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj
rename to APIJSON.NET/APIJSON.Data/APIJSON.Data.csproj
index f6c0ce9..8a515d4 100644
--- a/APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj
+++ b/APIJSON.NET/APIJSON.Data/APIJSON.Data.csproj
@@ -1,7 +1,7 @@
- netstandard2.1
+ net8.0
0.0.11
0.0.11 升级sqlSugarCore版本 解决如果查找字段是关键字(例如:key)时出错的问题
@@ -20,13 +20,12 @@
-
-
-
+
+
+
+
-
-
-
+
diff --git a/APIJSON.NET/APIJSON.Data/ApiJsonNetDataModule.cs b/APIJSON.NET/APIJSON.Data/ApiJsonNetDataModule.cs
new file mode 100644
index 0000000..8dbe0dc
--- /dev/null
+++ b/APIJSON.NET/APIJSON.Data/ApiJsonNetDataModule.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Volo.Abp.Autofac;
+using Volo.Abp.Modularity;
+
+namespace APIJSON.Data;
+[DependsOn(
+ typeof(AbpAutofacModule))]
+public class ApiJsonNetDataModule : AbpModule
+{
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+
+ }
+}
diff --git a/APIJSON.NET/APIJSON.Data/Data/DbContext.cs b/APIJSON.NET/APIJSON.Data/Data/DbContext.cs
new file mode 100644
index 0000000..1f2ab40
--- /dev/null
+++ b/APIJSON.NET/APIJSON.Data/Data/DbContext.cs
@@ -0,0 +1,41 @@
+using APIJSON.Data.Models;
+using Microsoft.Extensions.Configuration;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using Volo.Abp.DependencyInjection;
+namespace APIJSON.Data;
+
+public class DbContext:ISingletonDependency
+{
+ public DbContext(IConfiguration options)
+ {
+ Db = new SqlSugarClient(new ConnectionConfig()
+ {
+ ConnectionString = options.GetConnectionString("ConnectionString"),
+ DbType = (DbType)Enum.Parse(typeof(DbType), options.GetConnectionString("DbType")), InitKeyType= InitKeyType.Attribute,
+ IsAutoCloseConnection = true
+ });
+ Db.Aop.OnLogExecuted = (sql, pars) => //SQL执行完事件
+ {
+
+ };
+ Db.Aop.OnLogExecuting = (sql, pars) => //SQL执行前事件
+ {
+
+ };
+ }
+ public SqlSugarClient Db;
+ public DbSet LoginDb { get { return new DbSet(Db); } }
+}
+public class DbSet : SimpleClient where T : class, new()
+{
+ public DbSet(SqlSugarClient context) : base(context)
+ {
+
+ }
+ public List GetByIds(dynamic[] ids)
+ {
+ return Context.Queryable().In(ids).ToList(); ;
+ }
+}
diff --git a/APIJSON.NET/APIJSON.Data/FuncList.cs b/APIJSON.NET/APIJSON.Data/FuncList.cs
new file mode 100644
index 0000000..7acc119
--- /dev/null
+++ b/APIJSON.NET/APIJSON.Data/FuncList.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Linq;
+
+namespace APIJSON.Data;
+
+///
+/// 自定义方法
+///
+public class FuncList
+{
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public string Merge(object a, object b)
+ {
+ return a.ToString() + b.ToString();
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public object MergeObj(object a, object b)
+ {
+ return new { a, b };
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public bool isContain(object a, object b)
+ {
+ return a.ToString().Split(',').Contains(b);
+ }
+}
diff --git a/APIJSON.NET/APIJSON.Data/Infrastructure/SimpleStringCipher.cs b/APIJSON.NET/APIJSON.Data/Infrastructure/SimpleStringCipher.cs
new file mode 100644
index 0000000..43b09bc
--- /dev/null
+++ b/APIJSON.NET/APIJSON.Data/Infrastructure/SimpleStringCipher.cs
@@ -0,0 +1,134 @@
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace APIJSON.Data;
+
+public class SimpleStringCipher
+{
+ public static SimpleStringCipher Instance { get; }
+
+ ///
+ /// This constant string is used as a "salt" value for the PasswordDeriveBytes function calls.
+ /// This size of the IV (in bytes) must = (keysize / 8). Default keysize is 256, so the IV must be
+ /// 32 bytes long. Using a 16 character string here gives us 32 bytes when converted to a byte array.
+ ///
+ public byte[] InitVectorBytes;
+
+ ///
+ /// Default password to encrypt/decrypt texts.
+ /// It's recommented to set to another value for security.
+ /// Default value: "gsKnGZ041HLL4IM8"
+ ///
+ public static string DefaultPassPhrase { get; set; }
+
+ ///
+ /// Default value: Encoding.ASCII.GetBytes("jkE49230Tf093b42")
+ ///
+ public static byte[] DefaultInitVectorBytes { get; set; }
+
+ ///
+ /// Default value: Encoding.ASCII.GetBytes("hgt!16kl")
+ ///
+ public static byte[] DefaultSalt { get; set; }
+
+ ///
+ /// This constant is used to determine the keysize of the encryption algorithm.
+ ///
+ public const int Keysize = 256;
+
+ static SimpleStringCipher()
+ {
+ DefaultPassPhrase = "gsKnGZ041HLL4IM9";
+ DefaultInitVectorBytes = Encoding.ASCII.GetBytes("jkE49230Tf093b42");
+ DefaultSalt = Encoding.ASCII.GetBytes("hgt!11kl");
+ Instance = new SimpleStringCipher();
+ }
+
+ public SimpleStringCipher()
+ {
+ InitVectorBytes = DefaultInitVectorBytes;
+ }
+
+ public string Encrypt(string plainText, string passPhrase = null, byte[] salt = null)
+ {
+ if (plainText == null)
+ {
+ return null;
+ }
+
+ if (passPhrase == null)
+ {
+ passPhrase = DefaultPassPhrase;
+ }
+
+ if (salt == null)
+ {
+ salt = DefaultSalt;
+ }
+
+ var plainTextBytes = Encoding.UTF8.GetBytes(plainText);
+ using (var password = new Rfc2898DeriveBytes(passPhrase, salt))
+ {
+ var keyBytes = password.GetBytes(Keysize / 8);
+ using (var symmetricKey = Aes.Create())
+ {
+ symmetricKey.Mode = CipherMode.CBC;
+ using (var encryptor = symmetricKey.CreateEncryptor(keyBytes, InitVectorBytes))
+ {
+ using (var memoryStream = new MemoryStream())
+ {
+ using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
+ {
+ cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);
+ cryptoStream.FlushFinalBlock();
+ var cipherTextBytes = memoryStream.ToArray();
+ return Convert.ToBase64String(cipherTextBytes);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public string Decrypt(string cipherText, string passPhrase = null, byte[] salt = null)
+ {
+ if (string.IsNullOrEmpty(cipherText))
+ {
+ return null;
+ }
+
+ if (passPhrase == null)
+ {
+ passPhrase = DefaultPassPhrase;
+ }
+
+ if (salt == null)
+ {
+ salt = DefaultSalt;
+ }
+
+ var cipherTextBytes = Convert.FromBase64String(cipherText);
+ using (var password = new Rfc2898DeriveBytes(passPhrase, salt))
+ {
+ var keyBytes = password.GetBytes(Keysize / 8);
+ using (var symmetricKey = Aes.Create())
+ {
+ symmetricKey.Mode = CipherMode.CBC;
+ using (var decryptor = symmetricKey.CreateDecryptor(keyBytes, InitVectorBytes))
+ {
+ using (var memoryStream = new MemoryStream(cipherTextBytes))
+ {
+ using (var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read))
+ {
+ var plainTextBytes = new byte[cipherTextBytes.Length];
+ var decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length);
+ return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount);
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/APIJSON.NET/APIJSON.Data/Infrastructure/StringExtensions.cs b/APIJSON.NET/APIJSON.Data/Infrastructure/StringExtensions.cs
new file mode 100644
index 0000000..240b92b
--- /dev/null
+++ b/APIJSON.NET/APIJSON.Data/Infrastructure/StringExtensions.cs
@@ -0,0 +1,28 @@
+namespace APIJSON.Data;
+
+using System;
+using System.Text.RegularExpressions;
+public static class StringExtensions
+{
+
+ ///
+ /// 是否有值
+ ///
+ ///
+ ///
+ public static bool IsValue(this object str)
+ {
+ return str != null && !string.IsNullOrEmpty(str.ToString());
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string GetParamName(this string param)
+ {
+ return param + new Random().Next(1, 100);
+ }
+
+}
\ No newline at end of file
diff --git a/APIJSON.NET/APIJSON.Data/Models/DbOptions.cs b/APIJSON.NET/APIJSON.Data/Models/DbOptions.cs
new file mode 100644
index 0000000..c33da47
--- /dev/null
+++ b/APIJSON.NET/APIJSON.Data/Models/DbOptions.cs
@@ -0,0 +1,15 @@
+namespace APIJSON.Data;
+
+using global::SqlSugar;
+public class DbOptions
+{
+ ///
+ ///
+ ///
+ public DbType DbType { get; set; }
+
+ ///
+ ///
+ ///
+ public string ConnectionString { get; set; }
+}
diff --git a/APIJSON.NET/APIJSON.Data/Models/Login.cs b/APIJSON.NET/APIJSON.Data/Models/Login.cs
new file mode 100644
index 0000000..0dcdf11
--- /dev/null
+++ b/APIJSON.NET/APIJSON.Data/Models/Login.cs
@@ -0,0 +1,19 @@
+using SqlSugar;
+using System;
+
+namespace APIJSON.Data.Models;
+
+public class Login
+{
+ [SugarColumn(IsNullable = false, IsPrimaryKey = true)]
+ public int userId { get; set; }
+ [SugarColumn(Length = 100, ColumnDescription = "用户名")]
+ public string userName { get; set; }
+ [SugarColumn(Length = 200, ColumnDescription = "密码")]
+ public string passWord { get; set; }
+ [SugarColumn(Length = 100, ColumnDescription = "密码盐")]
+ public string passWordSalt { get; set; }
+ [SugarColumn(Length = 100, ColumnDescription = "权限组")]
+ public string roleCode { get; set; }
+
+}
diff --git a/APIJSON.NET/APIJSON.Data/Models/RoleItem.cs b/APIJSON.NET/APIJSON.Data/Models/RoleItem.cs
new file mode 100644
index 0000000..ba16bc6
--- /dev/null
+++ b/APIJSON.NET/APIJSON.Data/Models/RoleItem.cs
@@ -0,0 +1,18 @@
+namespace APIJSON.Data.Models;
+
+public class RoleItem
+{
+ public string[] Table { get; set; }
+ public string[] Column { get; set; }
+ public string[] Filter { get; set; }
+}
+public class Role
+{
+ public string Name { get; set; }
+ public RoleItem Select { get; set; }
+ public RoleItem Update { get; set; }
+ public RoleItem Insert { get; set; }
+ public RoleItem Delete { get; set; }
+
+}
+
diff --git a/APIJSON.NET/APIJSONCommon/Properties/AssemblyInfo.cs b/APIJSON.NET/APIJSON.Data/Properties/AssemblyInfo.cs
similarity index 100%
rename from APIJSON.NET/APIJSONCommon/Properties/AssemblyInfo.cs
rename to APIJSON.NET/APIJSON.Data/Properties/AssemblyInfo.cs
diff --git a/APIJSON.NET/APIJSON.Data/SelectTable.cs b/APIJSON.NET/APIJSON.Data/SelectTable.cs
new file mode 100644
index 0000000..8aa9e2d
--- /dev/null
+++ b/APIJSON.NET/APIJSON.Data/SelectTable.cs
@@ -0,0 +1,832 @@
+namespace APIJSON.Data;
+
+using AspectCore.Extensions.Reflection;
+using global::SqlSugar;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Dynamic;
+using System.Linq;
+using System.Text.RegularExpressions;
+
+///
+///
+///
+public class SelectTable
+{
+ private readonly IIdentityService _identitySvc;
+ private readonly ITableMapper _tableMapper;
+ private readonly SqlSugarClient db;
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public SelectTable(IIdentityService identityService, ITableMapper tableMapper, SqlSugarClient dbClient)
+ {
+ _identitySvc = identityService;
+ _tableMapper = tableMapper;
+ db = dbClient;
+ }
+ ///
+ /// 判断表名是否正确
+ ///
+ ///
+ ///
+ public virtual bool IsTable(string table)
+ {
+ return db.DbMaintenance.GetTableInfoList().Any(it => it.Name.Equals(table, StringComparison.CurrentCultureIgnoreCase));
+ }
+ ///
+ /// 判断表的列名是否正确
+ ///
+ ///
+ ///
+ ///
+ public virtual bool IsCol(string table, string col)
+ {
+ return db.DbMaintenance.GetColumnInfosByTableName(table).Any(it => it.DbColumnName.Equals(col, StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public virtual Tuple GetTableData(string subtable, int page, int count, int query, string json, JObject dd)
+ {
+
+ var role = _identitySvc.GetSelectRole(subtable);
+ if (!role.Item1)//没有权限返回异常
+ {
+ throw new Exception(role.Item2);
+ }
+ string selectrole = role.Item2;
+ subtable = _tableMapper.GetTableName(subtable);
+
+ JObject values = JObject.Parse(json);
+ page = values["page"] == null ? page : int.Parse(values["page"].ToString());
+ count = values["count"] == null ? count : int.Parse(values["count"].ToString());
+ query = values["query"] == null ? query : int.Parse(values["query"].ToString());
+ values.Remove("page");
+ values.Remove("count");
+ var tb = sugarQueryable(subtable, selectrole, values, dd);
+ if (query == 1)//1-总数
+ return new Tuple(new List