fix simapi cache
This commit is contained in:
@@ -8,7 +8,7 @@ public class SimApiCache(IDistributedCache cache)
|
|||||||
private const string Prefix = "SimApi:Cache:";
|
private const string Prefix = "SimApi:Cache:";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置缓存
|
/// 设置缓存 (值不能为null)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key"></param>
|
/// <param name="key"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
@@ -64,6 +64,6 @@ public class SimApiCache(IDistributedCache cache)
|
|||||||
public T? Get<T>(string key)
|
public T? Get<T>(string key)
|
||||||
{
|
{
|
||||||
var data = cache.GetString(Prefix + key);
|
var data = cache.GetString(Prefix + key);
|
||||||
return data == null ? default : JsonSerializer.Deserialize<T>(data);
|
return data == null ? default : SimApiUtil.FromJson<T>(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Mail;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -94,6 +95,25 @@ public static class SimApiUtil
|
|||||||
return regex.IsMatch(cell);
|
return regex.IsMatch(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断是否是Email地址
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="email"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool CheckEmail(string email)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var m = new MailAddress(email);
|
||||||
|
return m.Address == email;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MD5加密字符串
|
/// MD5加密字符串
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -154,6 +174,17 @@ public static class SimApiUtil
|
|||||||
return JsonSerializer.Serialize(obj, JsonOption);
|
return JsonSerializer.Serialize(obj, JsonOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将JSON解析为对象(控制台输出中文不会被编码)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="jsonString"></param>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T? FromJson<T>(string jsonString)
|
||||||
|
{
|
||||||
|
return JsonSerializer.Deserialize<T>(jsonString, JsonOption);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分页
|
/// 分页
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user