diff --git a/README.md b/README.md
index 76218358..87c646ac 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ Yi框架-一套与SqlSugar一样爽的.Net6低代码开源框架。
适合.Net6学习、Sqlsugar学习 、项目二次开发。
集大成者,终究轮子
-Yi框架最新版本标签:`v1.1.7`,具体版本可以查看标签迭代
+Yi框架最新版本标签:`v1.1.8`,具体版本可以查看标签迭代
(项目与Sqlsugar同步更新,但这作者老杰哥代码天天爆肝到凌晨两点,我们也尽量会跟上他的脚步。更新频繁,所以可watching持续关注。)
diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj
index d7d79b45..e4e7aa28 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj
@@ -31,10 +31,6 @@
-
-
-
-
diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Base/NullValue.cs b/Yi.Framework.Net6/Yi.Framework.Common/Base/NullValue.cs
new file mode 100644
index 00000000..d9379f64
--- /dev/null
+++ b/Yi.Framework.Net6/Yi.Framework.Common/Base/NullValue.cs
@@ -0,0 +1,430 @@
+namespace System
+{
+ #region 无值定义
+
+ ///
+ /// 无值定义
+ ///
+ public class NullValue
+ {
+ ///
+ /// 唯一识别型的默认无值
+ ///
+ public static readonly Guid Guid = Guid.Empty;
+
+ ///
+ /// 日期时间的默认无值
+ ///
+ /// 解决C#DateTime最小值是SQL 2005不允许的范围内
+ public static readonly DateTime DateTime = DateTime.Parse("1753-1-1 12:00:01");
+
+ ///
+ /// JavaScript日期时间的默认无值
+ ///
+ ///
+ public static readonly DateTime JavaScriptDateTime = DateTime.Parse("1970-1-1 00:00:00");
+
+ #region 数字类型
+
+ ///
+ /// 短整数的默认无值
+ ///
+ public const short ShortInterger = -1;//short.MinValue;
+
+ ///
+ /// 整数的默认无值
+ ///
+ public const int Interger = -1;//int.MinValue;
+
+ ///
+ /// 长整数的默认无值
+ ///
+ public const long LongInterger = -1;//long.MinValue;
+
+ ///
+ /// Decimal数的默认无值
+ ///
+ public const decimal Decimal = -1;//decimal.MinValue;
+
+ ///
+ /// Float数的默认无值
+ ///
+ public const float Float = -1;//float.MinValue;
+
+ ///
+ /// Double数的默认无值
+ ///
+ public const double Double = -1;//double.MinValue;
+
+ ///
+ /// Byte数的默认无值
+ ///
+ public const byte Byte = byte.MinValue;
+
+ ///
+ /// SByte数的默认无值
+ ///
+ public const sbyte SByte = sbyte.MinValue;
+
+ #endregion
+
+ ///
+ /// 字串的默认无值
+ ///
+ public static readonly string String = String.Empty;
+
+ ///
+ /// 一般对象的判断
+ ///
+ public const Object Object = null;
+ }
+
+ #endregion
+
+ #region 无值的扩展方法
+
+ ///
+ /// 无值的扩展方法
+ ///
+ public static class NullValueExtensions
+ {
+ #region 一般类型
+
+ public static Guid TryToGuid(this string guid)
+ {
+ if (Guid.TryParse(guid, out var guid1))
+ {
+ return guid1;
+ }
+ return Guid.Empty;
+
+ }
+
+ public static string TryStringNull(this string value)
+ {
+ return value == null ? "" : value;
+
+ }
+
+ ///
+ /// Object类型无值判断
+ ///
+ /// 待判断对象
+ /// 是否为空(true--真,false--假)
+ public static bool IsNull(this object value)
+ {
+ if (value == null || value == NullValue.Object)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Object类型有值判断
+ ///
+ /// 待判断对象
+ /// 是否不为空(true--真,false--假)
+ public static bool IsNotNull(this object value)
+ {
+ return !value.IsNull();
+ }
+ public static bool IsGuidNotNull(this Guid? value)
+ {
+ return !value.IsGuidNull();
+ }
+ public static bool IsGuidNull(this Guid? value)
+ {
+ if (value == null || value == Guid.Empty)
+ {
+ return true;
+ }
+
+ return false;
+ }
+ ///
+ /// String类型无值判断
+ ///
+ /// 待判断对象
+ /// 是否为空(true--真,false--假)
+ public static bool IsNull(this String value)
+ {
+ if (string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// String类型有值判断
+ ///
+ /// 待判断对象
+ /// 是否不为空(true--真,false--假)
+ public static bool IsNotNull(this String value)
+ {
+ return !value.IsNull();
+ }
+
+ ///
+ /// Guid类型无值判断
+ ///
+ /// 待判断对象
+ /// 是否为空(true--真,false--假)
+ public static bool IsNull(this Guid value)
+ {
+ if (value == NullValue.Guid)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Guid类型有值判断
+ ///
+ /// 待判断对象
+ /// 是否不为空(true--真,false--假)
+ public static bool IsNotNull(this Guid value)
+ {
+ return !value.IsNull();
+ }
+
+ #region 数字类型
+
+ ///
+ /// ShortInterger类型无值判断
+ ///
+ /// 待判断对象
+ /// 是否为空(true--真,false--假)
+ public static bool IsNull(this short value)
+ {
+ if (value == NullValue.ShortInterger)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// ShortInterger类型有值判断
+ ///
+ /// 待判断对象
+ /// 是否不为空(true--真,false--假)
+ public static bool IsNotNull(this short value)
+ {
+ return !value.IsNull();
+ }
+
+ ///
+ /// Interger类型无值判断
+ ///
+ /// 待判断对象
+ /// 是否为空(true--真,false--假)
+ public static bool IsNull(this int value)
+ {
+ if (value == NullValue.Interger)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Interger类型有值判断
+ ///
+ /// 待判断对象
+ /// 是否不为空(true--真,false--假)
+ public static bool IsNotNull(this int value)
+ {
+ return !value.IsNull();
+ }
+
+ ///
+ /// LongInterger类型无值判断
+ ///
+ /// 待判断对象
+ /// 是否为空(true--真,false--假)
+ public static bool IsNull(this long value)
+ {
+ if (value == NullValue.LongInterger)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// LongInterger类型有值判断
+ ///
+ /// 待判断对象
+ /// 是否不为空(true--真,false--假)
+ public static bool IsNotNull(this long value)
+ {
+ return !value.IsNull();
+ }
+
+ ///
+ /// Decimal类型无值判断
+ ///
+ /// 待判断对象
+ /// 是否为空(true--真,false--假)
+ public static bool IsNull(this decimal value)
+ {
+ if (value == NullValue.Decimal)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Decimal类型有值判断
+ ///
+ /// 待判断对象
+ /// 是否不为空(true--真,false--假)
+ public static bool IsNotNull(this decimal value)
+ {
+ return !value.IsNull();
+ }
+
+ ///
+ /// Float类型无值判断
+ ///
+ /// 待判断对象
+ /// 是否为空(true--真,false--假)
+ public static bool IsNull(this float value)
+ {
+ if (value == NullValue.Float)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Float类型有值判断
+ ///
+ /// 待判断对象
+ /// 是否不为空(true--真,false--假)
+ public static bool IsNotNull(this float value)
+ {
+ return !value.IsNull();
+ }
+
+ ///
+ /// Double类型无值判断
+ ///
+ /// 待判断对象
+ /// 是否为空(true--真,false--假)
+ public static bool IsNull(this double value)
+ {
+ if (value == NullValue.Double)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Double类型有值判断
+ ///
+ /// 待判断对象
+ /// 是否不为空(true--真,false--假)
+ public static bool IsNotNull(this double value)
+ {
+ return !value.IsNull();
+ }
+
+ ///
+ /// Byte类型无值判断
+ ///
+ /// 待判断对象
+ /// 是否为空(true--真,false--假)
+ public static bool IsNull(this byte value)
+ {
+ if (value == NullValue.Byte)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Byte类型有值判断
+ ///
+ /// 待判断对象
+ /// 是否不为空(true--真,false--假)
+ public static bool IsNotNull(this byte value)
+ {
+ return !value.IsNull();
+ }
+
+ ///
+ /// SByte类型无值判断
+ ///
+ /// 待判断对象
+ /// 是否为空(true--真,false--假)
+ public static bool IsNull(this sbyte value)
+ {
+ if (value == NullValue.SByte)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// SByte类型有值判断
+ ///
+ /// 待判断对象
+ /// 是否不为空(true--真,false--假)
+ public static bool IsNotNull(this sbyte value)
+ {
+ return !value.IsNull();
+ }
+
+ #endregion
+
+ ///
+ /// DateTime类型无值判断
+ ///
+ /// 待判断对象
+ /// 是否为空(true--真,false--假)
+ public static bool IsNull(this DateTime value)
+ {
+ if (value == DateTime.MinValue || value <= NullValue.DateTime || value == NullValue.JavaScriptDateTime)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// DateTime类型有值判断
+ ///
+ /// 待判断对象
+ /// 是否不为空(true--真,false--假)
+ public static bool IsNotNull(this DateTime value)
+ {
+ return !value.IsNull();
+ }
+
+ #endregion
+ }
+
+ #endregion
+
+}
diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/DistinctHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/DistinctHelper.cs
new file mode 100644
index 00000000..1e245aaf
--- /dev/null
+++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/DistinctHelper.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Yi.Framework.Common.Helper
+{
+ public class Compare : IEqualityComparer
+ {
+ private Func _getField;
+ public Compare(Func getfield)
+ {
+ this._getField = getfield;
+ }
+ public bool Equals(T x, T y)
+ {
+ return EqualityComparer.Default.Equals(_getField(x), _getField(y));
+ }
+ public int GetHashCode(T obj)
+ {
+ return EqualityComparer.Default.GetHashCode(this._getField(obj));
+ }
+ }
+ public static class DistinctHelper
+ {
+ ///
+ /// 自定义Distinct扩展方法
+ ///
+ /// 要去重的对象类
+ /// 自定义去重的字段类型
+ /// 要去重的对象
+ /// 获取自定义去重字段的委托
+ ///
+ public static IEnumerable DistinctNew(this IEnumerable source, Func getfield)
+ {
+ return source.Distinct(new Compare(getfield));
+ }
+ }
+}
diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/ZipHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/ZipHelper.cs
new file mode 100644
index 00000000..90f1aa8c
--- /dev/null
+++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/ZipHelper.cs
@@ -0,0 +1,397 @@
+/***
+* Title:"基础工具" 项目
+* Title:"基础工具" 项目
+* 主题:压缩包帮助类
+* Description:
+* 功能:
+* 1、压缩单个文件
+* 2、压缩多个文件
+* 3、压缩多层目录
+* 4、递归遍历目录
+* 5、解压缩一个 zip 文件
+* 6、获取压缩文件中指定类型的文件
+* 7、获取压缩文件中的所有文件
+* Date:2021
+* Version:0.1版本
+* Author:Coffee
+* Modify Recoder:
+*/
+
+using ICSharpCode.SharpZipLib.Zip;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace Yi.Framework.Common.Helper
+{
+ public class ZipHelper
+ {
+ ///
+ /// 压缩单个文件
+ ///
+ /// 要压缩的文件
+ /// 压缩后的文件
+ /// 压缩等级
+ /// 每次写入大小
+ public static void ZipFile(string fileToZip, string zipedFile, int compressionLevel, int blockSize)
+ {
+ //如果文件没有找到,则报错
+ if (!File.Exists(fileToZip))
+ {
+ throw new FileNotFoundException("指定要压缩的文件: " + fileToZip + " 不存在!");
+ }
+
+ using (FileStream ZipFile = File.Create(zipedFile))
+ {
+ using (ZipOutputStream ZipStream = new ZipOutputStream(ZipFile))
+ {
+ using (FileStream StreamToZip = new FileStream(fileToZip, FileMode.Open, FileAccess.Read))
+ {
+ string fileName = fileToZip.Substring(fileToZip.LastIndexOf("\\") + 1);
+
+ ZipEntry ZipEntry = new ZipEntry(fileName);
+
+ ZipStream.PutNextEntry(ZipEntry);
+
+ ZipStream.SetLevel(compressionLevel);
+
+ byte[] buffer = new byte[blockSize];
+
+ int sizeRead = 0;
+
+ try
+ {
+ do
+ {
+ sizeRead = StreamToZip.Read(buffer, 0, buffer.Length);
+ ZipStream.Write(buffer, 0, sizeRead);
+ }
+ while (sizeRead > 0);
+ }
+ catch
+ {
+
+ }
+
+ StreamToZip.Close();
+ }
+
+ ZipStream.Finish();
+ ZipStream.Close();
+ }
+
+ ZipFile.Close();
+ }
+ }
+
+ ///
+ /// 压缩单个文件
+ ///
+ /// 要进行压缩的文件名
+ /// 压缩后生成的压缩文件名
+ public static void ZipFile(string fileToZip, string zipedFile)
+ {
+ //如果文件没有找到,则报错
+ if (!File.Exists(fileToZip))
+ {
+ throw new FileNotFoundException("指定要压缩的文件: " + fileToZip + " 不存在!");
+ }
+
+ using (FileStream fs = File.OpenRead(fileToZip))
+ {
+ byte[] buffer = new byte[fs.Length];
+ fs.Read(buffer, 0, buffer.Length);
+ fs.Close();
+
+ using (FileStream ZipFile = File.Create(zipedFile))
+ {
+ using (ZipOutputStream ZipStream = new ZipOutputStream(ZipFile))
+ {
+ string fileName = fileToZip.Substring(fileToZip.LastIndexOf("\\") + 1);
+ ZipEntry ZipEntry = new ZipEntry(fileName);
+ ZipStream.PutNextEntry(ZipEntry);
+ ZipStream.SetLevel(5);
+
+ ZipStream.Write(buffer, 0, buffer.Length);
+ ZipStream.Finish();
+ ZipStream.Close();
+ }
+ }
+ }
+ }
+
+ ///
+ /// 压缩多个文件到指定路径
+ ///
+ /// 压缩到哪个路径
+ /// 压缩文件名称
+ public static void ZipFile(List sourceFileNames, string zipFileName)
+ {
+ //压缩文件打包
+ using (ZipOutputStream s = new ZipOutputStream(File.Create(zipFileName)))
+ {
+ s.SetLevel(9);
+ byte[] buffer = new byte[4096];
+ foreach (string file in sourceFileNames)
+ {
+ if (Directory.Exists(file))// 先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
+ {
+ string pPath = "";
+ pPath += Path.GetFileName(file);
+ pPath += "\\";
+ ZipSetp(file, s, pPath, sourceFileNames);
+ }
+ else // 否则直接压缩文件
+ {
+
+ ZipEntry entry = new ZipEntry(Path.GetFileName(file));
+ entry.DateTime = DateTime.Now;
+ s.PutNextEntry(entry);
+ using (FileStream fs = File.OpenRead(file))
+ {
+ int sourceBytes;
+ do
+ {
+ sourceBytes = fs.Read(buffer, 0, buffer.Length);
+ s.Write(buffer, 0, sourceBytes);
+ } while (sourceBytes > 0);
+ }
+ }
+ }
+ s.Finish();
+ s.Close();
+ }
+ }
+
+
+ ///
+ /// 压缩多层目录
+ ///
+ /// 待压缩目录
+ /// 压缩后生成的压缩文件名,绝对路径
+ public static void ZipFileDirectory(string strDirectory, string zipedFile)
+ {
+ using (FileStream ZipFile = File.Create(zipedFile))
+ {
+ using (ZipOutputStream s = new ZipOutputStream(ZipFile))
+ {
+ s.SetLevel(9);
+ ZipSetp(strDirectory, s, "");
+ }
+ }
+ }
+
+ ///
+ /// 压缩多层目录
+ ///
+ /// 待压缩目录
+ /// 压缩后生成的压缩文件名,绝对路径
+ /// 指定要压缩的文件列表(完全路径)
+ public static void ZipFileDirectory(string strDirectory, string zipedFile, List files)
+ {
+ using (FileStream ZipFile = File.Create(zipedFile))
+ {
+ using (ZipOutputStream s = new ZipOutputStream(ZipFile))
+ {
+ s.SetLevel(9);
+ ZipSetp(strDirectory, s, "", files);
+ }
+ }
+ }
+
+ ///
+ /// 递归遍历目录
+ ///
+ /// 需遍历的目录
+ /// 压缩输出流对象
+ /// The parent path.
+ /// 需要压缩的文件
+ private static void ZipSetp(string strDirectory, ZipOutputStream s, string parentPath, List files = null!)
+ {
+ if (strDirectory[strDirectory.Length - 1] != Path.DirectorySeparatorChar)
+ {
+ strDirectory += Path.DirectorySeparatorChar;
+ }
+
+ string[] filenames = Directory.GetFileSystemEntries(strDirectory);
+
+ byte[] buffer = new byte[4096];
+ foreach (string file in filenames)// 遍历所有的文件和目录
+ {
+ if (files != null && !files.Contains(file))
+ {
+ continue;
+ }
+ if (Directory.Exists(file))// 先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
+ {
+ string pPath = parentPath;
+ pPath += Path.GetFileName(file);
+ pPath += "\\";
+ ZipSetp(file, s, pPath, files!);
+ }
+ else // 否则直接压缩文件
+ {
+ //打开压缩文件
+ string fileName = parentPath + Path.GetFileName(file);
+ ZipEntry entry = new ZipEntry(fileName);
+
+ entry.DateTime = DateTime.Now;
+
+ s.PutNextEntry(entry);
+ using (FileStream fs = File.OpenRead(file))
+ {
+ int sourceBytes;
+ do
+ {
+ sourceBytes = fs.Read(buffer, 0, buffer.Length);
+ s.Write(buffer, 0, sourceBytes);
+ } while (sourceBytes > 0);
+
+ }
+ }
+ }
+ }
+
+ ///
+ /// 解压缩一个 zip 文件。
+ ///
+ /// 压缩文件
+ /// 解压目录
+ /// zip 文件的密码。
+ /// 是否覆盖已存在的文件。
+ public static void UnZip(string zipedFile, string strDirectory, bool overWrite, string password)
+ {
+
+ if (strDirectory == "")
+ strDirectory = Directory.GetCurrentDirectory();
+ if (!strDirectory.EndsWith("\\"))
+ strDirectory = strDirectory + "\\";
+
+ using (ZipInputStream s = new ZipInputStream(File.OpenRead(zipedFile)))
+ {
+ if (password != null)
+ {
+ s.Password = password;
+ }
+ ZipEntry theEntry;
+
+ while ((theEntry = s.GetNextEntry()) != null)
+ {
+ string directoryName = "";
+ string pathToZip = "";
+ pathToZip = theEntry.Name;
+
+ if (pathToZip != "")
+ directoryName = Path.GetDirectoryName(pathToZip) + "\\";
+
+ string fileName = Path.GetFileName(pathToZip);
+
+ Directory.CreateDirectory(strDirectory + directoryName);
+
+ if (fileName != "")
+ {
+ if (File.Exists(strDirectory + directoryName + fileName) && overWrite || !File.Exists(strDirectory + directoryName + fileName))
+ {
+ using (FileStream streamWriter = File.Create(strDirectory + directoryName + fileName))
+ {
+ int size = 2048;
+ byte[] data = new byte[2048];
+ while (true)
+ {
+ size = s.Read(data, 0, data.Length);
+
+ if (size > 0)
+ streamWriter.Write(data, 0, size);
+ else
+ break;
+ }
+ streamWriter.Close();
+ }
+ }
+ }
+ }
+
+ s.Close();
+ }
+ }
+
+ ///
+ /// 解压缩一个 zip 文件。
+ ///
+ /// 压缩文件
+ /// 解压目录
+ /// 是否覆盖已存在的文件。
+ public static void UnZip(string zipedFile, string strDirectory, bool overWrite)
+ {
+ UnZip(zipedFile, strDirectory, overWrite, null!);
+ }
+
+ ///
+ /// 解压缩一个 zip 文件。
+ /// 覆盖已存在的文件。
+ ///
+ /// 压缩文件
+ /// 解压目录
+ public static void UnZip(string zipedFile, string strDirectory)
+ {
+ UnZip(zipedFile, strDirectory, true);
+ }
+
+ ///
+ /// 获取压缩文件中指定类型的文件
+ ///
+ /// 压缩文件
+ /// 文件类型(.txt|.exe)
+ /// 文件名称列表(包含子目录)
+ public static List GetFiles(string zipedFile, List fileExtension)
+ {
+ List files = new List();
+ if (!File.Exists(zipedFile))
+ {
+ //return files;
+ throw new FileNotFoundException(zipedFile);
+ }
+
+ using (ZipInputStream s = new ZipInputStream(File.OpenRead(zipedFile)))
+ {
+ ZipEntry theEntry;
+ while ((theEntry = s.GetNextEntry()) != null)
+ {
+ if (theEntry.IsFile)
+ {
+ //Console.WriteLine("Name : {0}", theEntry.Name);
+ if (fileExtension != null)
+ {
+ if (fileExtension.Contains(Path.GetExtension(theEntry.Name)))
+ {
+ files.Add(theEntry.Name);
+ }
+ }
+ else
+ {
+ files.Add(theEntry.Name);
+ }
+ }
+ }
+ s.Close();
+ }
+
+ return files;
+ }
+
+ ///
+ /// 获取压缩文件中的所有文件
+ ///
+ /// 压缩文件
+ /// 文件名称列表(包含子目录)
+ public static List GetFiles(string zipedFile)
+ {
+ return GetFiles(zipedFile, null!);
+ }
+
+
+
+ }//Class_end
+
+}
\ No newline at end of file
diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Yi.Framework.Common.csproj b/Yi.Framework.Net6/Yi.Framework.Common/Yi.Framework.Common.csproj
index 70af49f1..bcfa819d 100644
--- a/Yi.Framework.Net6/Yi.Framework.Common/Yi.Framework.Common.csproj
+++ b/Yi.Framework.Net6/Yi.Framework.Common/Yi.Framework.Common.csproj
@@ -8,6 +8,7 @@
+
diff --git a/Yi.Framework.Net6/Yi.Framework.Core/CacheClientDB.cs b/Yi.Framework.Net6/Yi.Framework.Core/CacheClientDB.cs
index 5142f3e3..3fc0d53b 100644
--- a/Yi.Framework.Net6/Yi.Framework.Core/CacheClientDB.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Core/CacheClientDB.cs
@@ -22,8 +22,19 @@ namespace Yi.Framework.Core
{
this._RedisOptions = redisConnOptions.CurrentValue;
}
+ //public CSRedisClient GetClient()
+ //{
+ // return client;
+ //}
+ //private CSRedisClient client=null;
+
+ // 为了以后全链路做准备
+
private T TryCatch(MyAction action)
{
+ //Stopwatch sw = Stopwatch.StartNew();
+ ////Exception ex = null;
+ ////bool isError = false;
var client2 = new CSRedisClient($"{_RedisOptions.Host}:{_RedisOptions.Prot},password={_RedisOptions.Password},defaultDatabase ={ _RedisOptions.DB }");
T result;
try
@@ -34,7 +45,9 @@ namespace Yi.Framework.Core
{
object p = null;
result = (T)p;
+ //isError = true;
Console.WriteLine(exinfo);
+
}
finally
{
@@ -55,6 +68,11 @@ namespace Yi.Framework.Core
return this.TryCatch((u) => u.Del(key));
}
+ public long HRemove(string key, params string[] par)
+ {
+ return this.TryCatch((u) => u.HDel(key, par));
+ }
+
public T Get(string key)
{
return this.TryCatch((u) => u.Get(key));
@@ -68,9 +86,36 @@ namespace Yi.Framework.Core
{
return this.TryCatch((u) => u.Set(key, data));
}
- public bool AddHash(string key,string field, T data)
+ public T QueuePop(string key)
{
- return this.TryCatch((u)=>u.HSet(key ,field,data));
+ return this.TryCatch((u) => u.RPop(key));
+ }
+ public long QueuePush(string key, T data)
+ {
+ return this.TryCatch((u) => u.LPush(key, data));
+ }
+ public long QueueLen(string key)
+ {
+ return TryCatch((u) => u.LLen(key));
+ }
+
+ public bool HSet(string key, string fieId, T data)
+ {
+ return this.TryCatch((u) => u.HSet(key, fieId, data));
+ }
+ public bool HSet(string key, string fieId, T data, TimeSpan time)
+ {
+ return this.TryCatch((u) =>
+ {
+ var res = u.HSet(key, fieId, data);
+ u.Expire(key, time);
+ return res;
+ });
+ }
+
+ public CSRedisClient Db()
+ {
+ return new CSRedisClient($"{_RedisOptions.Host}:{_RedisOptions.Prot},password={_RedisOptions.Password},defaultDatabase ={ _RedisOptions.DB }");
}
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Core/Yi.Framework.Core.csproj b/Yi.Framework.Net6/Yi.Framework.Core/Yi.Framework.Core.csproj
index fc9dce43..b88b0e6b 100644
--- a/Yi.Framework.Net6/Yi.Framework.Core/Yi.Framework.Core.csproj
+++ b/Yi.Framework.Net6/Yi.Framework.Core/Yi.Framework.Core.csproj
@@ -18,8 +18,6 @@
-
-
diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/Yi.Framework.Interface.csproj b/Yi.Framework.Net6/Yi.Framework.Interface/Yi.Framework.Interface.csproj
index a98e0345..da904855 100644
--- a/Yi.Framework.Net6/Yi.Framework.Interface/Yi.Framework.Interface.csproj
+++ b/Yi.Framework.Net6/Yi.Framework.Interface/Yi.Framework.Interface.csproj
@@ -10,7 +10,6 @@
-
diff --git a/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs b/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs
index cbdce58a..c08d4eee 100644
--- a/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Repository/IRepository.cs
@@ -25,5 +25,7 @@ namespace Yi.Framework.Repository
public Task UseSqlAsync(string sql, object parameters = null);
ISugarQueryable QueryConditionHandler(QueryCondition pars);
Task UpdateSuperSaveAsync(T data, Expression> columns);
+ Task> GetListAsync(Expression> where, Expression> order, OrderByType orderByType = OrderByType.Desc);
+ Task GetFirstAsync(Expression> where, Expression> order, OrderByType orderByType = OrderByType.Desc);
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs b/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs
index 4f413641..4ac255a6 100644
--- a/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Repository/Repository.cs
@@ -189,7 +189,23 @@ namespace Yi.Framework.Repository
.ToStorage();
return await x.AsInsertable.ExecuteCommandAsync() > 0;//插入可插入部分
}
+ ///
+ /// 方法重载,多条件获取第一个值
+ ///
+ ///
+ public async Task GetFirstAsync(Expression> where, Expression> order, OrderByType orderByType = OrderByType.Desc)
+ {
+ return await _Db.Queryable().Where(where).OrderBy(order, orderByType).FirstAsync();
+ }
+ ///
+ /// 方法重载,多条件获取范围
+ ///
+ ///
+ public async Task> GetListAsync(Expression> where, Expression> order, OrderByType orderByType = OrderByType.Desc)
+ {
+ return await _Db.Queryable().Where(where).OrderBy(order, orderByType).ToListAsync();
+ }
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Repository/Yi.Framework.Repository.csproj b/Yi.Framework.Net6/Yi.Framework.Repository/Yi.Framework.Repository.csproj
index 9eb1d78e..239ac7ef 100644
--- a/Yi.Framework.Net6/Yi.Framework.Repository/Yi.Framework.Repository.csproj
+++ b/Yi.Framework.Net6/Yi.Framework.Repository/Yi.Framework.Repository.csproj
@@ -11,7 +11,6 @@
-
diff --git a/Yi.Framework.Net6/Yi.Framework.Service/Yi.Framework.Service.csproj b/Yi.Framework.Net6/Yi.Framework.Service/Yi.Framework.Service.csproj
index 9f989a4a..3ff23470 100644
--- a/Yi.Framework.Net6/Yi.Framework.Service/Yi.Framework.Service.csproj
+++ b/Yi.Framework.Net6/Yi.Framework.Service/Yi.Framework.Service.csproj
@@ -9,11 +9,7 @@
-
-
-
-
diff --git a/Yi.Framework.Net6/Yi.Framework.Task/Yi.Framework.Job.csproj b/Yi.Framework.Net6/Yi.Framework.Task/Yi.Framework.Job.csproj
index 2939eae1..f13bb262 100644
--- a/Yi.Framework.Net6/Yi.Framework.Task/Yi.Framework.Job.csproj
+++ b/Yi.Framework.Net6/Yi.Framework.Task/Yi.Framework.Job.csproj
@@ -9,7 +9,6 @@
-
diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs
index 25aff44f..ebc23248 100644
--- a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs
+++ b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs
@@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Model.Models;
using System.IdentityModel.Tokens.Jwt;
+using System.IO;
namespace Yi.Framework.WebCore
{
@@ -51,5 +52,42 @@ namespace Yi.Framework.WebCore
//Name = claimlist.FirstOrDefault(u => u.Type == JwtRegisteredClaimNames.Name).Value
};
}
+
+ public static void FileInlineHandle(this HttpContext httpContext, string fileName)
+ {
+ string encodeFilename = System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.GetEncoding("UTF-8"));
+ httpContext.Response.Headers.Add("Content-Disposition", "inline;filename=" + encodeFilename);
+
+ }
+ public static void FileAttachmentHandle(this HttpContext httpContext, string fileName)
+ {
+ string encodeFilename = System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.GetEncoding("UTF-8"));
+ httpContext.Response.Headers.Add("Content-Disposition", "attachment;filename=" + encodeFilename);
+
+ }
+ public static string GetLanguage(this HttpContext httpContext)
+ {
+ string res = "zh-CN";
+ var str = httpContext.Request.Headers["Accept-Language"].FirstOrDefault();
+ if (str.IsNotNull())
+ {
+ res = str.Split(",")[0];
+ }
+ return res;
+
+ }
+
+ public static string GetBody(this HttpContext httpContext)
+ {
+ if (httpContext.Request.Body != null)
+ {
+ httpContext.Request.EnableBuffering();
+ httpContext.Request.Body.Position = 0;
+ StreamReader stream = new StreamReader(httpContext.Request.Body);
+ return stream.ReadToEndAsync().GetAwaiter().GetResult();
+ }
+ return "";
+
+ }
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SqlsugarExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SqlsugarExtension.cs
index 806f0622..63e12106 100644
--- a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SqlsugarExtension.cs
+++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SqlsugarExtension.cs
@@ -10,7 +10,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
{
public static class SqlsugarExtension
{
- public static void AddSqlsugarServer(this IServiceCollection services)
+ public static void AddSqlsugarServer(this IServiceCollection services, Action action = null)
{
@@ -61,6 +61,10 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
},
db =>
{
+ if (action.IsNotNull())
+ {
+ action(db);
+ }
db.Aop.DataExecuting = (oldValue, entityInfo) =>
{
diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj b/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj
index 27308c25..1a6baaf2 100644
--- a/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj
+++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj
@@ -34,10 +34,6 @@
-
-
-
-