CloudGamingAdmin/admin-server/CloudGaming.Code.DataBaseModel/CloudGamingAuditAop.cs
2024-11-15 02:58:48 +08:00

48 lines
1.1 KiB
C#

using CloudGaming.Core.Identity.Services;
using CloudGaming.Core;
using HZY.Framework.Core;
using HZY.Framework.Repository.EntityFramework.Interceptor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudGaming.Code.DataBaseModel;
public class CloudGamingAuditAop : AbstractFreeSqlAuditAop
{
/// <summary>
/// 获取当前用户 id
/// </summary>
/// <returns></returns>
protected override string? GetCurrentUserId()
{
try
{
using var scope = App.CreateScope();
var tokenService = scope?.ServiceProvider.GetService<JwtTokenService>(); //
var id = tokenService?.GetAccountIdByToken();
return id == Guid.Empty || id == null ? null : id.ToString();
}
catch (Exception)
{
// ignored
return null;
}
}
/// <summary>
/// 获取雪花id
/// </summary>
/// <returns></returns>
protected override long GetSnowflakeId()
{
return Tools.GetNewId();
}
}