MarketCustomerResourcesController.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. JsonView jw = new JsonView();
  28. try
  29. {
  30. Result resultData = await _clientDataRepository.QueryNewClientData(dto);
  31. if (resultData.Code == 0)
  32. {
  33. jw = JsonView(true, resultData.Msg, resultData.Data);
  34. }
  35. else
  36. {
  37. jw = JsonView(false, resultData.Msg, resultData.Data);
  38. }
  39. }
  40. catch (Exception)
  41. {
  42. jw = JsonView(false, "程序错误!");
  43. }
  44. return Ok(jw);
  45. }
  46. /// <summary>
  47. /// 客户资料操作(Status:1.新增,2.修改)
  48. /// </summary>
  49. /// <param name="dto"></param>
  50. /// <returns></returns>
  51. [HttpPost]
  52. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  53. public async Task<IActionResult> NewClientOp(NewClientOpDto dto)
  54. {
  55. try
  56. {
  57. Domain.Result result = await _clientDataRepository.NewClientOp(dto);
  58. if (result.Code != 0)
  59. {
  60. return Ok(JsonView(false, result.Msg));
  61. }
  62. return Ok(JsonView(true, result.Msg));
  63. }
  64. catch (Exception)
  65. {
  66. return Ok(JsonView(false, "程序错误!"));
  67. }
  68. }
  69. /// <summary>
  70. /// 新客户资料操作(删除)
  71. /// </summary>
  72. /// <param name="dto"></param>
  73. /// <returns></returns>
  74. [HttpPost]
  75. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  76. public async Task<IActionResult> NewClientDel(DelBaseDto dto)
  77. {
  78. var res = await _clientDataRepository.DelNewClientData(dto);
  79. if (res.Code != 0)
  80. {
  81. return Ok(JsonView(false, "删除失败"));
  82. }
  83. return Ok(JsonView(true, "删除成功!"));
  84. }
  85. /// <summary>
  86. /// 获取下拉列表数据和单条数据信息
  87. /// </summary>
  88. /// <param name="dto"></param>
  89. /// <returns></returns>
  90. [HttpPost]
  91. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  92. public async Task<IActionResult> QuerySelectAndSingleData(QuerySingleDto dto)
  93. {
  94. JsonView jw = new JsonView();
  95. var result = await _clientDataRepository.QuerySelectAndSingleData(dto);
  96. if (result.Code == 0)
  97. {
  98. jw = JsonView(true, result.Msg,result.Data);
  99. }
  100. else
  101. {
  102. jw = JsonView(false, result.Msg);
  103. }
  104. return Ok(jw);
  105. }
  106. /// <summary>
  107. /// 获取现有负责人
  108. /// </summary>
  109. /// <returns></returns>
  110. [HttpPost]
  111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  112. public async Task<IActionResult> QueryUserSelect()
  113. {
  114. try
  115. {
  116. Result resTable = _clientDataRepository.QueryUserSelect();
  117. return Ok(JsonView(true, resTable.Msg, resTable.Data));
  118. }
  119. catch (Exception)
  120. {
  121. return Ok(JsonView(false, "程序错误!"));
  122. }
  123. }
  124. /// <summary>
  125. /// 获取出团数据
  126. /// </summary>
  127. /// <returns></returns>
  128. [HttpPost]
  129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  130. public async Task<IActionResult> QueryNumberGroups()
  131. {
  132. var result = await _clientDataRepository.QueryNumberGroups();
  133. if (result.Code != 0)
  134. {
  135. return Ok(JsonView(false, result.Msg));
  136. }
  137. return Ok(JsonView(true, result.Msg,result.Data));
  138. }
  139. }
  140. }