This commit is contained in:
Putoo
2026-05-20 18:32:54 +08:00
parent 2c85872abd
commit 784bc66ef6
51 changed files with 1818 additions and 106 deletions

View File

@@ -0,0 +1,61 @@
using Microsoft.AspNetCore.Mvc;
namespace Application.Web.Controllers.Map;
/// <summary>
/// 地图接口
/// </summary>
[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;
}
/// <summary>
/// 获取地图主页信息
/// </summary>
/// <param name="map"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> 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);
}
}