This commit is contained in:
Putoo
2026-05-18 13:28:20 +08:00
parent 78759387f7
commit 974421ce9b
13 changed files with 200 additions and 39 deletions

View File

@@ -20,6 +20,6 @@ public class NoticeService:INoticeService,ITransient
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>().ToPageListAsync(page, limit, total);
return await db.Queryable<game_notice>().OrderByDescending(it=>it.addTime).ToPageListAsync(page, limit, total);
}
}

View File

@@ -25,7 +25,11 @@ public class GameAccountService : IGameAccountService, ITransient
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_account>();
var data = await db.Queryable<game_account>().Where(it => it.openId == openId).FirstAsync();
await _redisClient.AddHashAsync(key, openId, data);
if (data != null)
{
await _redisClient.AddHashAsync(key, openId, data);
}
return data;
}
}
@@ -41,11 +45,15 @@ public class GameAccountService : IGameAccountService, ITransient
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_account>();
var data = await db.Queryable<game_account>().Where(it => it.accId == accId).FirstAsync();
await _redisClient.AddHashAsync(key, accId, data);
if (data != null)
{
await _redisClient.AddHashAsync(key, accId, data);
}
return data;
}
}
public async Task<game_account> GetAccInfoByToken(string token)
{
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_account>();
@@ -86,7 +94,7 @@ public class GameAccountService : IGameAccountService, ITransient
}
}
public async Task<game_account> Regist(string userName, string nick, string pwd, string remAccId = "",
public async Task<game_account> Regist(string userName, string nick, string pwd, string remAccId = "",
string openId = "")
{
game_account result = new game_account();
@@ -116,12 +124,13 @@ public class GameAccountService : IGameAccountService, ITransient
{
result = null;
}
await _dbClient.AsTenant().CommitTranAsync();
}
catch
{
result = null;
await _dbClient.AsTenant().RollbackTranAsync();
await _dbClient.AsTenant().RollbackTranAsync();
}
return result;

View File

@@ -12,11 +12,13 @@ namespace Application.Web.Controllers.Pub
{
private readonly IAreaService _areaService;
private readonly INoticeService _noticeService;
private readonly IGameAccountService _accountService;
public PubController(IAreaService areaService, INoticeService noticeService)
public PubController(IAreaService areaService, INoticeService noticeService,IGameAccountService accountService)
{
_areaService = areaService;
_noticeService = noticeService;
_accountService = accountService;
}
/// <summary>
@@ -28,16 +30,35 @@ namespace Application.Web.Controllers.Pub
public async Task<IPoAction> GetMain(string? sid)
{
bool isOnline = false;
game_account account = new game_account();
if (!string.IsNullOrEmpty(sid))
{
isOnline = true;
account = await _accountService.GetAccInfoByToken(sid);
if (account != null)
{
isOnline = true;
}
}
var areaData = await _areaService.GetAreaData();
var notice = await _noticeService.GetNoticeDataByTake(5);
int OnCount = 100;
return PoAction.Ok(new { area = areaData, notice, isOnline, onCount = OnCount });
return PoAction.Ok(new { area = areaData, notice, isOnline, onCount = OnCount,account });
}
/// <summary>
/// 获取公告列表
/// </summary>
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetNoticeData(int page,int limit)
{
RefAsync<int> total = 0;
var data = await _noticeService.GetNoticeData(page, limit, total);
return PoAction.Ok(new { data, total=total.Value });
}
}
}

View File

@@ -4,6 +4,7 @@ global using Photon.Core.Services;
global using Photon.Core.SqlSugar;
global using Photon.Core.Assist;
global using Photon.Core.Timer;
global using SqlSugar;
global using Application.Service.Pub;
global using Application.Domain;