SupplyDemandInfoController.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. /**
  59. * @notes 供需列表
  60. * @return \think\response\Json
  61. * @author 段誉
  62. * @date 2022/9/7 15:38
  63. */
  64. public function getSupplyDemandList()
  65. {
  66. return $this->dataLists(new SupplyDemandLists());
  67. }
  68. /**
  69. * @notes 查询供需信息
  70. * @return \think\response\Json
  71. * @author 段誉
  72. * @date 2022/9/7 15:38
  73. */
  74. public function getSupplyDemandInfo()
  75. {
  76. $params = (new SupplyDemandValidate())->get()->goCheck('info');
  77. $result = SupplyDemandLogic::getInfo($params,$this->userId);
  78. if ($result['code'] === false) {
  79. return $this->fail(SupplyDemandLogic::getError());
  80. }
  81. return $this->data($result['data']);
  82. }
  83. }