This commit is contained in:
Putoo
2026-07-16 12:48:31 +08:00
parent c94b3ce200
commit 2cd2ed02f8
19 changed files with 138 additions and 20 deletions

View File

@@ -20,6 +20,8 @@ namespace Application.Domain
HandleExchangeData,//处理兑换数据
HandleTaskLog,//处理任务日志
HandelTaskUser,//处理角色任务
HandleClearChat,//清理频道信息
HandleMessageData,//处理消息类
}
}

View File

@@ -105,5 +105,22 @@
var taskService = App.GetService<IGameTaskService>();
await taskService.HandleUserTask();
}
/// <summary>
/// 清理频道信息
/// </summary>
/// <param name="context"></param>
[EventSubscribe(BusEventsEnum.BusEventsName.HandleClearChat, NumRetries = 0,RetryTimeout = 999999999)]
public async Task HandleClearChat(EventHandlerExecutingContext context)
{
var chatService = App.GetService<IGameChatService>();
await chatService.ClearChat();
}
[EventSubscribe(BusEventsEnum.BusEventsName.HandleMessageData, NumRetries = 0,RetryTimeout = 999999999)]
public async Task HandleMessageData(EventHandlerExecutingContext context)
{
var messageService = App.GetService<IMessageService>();
await messageService.HandleMessageData();
}
}
}

View File

@@ -17,6 +17,8 @@ public static class GameEnum
UpdateExchangeData,//更新兑换的记录
UpdateTaskLog,//更新任务日志
UpdateTaskUser,//更新角色任务
ClearChat,//清理频道信息
ClearMessage,//清理个人消息信息
}
public enum PropCode//游戏资源编码
{

View File

@@ -12,4 +12,5 @@ public interface IGameChatService
Task<bool> SendChat(string userId, string code, string sign, string par = "");
Task<game_chat> GetChatInfo(string chatId);
Task<bool> DeleteChat(string chatId, string opUser);
Task ClearChat();
}

View File

@@ -53,4 +53,6 @@ public interface IMessageService
Task<bool> SendBroadcast(string userId, string code, string msg);
#endregion
Task HandleMessageData();
}

View File

@@ -3,6 +3,7 @@
public interface INoticeService
{
Task<List<game_notice>> GetNoticeDataByTake(int take);
Task<List<game_notice>> GetNoticeDataByMap();
Task<List<game_notice>> GetNoticeData(int page, int limit, RefAsync<int> total);
Task<game_notice> GetNoticeInfo(string id);
}

View File

@@ -181,4 +181,11 @@ public class GameChatService : IGameChatService, ITransient
.Where(it => it.chatId == chatId)
.ExecuteCommandAsync() > 0;
}
public async Task ClearChat()
{
long time = TimeExtend.GetTimeStampSeconds;
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_chat>();
await db.Deleteable<game_chat>().Where(it => it.delTime < time).ExecuteCommandAsync();
}
}

View File

@@ -827,7 +827,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
private async Task<List<game_equ_make>> GetEquMakeData(int goodsId)
{
string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "EquUpData");
string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "EquMakeData");
if (await redis.HExistsHashAsync(key, goodsId.ToString()))
{
return await redis.GetHashAsync<List<game_equ_make>>(key, goodsId.ToString());

View File

@@ -435,4 +435,21 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess
}
#endregion
public async Task HandleMessageData()
{
long time = TimeExtend.GetTimeStampSeconds;
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_message>();
await db.Deleteable<unit_user_mail>().Where(it => it.endTime < time && it.isRead == 1)
.ExecuteCommandAsync(); //清理邮件
await db.Deleteable<unit_user_message>().Where(it => it.endTime < time && it.isRead == 1)
.ExecuteCommandAsync(); //清理消息
await db.Deleteable<unit_user_message_event>().Where(it => it.endTime < time).ExecuteCommandAsync(); //清理通知
//删除缓存
string msgKey = string.Format(UserCache.BaseCacheKeys, "Message", "MsgCount");
string eventKey = string.Format(UserCache.BaseCacheKeys, "Message", "EventCount");
string mailKey = string.Format(UserCache.BaseCacheKeys, "Message", "MailCount");
await redis.DelAsync(msgKey, eventKey, mailKey);
}
}

View File

@@ -1,6 +1,6 @@
namespace Application.Domain;
public class NoticeService:INoticeService,ITransient
public class NoticeService : INoticeService, ITransient
{
private readonly ISqlSugarClient _dbClient;
private readonly IRedisCache _redisClient;
@@ -14,13 +14,14 @@ public class NoticeService:INoticeService,ITransient
public async Task<List<game_notice>> GetNoticeDataByTake(int take)
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_notice>();
return await db.Queryable<game_notice>().Take(take).OrderByDescending(it=>it.addTime).ToListAsync();
return await db.Queryable<game_notice>().Take(take).OrderByDescending(it => it.addTime).ToListAsync();
}
public async Task<List<game_notice>> GetNoticeData(int page, int limit, RefAsync<int> total)
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_notice>();
return await db.Queryable<game_notice>().OrderByDescending(it=>it.addTime).ToPageListAsync(page, limit, total);
return await db.Queryable<game_notice>().OrderByDescending(it => it.addTime)
.ToPageListAsync(page, limit, total);
}
public async Task<game_notice> GetNoticeInfo(string id)
@@ -28,4 +29,19 @@ public class NoticeService:INoticeService,ITransient
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_notice>();
return await db.Queryable<game_notice>().Where(it => it.noticeId == id).SingleAsync();
}
public async Task<List<game_notice>> GetNoticeDataByMap()
{
string key = string.Format(BaseCache.BaseCacheKey, "Notice");
if (await _redisClient.ExistsAsync(key))
{
return await _redisClient.GetAsync<List<game_notice>>(key);
}
DateTime time = DateTime.Now;
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_notice>();
var data = await db.Queryable<game_notice>().OrderByDescending(it => it.endTime > time).ToListAsync();
await _redisClient.SetAsync(key, data, 3600);
return data;
}
}