using Bowin.Common.WebModels; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using YLShipBuildLandMap.Entity.ViewModel; using YLShipBuildLandMap.Entity.ViewModel.Build; using YLShipBuildLandMap.Services.Build; namespace YLShipBuildLandMap.Web.Controllers.Build { [Route("api/build/[controller]/[action]")] [Authorize] [ApiController] public class BuildingController : ControllerBase { private IBuildingService BuildingService { get; set; } public BuildingController(IBuildingService buildingService) { BuildingService = buildingService; } [HttpGet] public async Task GetBuildingList() { return ResultMessage.Success(await BuildingService.GetBuildingList()); } [HttpGet] [AllowAnonymous] public async Task GetFloorList(Guid? buildingId) { return ResultMessage.Success(await BuildingService.GetFloorList(buildingId)); } [HttpGet] public async Task GetBuildingById(Guid? buildingId) { return ResultMessage.Success(await BuildingService.GetBuildingById(buildingId)); } [HttpPost] public async Task DeleteBuilding([FromBody] dynamic inputObject) { List idList = inputObject.buildingIds.ToObject>(); return ResultMessage.Success(await BuildingService.DeleteBuilding(idList)); } [HttpPost] public async Task DeleteFloor([FromBody] dynamic inputObject) { Guid floorId = inputObject.buildingFloorId; return ResultMessage.Success(await BuildingService.DeleteFloor(floorId)); } [HttpPost] public async Task SaveBuilding([FromBody] dynamic inputObj) { BuildingView data = inputObj["data"].ToObject(); List floorList = inputObj["floorList"].ToObject>(); return ResultMessage.Success(await BuildingService.SaveBuilding(data, floorList, LoginUser.Current.UserID)); } [HttpGet] [AllowAnonymous] public async Task GetBuildingXYAxisList(Guid? buildingId) { return ResultMessage.Success(await BuildingService.GetBuildingXYAxisList(buildingId)); } [HttpGet] [AllowAnonymous] public async Task GetBuildingXyAxisGroupList(Guid? buildingId) { return ResultMessage.Success(await BuildingService.GetBuildingXyAxisGroupList(buildingId)); } } }