111
This commit is contained in:
61
Service/Application.Web/Controllers/Map/MapController.cs
Normal file
61
Service/Application.Web/Controllers/Map/MapController.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user