feat: 新增SDK模块、OSS相关功能并优化Redis与代码扩展

1.  新增API版本枚举SDK项,创建SDK基础控制器
2.  添加IList、string扩展方法,新增时间戳扩展工具
3.  新增OSS配置、STS凭证服务、文件处理相关代码
4.  重构Redis缓存组件,替换StackExchange.Redis为CSRedisCore
5.  修复原有Redis操作方法调用,新增基础控制器快捷返回方法
6.  新增阿里云OSS、短信、VOD相关SDK依赖
7.  配置阿里云OSS相关参数到appsettings
This commit is contained in:
glz
2026-06-09 14:36:46 +08:00
parent 1d86580db7
commit 77778f67c1
20 changed files with 748 additions and 146 deletions

View File

@ -7,6 +7,10 @@ namespace QYZH.InteractiveMagazine.Common.Extensions
/// </summary>
public static class DateTimeExtension
{
/// <summary>
/// 时间戳起始日期
/// </summary>
public static readonly DateTime TimestampStart = new(1970, 1, 1, 0, 0, 0, 0);
/// <summary>
/// 转换为Unix时间戳(秒)
/// </summary>
@ -84,5 +88,15 @@ namespace QYZH.InteractiveMagazine.Common.Extensions
{
return dateTime.Date.AddDays(1).AddTicks(-1);
}
public static long ToTimestamp(this DateTime dateTime, bool milliseconds = false)
{
var timestamp = dateTime.ToUniversalTime() - TimestampStart;
return (long)(milliseconds ? timestamp.TotalMilliseconds : timestamp.TotalSeconds);
}
public static long ToMillisecondsTimestamp(this DateTime dateTime)
{
return ToTimestamp(dateTime, true);
}
}
}

View File

@ -90,5 +90,10 @@ namespace QYZH.InteractiveMagazine.Common.Extensions
return dictionary;
}
public static bool IsNull<T>(this IList<T>? s)
{
return s == null || s?.Count() < 1;
}
}
}

View File

@ -146,5 +146,22 @@ namespace QYZH.InteractiveMagazine.Common.Extensions
return Regex.IsMatch(input, pattern);
}
/// <summary>
/// 判断字符串是否为Null、空
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool IsNull(this string s)
{
return string.IsNullOrWhiteSpace(s);
}
public static string RemoveDomain(this string str)
{
if (str.IsNull()) return str;
// 匹配域名后的路径部分(包括第一个/
return Regex.Replace(str, @"https?://[^/]+/([^""\s<>]*)", "$1");
}
}
}