SysDictItemController.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using Attribute;
  2. using Common;
  3. using Dto;
  4. using Vo;
  5. using Enums;
  6. using Filters;
  7. using Infrastructure;
  8. using Infrastructure.Model;
  9. using Mapster;
  10. using Microsoft.AspNetCore.Mvc;
  11. using Middleware;
  12. using Model;
  13. using Services;
  14. using Model.Base;
  15. namespace Controllers
  16. {
  17. /// <summary>
  18. /// SysDictItem)Controller
  19. /// </summary>
  20. // [Route("SysDictItem")]
  21. // [ApiExplorerSettings(GroupName = "SysDictItem")]
  22. public class SysDictItemController : BaseController
  23. {
  24. /// <summary>
  25. /// api分组接口
  26. /// </summary>
  27. private readonly ISysDictItemService _SysDictItemService;
  28. public SysDictItemController(ISysDictItemService SysDictItemService)
  29. {
  30. _SysDictItemService = SysDictItemService;
  31. }
  32. /// <summary>
  33. /// 字典项列表
  34. /// </summary>
  35. /// <param name="parm">请求参数</param>
  36. /// <returns>字典项列表</returns>
  37. [HttpGet]
  38. [Route("/v1/api/SysDictItem/list")]
  39. public IActionResult List([FromQuery] SysDictItemListDto parm)
  40. {
  41. var response = _SysDictItemService.List(parm);
  42. return SUCCESS(response);
  43. }
  44. /// <summary>
  45. /// 字典项详情
  46. /// </summary>
  47. /// <param name="parm">请求参数</param>
  48. /// <returns>字典项详情</returns>
  49. [HttpGet]
  50. [Route("/v1/api/SysDictItem/query")]
  51. public IActionResult Query([FromQuery] SysDictItemQueryDto parm)
  52. {
  53. var response = _SysDictItemService.Queryable()
  54. .First(x => x.id == parm.id)
  55. .Adapt<SysDictItemQueryVo>() ?? new SysDictItemQueryVo();
  56. return SUCCESS(response);
  57. }
  58. /// <summary>
  59. /// 字典项添加
  60. /// </summary>
  61. /// <param name="parm">请求参数</param>
  62. /// <returns>字典项添加</returns>
  63. [HttpPost]
  64. [Route("/v1/api/SysDictItem/add")]
  65. public IActionResult Add([FromBody] SysDictItemAddDto parm)
  66. {
  67. var modal = parm.Adapt<SysDictItem>().ToCreate(HttpContext);
  68. var response = _SysDictItemService.Add(modal);
  69. return SUCCESS(response);
  70. }
  71. /// <summary>
  72. /// 字典项修改
  73. /// </summary>
  74. /// <param name="parm">请求参数</param>
  75. /// <returns>字典项修改</returns>
  76. [HttpPut]
  77. [Route("/v1/api/SysDictItem/update")]
  78. public IActionResult Update([FromBody] SysDictItemUpdateDto parm)
  79. {
  80. var modal = parm.Adapt<SysDictItem>().ToUpdate(HttpContext);
  81. var response = _SysDictItemService.Update(modal, true);
  82. return SUCCESS(response);
  83. }
  84. /// <summary>
  85. /// 字典项删除
  86. /// </summary>
  87. /// <param name="Id">编号</param>
  88. /// <returns>字典项删除</returns>
  89. [HttpDelete]
  90. [Route("/v1/api/SysDictItem/delete/{id}")]
  91. public IActionResult Delete(long id)
  92. {
  93. var response = _SysDictItemService.Delete(id);
  94. return SUCCESS(response);
  95. }
  96. }
  97. }