| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\api\controller;
- use app\api\validate\{ ServiceValidate, SupplyDemandValidate};
- use app\api\logic\ServiceLogic;
- use app\api\logic\SupplyDemandLogic;
- use app\api\lists\supply_demand\SupplyDemandLists;
- /**
- * 供需发布管理
- * Class LoginController
- * @package app\api\controller
- */
- class SupplyDemandInfoController extends BaseApiController
- {
- public array $notNeedLogin = ['getSupplyDemandList','getSupplyDemandInfo','getCateList'];
- /**
- * @notes 我的供需发布
- * @return \think\response\Json
- * @author 段誉
- * @date 2022/9/7 15:38
- */
- public function supplyDemandRelease()
- {
- if($this->request->isPost()) {
- $params = (new SupplyDemandValidate())->post()->goCheck('supplyDemandRelease');
- $userId = $this->userId;
- $params['user_id'] = $userId;
- $result = SupplyDemandLogic::addSupplyDemand($params);
- if (true === $result) {
- switch ($params['type']){
- case 1 :
- $type_name = '供应';
- break;
- case 2 :
- $type_name = '需求';
- break ;
- default :
- $type_name = '';
- break;
- }
- return $this->success($type_name.'信息添加成功', [], 1, 1);
- }
- }else{
- return $this->fail('请求方式错误');
- }
- }
- public function submitSupplyDemandInfo()
- {
- if($this->request->isPost()) {
- $params = (new SupplyDemandValidate())->post()->goCheck('submitSupplyDemand');
- $userId = $this->userId;
- $params['user_id'] = $userId;
- $result = SupplyDemandLogic::submitSupplyDemand($params);
- if (true === $result) {
- return $this->success('信息提交审核成功', [], 1, 1);
- }
- }else{
- return $this->fail('请求方式错误');
- }
- }
- /**
- * @notes 供需列表
- * @return \think\response\Json
- * @author 段誉
- * @date 2022/9/7 15:38
- */
- public function getSupplyDemandList()
- {
- return $this->dataLists(new SupplyDemandLists());
- }
- /**
- * @notes 查询供需信息
- * @return \think\response\Json
- * @author 段誉
- * @date 2022/9/7 15:38
- */
- public function getSupplyDemandInfo()
- {
- $params = (new SupplyDemandValidate())->get()->goCheck('info');
- $result = SupplyDemandLogic::getInfo($params,$this->userId);
- if ($result['code'] === false) {
- return $this->fail(SupplyDemandLogic::getError());
- }
- return $this->data($result['data']);
- }
- //供需分类
- public function getCateList()
- {
- $params = (new SupplyDemandValidate())->get()->goCheck('cate');
- $result = SupplyDemandLogic::getCateList($params,$this->userId);
- return $this->data($result);
- }
- public function delete(){
- if($this->request->isPost()) {
- $params = (new SupplyDemandValidate())->post()->goCheck('delete');
- $result = SupplyDemandLogic::delete($params);
- if (true === $result) {
- return $this->success('删除成功', [], 1, 1);
- }
- }else{
- return $this->fail('请求方式错误');
- }
- }
- }
|