36 lines
1.5 KiB
C#
36 lines
1.5 KiB
C#
namespace Application.Domain;
|
|
|
|
public class GameCdkService(ISqlSugarClient DbClient, IRedisCache redis) : IGameCdkService, ITransient
|
|
{
|
|
public async Task<game_cdk> GetCdkInfo(int cdkId)
|
|
{
|
|
var db = DbClient.AsTenant().GetConnectionWithAttr<game_cdk>();
|
|
return await db.Queryable<game_cdk>().Where(it => it.cdkId == cdkId).SingleAsync();
|
|
}
|
|
|
|
public async Task<game_cdk_item> GetCdkItemInfo(string cdk)
|
|
{
|
|
var db = DbClient.AsTenant().GetConnectionWithAttr<game_cdk_item>();
|
|
return await db.Queryable<game_cdk_item>().Where(it => it.ciId == cdk).SingleAsync();
|
|
}
|
|
|
|
public async Task<bool> UpdateCdkUser(string cdk, string userId)
|
|
{
|
|
var db = DbClient.AsTenant().GetConnectionWithAttr<game_cdk_item>();
|
|
return await db.Updateable<game_cdk_item>().SetColumns(it => it.userId == userId)
|
|
.SetColumns(it => it.upTime == DateTime.Now)
|
|
.Where(it => it.ciId == cdk).ExecuteCommandAsync() > 0;
|
|
}
|
|
|
|
public async Task<int> GetUserCdkCount(int cdkId, string userId)
|
|
{
|
|
var db = DbClient.AsTenant().GetConnectionWithAttr<game_cdk_item>();
|
|
return await db.Queryable<game_cdk_item>().Where(it => it.cdkId == cdkId && it.userId == userId).CountAsync();
|
|
}
|
|
|
|
public async Task<bool> AddCdkItem(List<game_cdk_item> data)
|
|
{
|
|
var db = DbClient.AsTenant().GetConnectionWithAttr<game_cdk_item>();
|
|
return await db.Insertable(data).ExecuteCommandAsync() > 0;
|
|
}
|
|
} |