using Microsoft.AspNetCore.Mvc; namespace Application.Web.Controllers.Map; /// /// 地图接口 /// [ApiExplorerSettings(GroupName = "Map")] [Route("Map/[controller]/[action]")] [ApiController] [Authorize] public class MapController : ControllerBase { private readonly IUnitUserService _userService; private readonly IGameMapService _mapService; private readonly IGameChatService _chatService; public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService) { _userService = userService; _mapService = mapService; _chatService = chatService; } /// /// 获取地图主页信息 /// /// /// [HttpGet] public async Task GetMapData(string? map) { string userId = StateHelper.userId; int area = StateHelper.areaId; var onMap = await _mapService.GetUserOnMap(userId); game_city_map mapInfo = new game_city_map(); if (string.IsNullOrEmpty(map)) { mapInfo = await _mapService.GetMapInfo(onMap.mapId); } else { mapInfo = await _mapService.GetMapInfo(map); } //公聊信息 string teamId = ""; string groupId = ""; var chatData = await _chatService.GetChatTop(area, 2, teamId, groupId); //NPC信息 var npcData = await _mapService.GetMapNpc(mapInfo.mapId); npcData = npcData.FindAll(it => GameTool.AreaVerify(StateHelper.areaId, it.areaId)); //城市信息 var cityInfo = await _mapService.GetCityInfo((int)mapInfo.cityId); #region 更新在线 string ip = ComHelper.GetClientUserIp(HttpContext); await _mapService.UpdateUserOnMap(userId, ip, mapInfo.mapId); #endregion object ret = new { mapInfo, cityInfo, npcData, chatData }; return PoAction.Ok(ret); } }