SysDictController.cs 3.0 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. /// SysDict)Controller
  19. /// </summary>
  20. // [Route("SysDict")]
  21. // [ApiExplorerSettings(GroupName = "SysDict")]
  22. public class SysDictController : BaseController
  23. {
  24. /// <summary>
  25. /// api分组接口
  26. /// </summary>
  27. private readonly ISysDictService _SysDictService;
  28. public SysDictController(ISysDictService SysDictService)
  29. {
  30. _SysDictService = SysDictService;
  31. }
  32. /// <summary>
  33. /// 字典表列表
  34. /// </summary>
  35. /// <param name="parm">请求参数</param>
  36. /// <returns>字典表列表</returns>
  37. [HttpGet]
  38. [Route("/v1/api/SysDict/list")]
  39. public IActionResult List([FromQuery] SysDictListDto parm)
  40. {
  41. var response = _SysDictService.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/SysDict/query")]
  51. public IActionResult Query([FromQuery] SysDictQueryDto parm)
  52. {
  53. var response = _SysDictService.Queryable()
  54. .First(x => x.id == parm.id)
  55. .Adapt<SysDictQueryVo>() ?? new SysDictQueryVo();
  56. return SUCCESS(response);
  57. }
  58. /// <summary>
  59. /// 字典表添加
  60. /// </summary>
  61. /// <param name="parm">请求参数</param>
  62. /// <returns>字典表添加</returns>
  63. [HttpPost]
  64. [Route("/v1/api/SysDict/add")]
  65. public IActionResult Add([FromBody] SysDictAddDto parm)
  66. {
  67. var modal = parm.Adapt<SysDict>().ToCreate(HttpContext);
  68. var response = _SysDictService.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/SysDict/update")]
  78. public IActionResult Update([FromBody] SysDictUpdateDto parm)
  79. {
  80. var modal = parm.Adapt<SysDict>().ToUpdate(HttpContext);
  81. var response = _SysDictService.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/SysDict/delete/{id}")]
  91. public IActionResult Delete(long id)
  92. {
  93. var response = _SysDictService.Delete(id);
  94. return SUCCESS(response);
  95. }
  96. }
  97. }