diff --git a/Helpers/SimApiCache.cs b/Helpers/SimApiCache.cs
index 6006794..cbdbe4c 100644
--- a/Helpers/SimApiCache.cs
+++ b/Helpers/SimApiCache.cs
@@ -8,7 +8,7 @@ public class SimApiCache(IDistributedCache cache)
private const string Prefix = "SimApi:Cache:";
///
- /// 设置缓存
+ /// 设置缓存 (值不能为null)
///
///
///
@@ -64,6 +64,6 @@ public class SimApiCache(IDistributedCache cache)
public T? Get(string key)
{
var data = cache.GetString(Prefix + key);
- return data == null ? default : JsonSerializer.Deserialize(data);
+ return data == null ? default : SimApiUtil.FromJson(data);
}
}
\ No newline at end of file
diff --git a/Helpers/SimApiUtil.cs b/Helpers/SimApiUtil.cs
index 4ad7298..b93f11b 100644
--- a/Helpers/SimApiUtil.cs
+++ b/Helpers/SimApiUtil.cs
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
+using System.Net.Mail;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
@@ -94,6 +95,25 @@ public static class SimApiUtil
return regex.IsMatch(cell);
}
+ ///
+ /// 判断是否是Email地址
+ ///
+ ///
+ ///
+ public static bool CheckEmail(string email)
+ {
+ try
+ {
+ var m = new MailAddress(email);
+ return m.Address == email;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
+
///
/// MD5加密字符串
///
@@ -154,6 +174,17 @@ public static class SimApiUtil
return JsonSerializer.Serialize(obj, JsonOption);
}
+ ///
+ /// 将JSON解析为对象(控制台输出中文不会被编码)
+ ///
+ ///
+ ///
+ ///
+ public static T? FromJson(string jsonString)
+ {
+ return JsonSerializer.Deserialize(jsonString, JsonOption);
+ }
+
///
/// 分页
///