using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Application.Web.Controllers.Pub { /// /// 公共接口 /// [Route("[controller]/[action]")] [ApiController] public class PubController : ControllerBase { private readonly IAreaService _areaService; private readonly INoticeService _noticeService; private readonly IGameAccountService _accountService; public PubController(IAreaService areaService, INoticeService noticeService,IGameAccountService accountService) { _areaService = areaService; _noticeService = noticeService; _accountService = accountService; } /// /// 获取首页信息 /// /// /// [HttpGet] public async Task GetMain(string? sid) { bool isOnline = false; game_account account = new game_account(); if (!string.IsNullOrEmpty(sid)) { 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,account }); } /// /// 获取公告列表 /// /// /// /// [HttpGet] public async Task GetNoticeData(int page,int limit) { RefAsync total = 0; var data = await _noticeService.GetNoticeData(page, limit, total); return PoAction.Ok(new { data, total=total.Value }); } } }