增加称号跟徽章接口
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Application.Domain.Services
|
||||
{
|
||||
public interface IGameBadgeService
|
||||
{
|
||||
#region unit_user_badge
|
||||
Task<int> GetUserShowBadgeCount(string userId);
|
||||
Task<int> GetUserShowBadgeOnCount(string userId);
|
||||
Task<bool> UpdateUserBadgeShow(string ubId, int show);
|
||||
Task<unit_user_badge> GetUserBadegInfo(string ubId);
|
||||
Task<List<unit_user_badge>> GetUserBadgeList(string userId, int page, int limit, RefAsync<int> total);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,9 @@
|
||||
|
||||
public interface IGameMaxNameService
|
||||
{
|
||||
|
||||
#region unit_user_maxname
|
||||
Task<bool> UpdateUserMaxname(unit_user_maxname name);
|
||||
Task<unit_user_maxname> GetUserMaxnameInfo(string umnId);
|
||||
Task<List<unit_user_maxname>> GetUserMaxnameList(string userId, int page, int limit, RefAsync<int> total);
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Application.Domain.Services
|
||||
{
|
||||
public class GameBadgeService(ISqlSugarClient DbClient, IRedisCache redis) : IGameBadgeService, ITransient
|
||||
{
|
||||
#region unit_user_badge
|
||||
public async Task<int> GetUserShowBadgeCount(string userId)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_badge>();
|
||||
return await db.Queryable<unit_user_badge>().Where(i => i.userId == userId && i.show == 1).CountAsync();
|
||||
}
|
||||
public async Task<int> GetUserShowBadgeOnCount(string userId)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_badge>();
|
||||
return await db.Queryable<unit_user_badge>().Where(i => i.userId == userId).SumAsync(i => (int)i.showChat);
|
||||
}
|
||||
public async Task<bool> UpdateUserBadgeShow(string ubId, int show)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_badge>();
|
||||
bool isok = await db.Updateable<unit_user_badge>().SetColumns(i => i.show == show).Where(i => i.ubId == ubId)
|
||||
.ExecuteCommandAsync() > 0;
|
||||
if (isok)
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKeys, "UserBadge", "BadgeInfo");
|
||||
await redis.DelHashAsync(key, ubId);
|
||||
}
|
||||
return isok;
|
||||
}
|
||||
public async Task<unit_user_badge> GetUserBadegInfo(string ubId)
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKeys, "UserBadge", "BadgeInfo");
|
||||
var data = await redis.GetHashAsync<unit_user_badge>(key, ubId);
|
||||
if (data == null)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_badge>();
|
||||
data = await db.Queryable<unit_user_badge>().Where(i => i.ubId == ubId).SingleAsync();
|
||||
if (data != null)
|
||||
{
|
||||
await redis.AddHashAsync(key, ubId, data);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
public async Task<List<unit_user_badge>> GetUserBadgeList(string userId, int page, int limit, RefAsync<int> total)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_badge>();
|
||||
return await db.Queryable<unit_user_badge>().Where(i => i.userId == userId).OrderBy(i => i.addTime)
|
||||
.ToPageListAsync(page, limit, total);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,39 @@
|
||||
|
||||
public class GameMaxNameService(ISqlSugarClient DbClient, IRedisCache redis) : IGameMaxNameService, ITransient
|
||||
{
|
||||
|
||||
|
||||
#region unit_user_maxname
|
||||
public async Task<bool> UpdateUserMaxname(unit_user_maxname name)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_maxname>();
|
||||
bool isok = await db.Updateable(name).ExecuteCommandAsync() > 0;
|
||||
if (isok)
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKeys, "UserMaxname", "MaxnameInfo");
|
||||
await redis.DelHashAsync(key, name.umnId);
|
||||
}
|
||||
return isok;
|
||||
}
|
||||
public async Task<unit_user_maxname> GetUserMaxnameInfo(string umnId)
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKeys, "UserMaxname", "MaxnameInfo");
|
||||
var data = await redis.GetHashAsync<unit_user_maxname>(key, umnId);
|
||||
if (data == null)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_maxname>();
|
||||
data = await db.Queryable<unit_user_maxname>().Where(i => i.umnId == umnId).SingleAsync();
|
||||
if (data != null)
|
||||
{
|
||||
await redis.AddHashAsync(key, umnId, data);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
public async Task<List<unit_user_maxname>> GetUserMaxnameList(string userId, int page, int limit, RefAsync<int> total)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_maxname>();
|
||||
return await db.Queryable<unit_user_maxname>().Where(i => i.userId == userId).OrderBy(i => i.addTime)
|
||||
.ToPageListAsync(page, limit, total);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user