|
@@ -0,0 +1,112 @@
|
|
|
+<?php
|
|
|
+namespace app\api\controller;
|
|
|
+use app\common\model\UserDemand;
|
|
|
+use library\tools\Data;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @title 需求
|
|
|
+ * @controller Demand
|
|
|
+ * @group base
|
|
|
+ */
|
|
|
+class Demand extends Base
|
|
|
+{
|
|
|
+ // 需要登录的
|
|
|
+ protected $need_login = [];
|
|
|
+ public function initialize()
|
|
|
+ {
|
|
|
+ parent::initialize();
|
|
|
+ parent::setUid();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @title 需求接口说明
|
|
|
+ * @desc 需求接口说明
|
|
|
+ * @author qc
|
|
|
+ * @url /api/Demand/classIntro
|
|
|
+ * @method GET
|
|
|
+ */
|
|
|
+ public function classIntro(){}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @title 以下接口调用验证登录【需要header传Authorization】
|
|
|
+ * @desc 转发成功后调用
|
|
|
+ * @author qc
|
|
|
+ * @method
|
|
|
+ * @url /api/Demand/needLogin
|
|
|
+ */
|
|
|
+ public function needLogin(){}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @title 用户提交||修改需求【用户】
|
|
|
+ * @desc 用户提交||修改需求
|
|
|
+ * @author qc
|
|
|
+ * @method POST
|
|
|
+ * @url /api/Demand/commitDemand
|
|
|
+ * @param name:id type:int default:-- desc:修改必传
|
|
|
+ * @param name:title type:string default:-- desc:标题
|
|
|
+ * @param name:content type:string default:1 desc:内容
|
|
|
+ * @param name:money type:float default:0 desc:价格【设计图没有,可以不传】
|
|
|
+ */
|
|
|
+ public function commitDemand()
|
|
|
+ {
|
|
|
+ $title = input('post.title');
|
|
|
+ $content = input('post.content');
|
|
|
+ $money = input('post.money');
|
|
|
+ $id = input('post.id');
|
|
|
+ if(!$title ||$content) $this->error('标题和需求内容必填');
|
|
|
+ Data::save('UserDemand',['title'=>$title,'content'=>$content,'user_id'=>$this->user_id,'money'=>$money,'id'=>$id],'user_id',['user_id'=>$this->user_id,'id'=>$id]);
|
|
|
+ $this->success('提交成功,请等待审核');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @title 获取我的需求列表【用户】
|
|
|
+ * @desc 获取我的图文列表【用户】
|
|
|
+ * @author qc
|
|
|
+ * @method GET
|
|
|
+ * @url /api/Demand/getMyDemandList
|
|
|
+ * @header name:Authorization require:1 desc:Token
|
|
|
+ * @param name:title type:string default:-- desc:标题
|
|
|
+ * @param name:page type:int default:0 desc:页数
|
|
|
+ * @param name:page_num type:int default:20 desc:每页数
|
|
|
+ * @return name:title type:string default:-- desc:标题
|
|
|
+ * @return name:content type:string default:-- desc:需求
|
|
|
+ * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过
|
|
|
+ * @return name:remark type:string default:-- desc:审核备注
|
|
|
+ */
|
|
|
+ public function getMyDemandList()
|
|
|
+ {
|
|
|
+ $sel_where = [];
|
|
|
+ $sel_where[] = ['is_deleted','=',0];
|
|
|
+ $sel_where[] = ['user_id','=',$this->user_id];
|
|
|
+ $title = input('get.title');
|
|
|
+ if($title) $sel_where[] = ['title','like','%'.$title.'%'];
|
|
|
+ $list = UserDemand::where($sel_where)
|
|
|
+ ->field('id,title,content,status,remark')
|
|
|
+ ->order('id desc')
|
|
|
+ ->limit($this->off_set,$this->page_num)
|
|
|
+ ->select()->toArray();
|
|
|
+ $this->success('ok',['list'=>$list]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @title 删除我的需求【用户】
|
|
|
+ * @desc 删除我的需求【用户】
|
|
|
+ * @author qc
|
|
|
+ * @method POST
|
|
|
+ * @url /api/Demand/delMyDemand
|
|
|
+ * @param name:id type:int default:-- desc:需求记录id
|
|
|
+ */
|
|
|
+ public function delMyDemand()
|
|
|
+ {
|
|
|
+ UserDemand::where(['id'=>input('post.id'),'user_id'=>$this->user_id])->delete();
|
|
|
+ $this->success('删除成功');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|