修改问题
This commit is contained in:
parent
a5c5fc72db
commit
c57a377d7a
|
|
@ -129,10 +129,9 @@ namespace CloudGaming.Code.Account
|
||||||
//创建设备号
|
//创建设备号
|
||||||
var dev = await ManageUserDevicesAsync(user, account, jwt.AccessToken);
|
var dev = await ManageUserDevicesAsync(user, account, jwt.AccessToken);
|
||||||
var key = $"user:login:{user.Id}";
|
var key = $"user:login:{user.Id}";
|
||||||
var accountUserLoginInfos = await RedisCache.StringGetAsync<List<AccountUserLoginInfo>>(key);
|
|
||||||
accountUserLoginInfos ??= new List<AccountUserLoginInfo>();
|
|
||||||
//创建redis缓存
|
//创建redis缓存
|
||||||
await RedisCache.StringSetAsync(key, $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", TimeSpan.FromHours(1));
|
await RedisCache.StringSetAsync(key, $"1", TimeSpan.FromHours(1));
|
||||||
//accountUserLoginInfos.Add(new AccountUserLoginInfo());
|
//accountUserLoginInfos.Add(new AccountUserLoginInfo());
|
||||||
T_User_Login_Log login_Log = new T_User_Login_Log()
|
T_User_Login_Log login_Log = new T_User_Login_Log()
|
||||||
{
|
{
|
||||||
|
|
@ -221,7 +220,7 @@ namespace CloudGaming.Code.Account
|
||||||
}
|
}
|
||||||
|
|
||||||
// 管理用户设备
|
// 管理用户设备
|
||||||
private async Task<T_User_Token> ManageUserDevicesAsync(T_User user, IUserAccount account, string accessToken)
|
private async Task<List<T_User_Token>> ManageUserDevicesAsync(T_User user, IUserAccount account, string accessToken)
|
||||||
{
|
{
|
||||||
var currentTime = DateTime.Now;
|
var currentTime = DateTime.Now;
|
||||||
var dev = string.IsNullOrEmpty(account.DeviceNumber)
|
var dev = string.IsNullOrEmpty(account.DeviceNumber)
|
||||||
|
|
@ -265,7 +264,7 @@ namespace CloudGaming.Code.Account
|
||||||
TokenMd5 = MD5Encryption.ComputeMD5Hash(accessToken)
|
TokenMd5 = MD5Encryption.ComputeMD5Hash(accessToken)
|
||||||
};
|
};
|
||||||
await Dao.DaoUser.Context.T_User_Token.AddAsync(existingDevice);
|
await Dao.DaoUser.Context.T_User_Token.AddAsync(existingDevice);
|
||||||
|
userLoginList.Add(existingDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -275,7 +274,7 @@ namespace CloudGaming.Code.Account
|
||||||
}
|
}
|
||||||
|
|
||||||
await Dao.DaoUser.Context.SaveChangesAsync();
|
await Dao.DaoUser.Context.SaveChangesAsync();
|
||||||
return existingDevice;
|
return userLoginList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新设备令牌信息
|
// 更新设备令牌信息
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace CloudGaming.Model.DbSqlServer.Db_Phone;
|
namespace CloudGaming.Model.DbSqlServer.Db_Phone;
|
||||||
|
|
@ -144,7 +145,8 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
|
||||||
public virtual DbSet<T_Videos> T_Videos { get; set; }
|
public virtual DbSet<T_Videos> T_Videos { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
=> optionsBuilder.UseSqlServer("Server=192.168.1.17;Database=CloudGamingPhone;User Id=sa;Password=Dbt@com@123;TrustServerCertificate=true;");
|
{ }
|
||||||
|
//=> optionsBuilder.UseSqlServer("Server=192.168.1.17;Database=CloudGamingPhone;User Id=sa;Password=Dbt@com@123;TrustServerCertificate=true;");
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ namespace HuanMeng.DotNetCore.Redis
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static ConcurrentDictionary<string, IDatabase> Redis { get; set; } = new ConcurrentDictionary<string, IDatabase>();
|
public static ConcurrentDictionary<string, IDatabase> Redis { get; set; } = new ConcurrentDictionary<string, IDatabase>();
|
||||||
|
|
||||||
|
public static ConcurrentDictionary<string, IServer> RedisServer { get; set; } = new ConcurrentDictionary<string, IServer>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|
@ -37,11 +39,29 @@ namespace HuanMeng.DotNetCore.Redis
|
||||||
{
|
{
|
||||||
var redis = ConnectionMultiplexer.Connect(redisConnection);
|
var redis = ConnectionMultiplexer.Connect(redisConnection);
|
||||||
database = redis.GetDatabase();
|
database = redis.GetDatabase();
|
||||||
|
//server.key
|
||||||
|
//redis.GetServer()
|
||||||
Redis.TryAdd(redisConnection, database);
|
Redis.TryAdd(redisConnection, database);
|
||||||
}
|
}
|
||||||
return database;
|
return database;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisConnection"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IServer GetServer(string redisConnection)
|
||||||
|
{
|
||||||
|
if (!RedisServer.TryGetValue(redisConnection, out var server))
|
||||||
|
{
|
||||||
|
var redis = ConnectionMultiplexer.Connect(redisConnection);
|
||||||
|
server = redis.GetServer("", "");
|
||||||
|
//server.key
|
||||||
|
//redis.GetServer()
|
||||||
|
RedisServer.TryAdd(redisConnection, server);
|
||||||
|
}
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|
@ -112,5 +132,17 @@ namespace HuanMeng.DotNetCore.Redis
|
||||||
// 将 RedisValue 转换为 T 类型
|
// 将 RedisValue 转换为 T 类型
|
||||||
return JsonConvert.DeserializeObject<T>(value);
|
return JsonConvert.DeserializeObject<T>(value);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 模糊查询key
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server"></param>
|
||||||
|
/// <param name="pattern"></param>
|
||||||
|
/// <param name="pageSize"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<string> ScanKeys(this IServer server, string pattern, int pageSize = 100)
|
||||||
|
{
|
||||||
|
var matchingKeys = server.Keys(pattern: pattern).Select(it => it.ToString()).ToList();
|
||||||
|
return matchingKeys;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user