BuildingController.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using Bowin.Common.WebModels;
  2. using Microsoft.AspNetCore.Authorization;
  3. using Microsoft.AspNetCore.Mvc;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using YLShipBuildLandMap.Entity.ViewModel;
  9. using YLShipBuildLandMap.Entity.ViewModel.Build;
  10. using YLShipBuildLandMap.Services.Build;
  11. namespace YLShipBuildLandMap.Web.Controllers.Build
  12. {
  13. [Route("api/build/[controller]/[action]")]
  14. [Authorize]
  15. [ApiController]
  16. public class BuildingController : ControllerBase
  17. {
  18. private IBuildingService BuildingService { get; set; }
  19. public BuildingController(IBuildingService buildingService)
  20. {
  21. BuildingService = buildingService;
  22. }
  23. [HttpGet]
  24. public async Task<ResultMessage> GetBuildingList()
  25. {
  26. return ResultMessage.Success(await BuildingService.GetBuildingList());
  27. }
  28. [HttpGet]
  29. [AllowAnonymous]
  30. public async Task<ResultMessage> GetFloorList(Guid? buildingId)
  31. {
  32. return ResultMessage.Success(await BuildingService.GetFloorList(buildingId));
  33. }
  34. [HttpGet]
  35. public async Task<ResultMessage> GetBuildingById(Guid? buildingId)
  36. {
  37. return ResultMessage.Success(await BuildingService.GetBuildingById(buildingId));
  38. }
  39. [HttpPost]
  40. public async Task<ResultMessage> DeleteBuilding([FromBody] dynamic inputObject)
  41. {
  42. List<Guid> idList = inputObject.buildingIds.ToObject<List<Guid>>();
  43. return ResultMessage.Success(await BuildingService.DeleteBuilding(idList));
  44. }
  45. [HttpPost]
  46. public async Task<ResultMessage> DeleteFloor([FromBody] dynamic inputObject)
  47. {
  48. Guid floorId = inputObject.buildingFloorId;
  49. return ResultMessage.Success(await BuildingService.DeleteFloor(floorId));
  50. }
  51. [HttpPost]
  52. public async Task<ResultMessage> SaveBuilding([FromBody] dynamic inputObj)
  53. {
  54. BuildingView data = inputObj["data"].ToObject<BuildingView>();
  55. List<FloorView> floorList = inputObj["floorList"].ToObject<List<FloorView>>();
  56. return ResultMessage.Success(await BuildingService.SaveBuilding(data, floorList, LoginUser.Current.UserID));
  57. }
  58. [HttpGet]
  59. [AllowAnonymous]
  60. public async Task<ResultMessage> GetBuildingXYAxisList(Guid? buildingId)
  61. {
  62. return ResultMessage.Success(await BuildingService.GetBuildingXYAxisList(buildingId));
  63. }
  64. [HttpGet]
  65. [AllowAnonymous]
  66. public async Task<ResultMessage> GetBuildingXyAxisGroupList(Guid? buildingId)
  67. {
  68. return ResultMessage.Success(await BuildingService.GetBuildingXyAxisGroupList(buildingId));
  69. }
  70. }
  71. }