MarketCustomerResourcesController.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using Microsoft.AspNetCore.Mvc;
  2. using OASystem.Domain.Dtos.CRM;
  3. using OASystem.Domain.Entities.Customer;
  4. using OASystem.Infrastructure.Repositories.CRM;
  5. using static OASystem.Domain.Dtos.CRM.NewClientDataQueryDto;
  6. namespace OASystem.API.Controllers
  7. {
  8. [Route("api/[controller]/[action]")]
  9. public class MarketCustomerResourcesController : ControllerBase
  10. {
  11. private readonly NewClientDataRepository _clientDataRepository;
  12. /// <summary>
  13. /// 初始化
  14. /// </summary>
  15. public MarketCustomerResourcesController(NewClientDataRepository clientDataRepository)
  16. {
  17. this._clientDataRepository = clientDataRepository;
  18. }
  19. /// <summary>
  20. /// 查询客户资料数据
  21. /// </summary>
  22. /// <returns></returns>
  23. [HttpPost]
  24. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25. public async Task<IActionResult> QueryNewClientData(NewClientDataQueryDto dto)
  26. {
  27. try
  28. {
  29. Result resTable = await _clientDataRepository.QueryNewClientData(dto);
  30. //Result resSelect = await _clientDataRepository.NewClientSelectData();
  31. return Ok(JsonView(true, resTable.Msg, resTable));
  32. }
  33. catch (Exception)
  34. {
  35. return Ok(JsonView(false, "程序错误!"));
  36. throw;
  37. }
  38. }
  39. /// <summary>
  40. /// 客户资料操作(Status:1.新增,2.修改)
  41. /// </summary>
  42. /// <param name="dto"></param>
  43. /// <returns></returns>
  44. [HttpPost]
  45. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  46. public async Task<IActionResult> NewClientOp(NewClientOpDto dto)
  47. {
  48. try
  49. {
  50. Domain.Result result = await _clientDataRepository.NewClientOp(dto);
  51. if (result.Code != 0)
  52. {
  53. return Ok(JsonView(false, result.Msg));
  54. }
  55. return Ok(JsonView(true, result.Msg));
  56. }
  57. catch (Exception)
  58. {
  59. return Ok(JsonView(false, "程序错误!"));
  60. throw;
  61. }
  62. }
  63. /// <summary>
  64. /// 新客户资料操作(删除)
  65. /// </summary>
  66. /// <param name="dto"></param>
  67. /// <returns></returns>
  68. [HttpPost]
  69. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  70. public async Task<IActionResult> NewClientDel(DelBaseDto dto)
  71. {
  72. try
  73. {
  74. var res = await _clientDataRepository.SoftDeleteByIdAsync<Crm_NewClientData>(dto.Id.ToString(), dto.DeleteUserId);
  75. if (!res)
  76. {
  77. return Ok(JsonView(false, "删除失败"));
  78. }
  79. return Ok(JsonView(true, "删除成功!"));
  80. }
  81. catch (Exception ex)
  82. {
  83. return Ok(JsonView(false, "程序错误!"));
  84. throw;
  85. }
  86. }
  87. [HttpPost]
  88. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  89. public async Task<IActionResult> QueryUserSelect()
  90. {
  91. try
  92. {
  93. Result resTable = await _clientDataRepository.QueryUserSelect();
  94. return Ok(JsonView(true, resTable.Msg, resTable));
  95. }
  96. catch (Exception)
  97. {
  98. return Ok(JsonView(false, "程序错误!"));
  99. throw;
  100. }
  101. }
  102. }
  103. }