111
This commit is contained in:
@@ -25,8 +25,9 @@ public interface IGameEquService
|
||||
|
||||
Task AddEquLog(unit_user_equ ueData, string code, string remark,
|
||||
bool isAddAttr = false);
|
||||
|
||||
|
||||
Task<List<unit_user_equ>> GetUserOnEqu(string userId);
|
||||
Task<bool> EquOnOrDown(unit_user_equ data, int state);
|
||||
#endregion
|
||||
|
||||
#region 辅助
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Application.Domain;
|
||||
using Azure.Core.Pipeline;
|
||||
|
||||
namespace Application.Domain;
|
||||
|
||||
public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGameEquService, ITransient
|
||||
{
|
||||
@@ -306,12 +308,48 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
await db.Insertable(logs).SplitTable().ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<List<unit_user_equ>> GetUserOnEqu(string userId)
|
||||
{
|
||||
var key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEqu");
|
||||
if (await redis.HExistsHashAsync(key, userId))
|
||||
{
|
||||
return await redis.GetHashAsync<List<unit_user_equ>>(key, userId);
|
||||
}
|
||||
else
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_equ>();
|
||||
var data = await db.Queryable<unit_user_equ>().Where(it => it.userId == userId && it.isOn == 1)
|
||||
.ToListAsync();
|
||||
await redis.AddHashAsync(key, userId, data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> EquOnOrDown(unit_user_equ data, int state)
|
||||
{
|
||||
data.isOn = state;
|
||||
if (data.opTime == 0)
|
||||
{
|
||||
data.opTime = 1;
|
||||
var equInfo = await GetEquInfo((int)data.equId);
|
||||
if (equInfo.useTime > 0)
|
||||
{
|
||||
data.useEndTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays((int)equInfo.useTime)) ;
|
||||
}
|
||||
}
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_equ>();
|
||||
bool result = await db.Updateable(data).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 辅助方法
|
||||
|
||||
Reference in New Issue
Block a user