RoomController.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 RoomController : ControllerBase
  17. {
  18. private IRoomService RoomService { get; set; }
  19. public RoomController(IRoomService roomService)
  20. {
  21. RoomService = roomService;
  22. }
  23. [HttpGet]
  24. public async Task<ResultMessage> GetRoomList(int pageIndex, int pageSize, Guid? buildingId, Guid? floorId)
  25. {
  26. return ResultMessage.Success(RoomService.GetRoomList(pageIndex, pageSize, buildingId, floorId));
  27. }
  28. [HttpGet]
  29. public async Task<ResultMessage> GetRoomById(Guid? roomId)
  30. {
  31. return ResultMessage.Success(await RoomService.GetRoomById(roomId));
  32. }
  33. [HttpPost]
  34. public async Task<ResultMessage> Delete([FromBody] dynamic inputObject)
  35. {
  36. List<Guid> roomIdList = inputObject.roomIdList.ToObject<List<Guid>>();
  37. return ResultMessage.Success(await RoomService.Delete(roomIdList));
  38. }
  39. [HttpPost]
  40. public async Task<ResultMessage> Save([FromBody] dynamic inputObj)
  41. {
  42. RoomView data = inputObj["data"].ToObject<RoomView>();
  43. return ResultMessage.Success(await RoomService.Save(data, LoginUser.Current.UserID));
  44. }
  45. [HttpGet]
  46. [AllowAnonymous]
  47. public async Task<ResultMessage> GetRoomDepOrServiceList()
  48. {
  49. return ResultMessage.Success(await RoomService.GetRoomDepOrServiceList());
  50. }
  51. }
  52. }