InRetreatRecordController.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using Infrastructure;
  2. using Infrastructure.Attribute;
  3. using Infrastructure.Enums;
  4. using Infrastructure.Model;
  5. using Mapster;
  6. using Microsoft.AspNetCore.Mvc;
  7. using ZR.Model.Dto;
  8. using ZR.Model.Models;
  9. using ZR.Service.Business.IBusinessService;
  10. using ZR.Admin.WebApi.Extensions;
  11. using ZR.Admin.WebApi.Filters;
  12. using ZR.Common;
  13. namespace ZR.Admin.WebApi.Controllers
  14. {
  15. /// <summary>
  16. /// 入库管理/退料记录表Controller
  17. ///
  18. /// @tableName in_retreat_record
  19. /// @author admin
  20. /// @date 2023-04-14
  21. /// </summary>
  22. [Verify]
  23. [Route("business/InRetreatRecord")]
  24. public class InRetreatRecordController : BaseController
  25. {
  26. /// <summary>
  27. /// 入库管理/退料记录表接口
  28. /// </summary>
  29. private readonly IInRetreatRecordService _InRetreatRecordService;
  30. public InRetreatRecordController(IInRetreatRecordService InRetreatRecordService)
  31. {
  32. _InRetreatRecordService = InRetreatRecordService;
  33. }
  34. /// <summary>
  35. /// 查询入库管理/退料记录表列表
  36. /// </summary>
  37. /// <param name="parm"></param>
  38. /// <returns></returns>
  39. [HttpGet("list")]
  40. [ActionPermissionFilter(Permission = "business:inretreatrecord:list")]
  41. public IActionResult QueryInRetreatRecord([FromQuery] InRetreatRecordQueryDto parm)
  42. {
  43. var response = _InRetreatRecordService.GetList(parm);
  44. return SUCCESS(response);
  45. }
  46. /// <summary>
  47. /// 查询入库管理/退料记录表详情
  48. /// </summary>
  49. /// <param name="RetreatId"></param>
  50. /// <returns></returns>
  51. [HttpGet("{RetreatId}")]
  52. [ActionPermissionFilter(Permission = "business:inretreatrecord:query")]
  53. public IActionResult GetInRetreatRecord(int RetreatId)
  54. {
  55. var response = _InRetreatRecordService.GetFirst(x => x.RetreatId == RetreatId);
  56. return SUCCESS(response);
  57. }
  58. /// <summary>
  59. /// 添加入库管理/退料记录表
  60. /// </summary>
  61. /// <returns></returns>
  62. [HttpPost]
  63. [ActionPermissionFilter(Permission = "business:inretreatrecord:add")]
  64. [Log(Title = "入库管理/退料记录表", BusinessType = BusinessType.INSERT)]
  65. public IActionResult AddInRetreatRecord([FromBody] InRetreatRecordDto parm)
  66. {
  67. if (parm == null)
  68. {
  69. throw new CustomException("请求参数错误");
  70. }
  71. var modal = parm.Adapt<InRetreatRecord>().ToCreate(HttpContext);
  72. var response = _InRetreatRecordService.AddInRetreatRecord(modal);
  73. return ToResponse(response);
  74. }
  75. /// <summary>
  76. /// 更新入库管理/退料记录表
  77. /// </summary>
  78. /// <returns></returns>
  79. [HttpPut]
  80. [ActionPermissionFilter(Permission = "business:inretreatrecord:edit")]
  81. [Log(Title = "入库管理/退料记录表", BusinessType = BusinessType.UPDATE)]
  82. public IActionResult UpdateInRetreatRecord([FromBody] InRetreatRecordDto parm)
  83. {
  84. if (parm == null)
  85. {
  86. throw new CustomException("请求实体不能为空");
  87. }
  88. var modal = parm.Adapt<InRetreatRecord>().ToUpdate(HttpContext);
  89. var response = _InRetreatRecordService.UpdateInRetreatRecord(modal);
  90. return ToResponse(response);
  91. }
  92. /// <summary>
  93. /// 删除入库管理/退料记录表
  94. /// </summary>
  95. /// <returns></returns>
  96. [HttpDelete("{ids}")]
  97. [ActionPermissionFilter(Permission = "business:inretreatrecord:delete")]
  98. [Log(Title = "入库管理/退料记录表", BusinessType = BusinessType.DELETE)]
  99. public IActionResult DeleteInRetreatRecord(string ids)
  100. {
  101. int[] idsArr = Tools.SpitIntArrary(ids);
  102. if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
  103. var response = _InRetreatRecordService.Delete(idsArr);
  104. return ToResponse(response);
  105. }
  106. }
  107. }