正在显示
3 个修改的文件
包含
45 行增加
和
0 行删除
@@ -110,4 +110,41 @@ class Cars extends Api | @@ -110,4 +110,41 @@ class Cars extends Api | ||
110 | $this->error('请求方式错误'); | 110 | $this->error('请求方式错误'); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | + | ||
114 | + /** | ||
115 | + * @ApiTitle (购物车列表) | ||
116 | + * @ApiSummary (购物车列表) | ||
117 | + * @ApiMethod (GET) | ||
118 | + * @ApiRoute (/api/cars/clearCar) | ||
119 | + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
120 | + * @ApiParams (name="id", type="string", required=true, description="购物车id(多个以逗号隔开)") | ||
121 | + * @ApiReturn({ | ||
122 | + "code": 1, | ||
123 | + "msg": "删除成功", | ||
124 | + "time": "1555504723", | ||
125 | + "data": 2 | ||
126 | + }) | ||
127 | + */ | ||
128 | + public function clearCar(){ | ||
129 | + if($this->request->isGet()){ | ||
130 | + $c_id = $this->request->get('id');//购物车id,以逗号隔开字符(“1,2,3”) | ||
131 | + $rule = config('site.cars'); | ||
132 | + $validate = new Validate($rule['rule'],$rule['msg']); | ||
133 | + if (!$validate->check(['id'=>$c_id])) { | ||
134 | + $this->error($validate->getError()); | ||
135 | + } | ||
136 | + $c_ids = explode(',',$c_id); | ||
137 | + $data = Db::table('gc_car') | ||
138 | + ->whereIn('id',$c_ids) | ||
139 | + ->where(['uid'=>$this->user_id]) | ||
140 | + ->delete(); | ||
141 | + if($data){ | ||
142 | + $this->success('删除成功',$data); | ||
143 | + }else{ | ||
144 | + $this->error('删除失败'); | ||
145 | + } | ||
146 | + }else{ | ||
147 | + $this->error('请求方式错误'); | ||
148 | + } | ||
149 | + } | ||
113 | } | 150 | } |
@@ -308,4 +308,12 @@ return array ( | @@ -308,4 +308,12 @@ return array ( | ||
308 | 'type' => '请选择支付类型', | 308 | 'type' => '请选择支付类型', |
309 | ] | 309 | ] |
310 | ], | 310 | ], |
311 | + 'cars' => [ | ||
312 | + 'rule' => [ | ||
313 | + 'id' => 'require', | ||
314 | + ], | ||
315 | + 'msg' => [ | ||
316 | + 'id.require' => '购物车id不能为空', | ||
317 | + ] | ||
318 | + ], | ||
311 | ); | 319 | ); |
此 diff 太大无法显示。
-
请 注册 或 登录 后发表评论