SupplyDemandInfoController.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. return $this->success('信息提交审核成功', [], 1, 1);
  67. }
  68. }else{
  69. return $this->fail('请求方式错误');
  70. }
  71. }
  72. /**
  73. * @notes 供需列表
  74. * @return \think\response\Json
  75. * @author 段誉
  76. * @date 2022/9/7 15:38
  77. */
  78. public function getSupplyDemandList()
  79. {
  80. return $this->dataLists(new SupplyDemandLists());
  81. }
  82. /**
  83. * @notes 查询供需信息
  84. * @return \think\response\Json
  85. * @author 段誉
  86. * @date 2022/9/7 15:38
  87. */
  88. public function getSupplyDemandInfo()
  89. {
  90. $params = (new SupplyDemandValidate())->get()->goCheck('info');
  91. $result = SupplyDemandLogic::getInfo($params,$this->userId);
  92. if ($result['code'] === false) {
  93. return $this->fail(SupplyDemandLogic::getError());
  94. }
  95. return $this->data($result['data']);
  96. }
  97. //供需分类
  98. public function getCateList()
  99. {
  100. $params = (new SupplyDemandValidate())->get()->goCheck('cate');
  101. $result = SupplyDemandLogic::getCateList($params,$this->userId);
  102. return $this->data($result);
  103. }
  104. public function delete(){
  105. if($this->request->isPost()) {
  106. $params = (new SupplyDemandValidate())->post()->goCheck('delete');
  107. $result = SupplyDemandLogic::delete($params);
  108. if (true === $result) {
  109. return $this->success('删除成功', [], 1, 1);
  110. }
  111. }else{
  112. return $this->fail('请求方式错误');
  113. }
  114. }
  115. }