SupplyDemandInfoController.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\api\controller;
  15. use app\api\validate\{ ServiceValidate, SupplyDemandValidate};
  16. use app\api\logic\ServiceLogic;
  17. use app\api\logic\SupplyDemandLogic;
  18. use app\api\lists\supply_demand\SupplyDemandLists;
  19. /**
  20. * 供需发布管理
  21. * Class LoginController
  22. * @package app\api\controller
  23. */
  24. class SupplyDemandInfoController extends BaseApiController
  25. {
  26. public array $notNeedLogin = ['getSupplyDemandList','getSupplyDemandInfo'];
  27. /**
  28. * @notes 我的供需发布
  29. * @return \think\response\Json
  30. * @author 段誉
  31. * @date 2022/9/7 15:38
  32. */
  33. public function supplyDemandRelease()
  34. {
  35. if($this->request->isPost()) {
  36. $params = (new SupplyDemandValidate())->post()->goCheck('supplyDemandRelease');
  37. $userId = $this->userId;
  38. $params['user_id'] = $userId;
  39. $result = SupplyDemandLogic::addSupplyDemand($params);
  40. if (true === $result) {
  41. switch ($params['type']){
  42. case 1 :
  43. $type_name = '供应';
  44. break;
  45. case 2 :
  46. $type_name = '需求';
  47. break ;
  48. default :
  49. $type_name = '';
  50. break;
  51. }
  52. return $this->success($type_name.'信息添加成功', [], 1, 1);
  53. }
  54. }else{
  55. return $this->fail('请求方式错误');
  56. }
  57. }
  58. public function submitSupplyDemandInfo()
  59. {
  60. if($this->request->isPost()) {
  61. $params = (new SupplyDemandValidate())->post()->goCheck('submitSupplyDemand');
  62. $userId = $this->userId;
  63. $params['user_id'] = $userId;
  64. $result = SupplyDemandLogic::submitSupplyDemand($params);
  65. if (true === $result) {
  66. switch ($params['type']){
  67. case 1 :
  68. $type_name = '供应';
  69. break;
  70. case 2 :
  71. $type_name = '需求';
  72. break ;
  73. default :
  74. $type_name = '';
  75. break;
  76. }
  77. return $this->success($type_name.'信息提交审核成功', [], 1, 1);
  78. }
  79. }else{
  80. return $this->fail('请求方式错误');
  81. }
  82. }
  83. /**
  84. * @notes 供需列表
  85. * @return \think\response\Json
  86. * @author 段誉
  87. * @date 2022/9/7 15:38
  88. */
  89. public function getSupplyDemandList()
  90. {
  91. return $this->dataLists(new SupplyDemandLists());
  92. }
  93. /**
  94. * @notes 查询供需信息
  95. * @return \think\response\Json
  96. * @author 段誉
  97. * @date 2022/9/7 15:38
  98. */
  99. public function getSupplyDemandInfo()
  100. {
  101. $params = (new SupplyDemandValidate())->get()->goCheck('info');
  102. $result = SupplyDemandLogic::getInfo($params,$this->userId);
  103. if ($result['code'] === false) {
  104. return $this->fail(SupplyDemandLogic::getError());
  105. }
  106. return $this->data($result['data']);
  107. }
  108. //供需分类
  109. public function getCateList()
  110. {
  111. $params = (new SupplyDemandValidate())->get()->goCheck('cate');
  112. $result = SupplyDemandLogic::getCateList($params,$this->userId);
  113. return $this->data($result);
  114. }
  115. }