DictionaryController.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Bowin.Common.ServiceToken.Permission;
  6. using Bowin.Common.WebModels;
  7. using YLShipBuildLandMap.Entity;
  8. using YLShipBuildLandMap.Entity.ViewModel;
  9. using YLShipBuildLandMap.Services.SystemSetting;
  10. using Microsoft.AspNetCore.Authorization;
  11. using Microsoft.AspNetCore.Http;
  12. using Microsoft.AspNetCore.Mvc;
  13. using Newtonsoft.Json.Linq;
  14. namespace YLShipBuildLandMap.Web.Controllers.SystemSetting
  15. {
  16. [Route("api/systemsetting/[controller]/[action]")]
  17. [ApiController]
  18. [Authorize]
  19. public class DictionaryController : ControllerBase
  20. {
  21. private IDictionaryService DictionaryService { get; set; }
  22. public DictionaryController(IDictionaryService dictionaryService)
  23. {
  24. DictionaryService = dictionaryService;
  25. }
  26. [HttpPost]
  27. [FunctionCode("9904")]
  28. public async Task<ResultMessage> GetList([FromBody] dynamic inputObject)
  29. {
  30. try
  31. {
  32. int? pageIndex = inputObject.pageIndex;
  33. int? pageSize = inputObject.pageSize;
  34. string dictionaryName = inputObject.dictionaryName;
  35. string dictionaryCode = inputObject.dictionaryCode;
  36. string name = inputObject.name;
  37. var dictionaryItemList = await DictionaryService.GetDictionaryItemList(pageIndex, pageSize, dictionaryName, dictionaryCode, name);
  38. return ResultMessage.Success(dictionaryItemList);
  39. }
  40. catch (Exception ex)
  41. {
  42. return ResultMessage.GetError(ex.Message);
  43. }
  44. }
  45. [HttpPost]
  46. public async Task<ResultMessage> GetDicList([FromBody] dynamic inputObject)
  47. {
  48. string code = inputObject.code;
  49. var list = await DictionaryService.GetDictionaryItemsbyCache(code);
  50. //System.Threading.Thread.Sleep(TimeSpan.FromSeconds(3));
  51. // var a = ResultMessage.Success(list);
  52. return ResultMessage.Success(list);
  53. }
  54. [HttpPost]
  55. public async Task<ResultMessage> GetTugboatTitleDicList([FromBody] dynamic inputObject)
  56. {
  57. string code = "TugboatTitle";
  58. var list = await DictionaryService.GetTugboatTitleDictionary(code);
  59. //System.Threading.Thread.Sleep(TimeSpan.FromSeconds(3));
  60. return ResultMessage.Success(list);
  61. }
  62. [HttpPost]
  63. public async Task<ResultMessage> GetDepartmentTitleDicList([FromBody] dynamic inputObject)
  64. {
  65. string code = "TugboatTitle";
  66. var list = await DictionaryService.GetDepartmentTitleDictionary(code);
  67. //System.Threading.Thread.Sleep(TimeSpan.FromSeconds(3));
  68. return ResultMessage.Success(list);
  69. }
  70. [HttpPost]
  71. public async Task<ResultMessage> GetDicListForSelect([FromBody] dynamic inputObject)
  72. {
  73. try
  74. {
  75. int? pageIndex = inputObject.pageindex;
  76. int? pageSize = inputObject.pagesize;
  77. string dictionaryName = inputObject.name;
  78. string dictionaryCode = inputObject.code;
  79. var dicList = await DictionaryService.GetDictionaryList(pageIndex, pageSize, dictionaryName, dictionaryCode);
  80. return ResultMessage.Success(dicList);
  81. }
  82. catch (Exception ex)
  83. {
  84. return ResultMessage.GetError(ex.Message);
  85. }
  86. }
  87. [HttpPost]
  88. [FunctionCode("990401")]
  89. public ResultMessage GetDicItem([FromBody] dynamic inputObject)
  90. {
  91. Guid? dicItemID = inputObject.dicItemID;
  92. return ResultMessage.Success(DictionaryService.GetDicItem(dicItemID));
  93. }
  94. [HttpPost]
  95. [FunctionCode("990402")]
  96. public async Task<ResultMessage> EditDicItem([FromBody] dynamic inputObject)
  97. {
  98. SysDictionaryItem dicItem = inputObject.dicItem.ToObject<SysDictionaryItem>();
  99. await DictionaryService.Save(dicItem, LoginUser.Current.UserID);
  100. return ResultMessage.Success();
  101. }
  102. [HttpPost]
  103. [FunctionCode("990403")]
  104. public async Task<ResultMessage> Delete([FromBody] dynamic inputObj)
  105. {
  106. try
  107. {
  108. List<Guid> dicItemIDList = inputObj.dicItemIDs.ToObject<List<Guid>>(); ;
  109. await DictionaryService.Delete(dicItemIDList);
  110. return ResultMessage.Success();
  111. }
  112. catch (Exception ex)
  113. {
  114. return ResultMessage.GetError(ex.Message);
  115. }
  116. }
  117. }
  118. }