MarketCustomerResourcesController.cs 4.8 KB

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