QaInspectRecordController.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 qa_inspect_record
  19. /// @author admin
  20. /// @date 2023-05-05
  21. /// </summary>
  22. [Verify]
  23. [Route("business/QaInspectRecord")]
  24. public class QaInspectRecordController : BaseController
  25. {
  26. /// <summary>
  27. /// 质检管理/质检记录表接口
  28. /// </summary>
  29. private readonly IQaInspectRecordService _QaInspectRecordService;
  30. public QaInspectRecordController(IQaInspectRecordService QaInspectRecordService)
  31. {
  32. _QaInspectRecordService = QaInspectRecordService;
  33. }
  34. /// <summary>
  35. /// 查询质检管理/质检记录表列表
  36. /// </summary>
  37. /// <param name="parm"></param>
  38. /// <returns></returns>
  39. [HttpGet("list")]
  40. [ActionPermissionFilter(Permission = "business:qainspectrecord:list")]
  41. public IActionResult QueryQaInspectRecord([FromQuery] QaInspectRecordQueryDto parm)
  42. {
  43. var response = _QaInspectRecordService.GetList(parm);
  44. return SUCCESS(response);
  45. }
  46. /// <summary>
  47. /// 查询质检管理/质检记录表详情
  48. /// </summary>
  49. /// <param name="InspectId"></param>
  50. /// <returns></returns>
  51. [HttpGet("{InspectId}")]
  52. [ActionPermissionFilter(Permission = "business:qainspectrecord:query")]
  53. public IActionResult GetQaInspectRecord(int InspectId)
  54. {
  55. var response = _QaInspectRecordService.GetFirst(x => x.InspectId == InspectId);
  56. return SUCCESS(response);
  57. }
  58. /// <summary>
  59. /// 添加质检管理/质检记录表
  60. /// </summary>
  61. /// <returns></returns>
  62. [HttpPost]
  63. [ActionPermissionFilter(Permission = "business:qainspectrecord:add")]
  64. [Log(Title = "质检管理/质检记录表", BusinessType = BusinessType.INSERT)]
  65. public IActionResult AddQaInspectRecord([FromBody] QaInspectRecordDto parm)
  66. {
  67. if (parm == null)
  68. {
  69. throw new CustomException("请求参数错误");
  70. }
  71. var modal = parm.Adapt<QaInspectRecord>().ToCreate(HttpContext);
  72. var response = _QaInspectRecordService.AddQaInspectRecord(modal);
  73. return ToResponse(response);
  74. }
  75. /// <summary>
  76. /// 更新质检管理/质检记录表
  77. /// </summary>
  78. /// <returns></returns>
  79. [HttpPut]
  80. [ActionPermissionFilter(Permission = "business:qainspectrecord:edit")]
  81. [Log(Title = "质检管理/质检记录表", BusinessType = BusinessType.UPDATE)]
  82. public IActionResult UpdateQaInspectRecord([FromBody] QaInspectRecordDto parm)
  83. {
  84. if (parm == null)
  85. {
  86. throw new CustomException("请求实体不能为空");
  87. }
  88. var modal = parm.Adapt<QaInspectRecord>().ToUpdate(HttpContext);
  89. var response = _QaInspectRecordService.UpdateQaInspectRecord(modal);
  90. return ToResponse(response);
  91. }
  92. /// <summary>
  93. /// 删除质检管理/质检记录表
  94. /// </summary>
  95. /// <returns></returns>
  96. [HttpDelete("{ids}")]
  97. [ActionPermissionFilter(Permission = "business:qainspectrecord:delete")]
  98. [Log(Title = "质检管理/质检记录表", BusinessType = BusinessType.DELETE)]
  99. public IActionResult DeleteQaInspectRecord(string ids)
  100. {
  101. int[] idsArr = Tools.SpitIntArrary(ids);
  102. if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
  103. var response = _QaInspectRecordService.Delete(idsArr);
  104. return ToResponse(response);
  105. }
  106. }
  107. }