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; public MapController(IUnitUserService userService, IGameMapService mapService) { _userService = userService; _mapService = mapService; } /// /// 获取地图主页信息 /// /// /// [HttpGet] public async Task GetMapData(string? map) { string userId = StateHelper.userId; 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); } //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 }; return PoAction.Ok(ret); } }