切换导航条
此项目
正在载入...
登录
景龙
/
feipin
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
景龙
6 years ago
提交
727402e1d8b17e0d9e3824c8b87bc2fc35f8d84a
1 个父辈
ade4e791
1 个管道 的构建
失败
耗费 1 秒
增加删除购物车
变更
3
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
45 行增加
和
0 行删除
application/api/controller/Cars.php
application/extra/site.php
public/api.html
application/api/controller/Cars.php
查看文件 @
727402e
...
...
@@ -110,4 +110,41 @@ class Cars extends Api
$this
->
error
(
'请求方式错误'
);
}
}
/**
* @ApiTitle (购物车列表)
* @ApiSummary (购物车列表)
* @ApiMethod (GET)
* @ApiRoute (/api/cars/clearCar)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="string", required=true, description="购物车id(多个以逗号隔开)")
* @ApiReturn({
"code": 1,
"msg": "删除成功",
"time": "1555504723",
"data": 2
})
*/
public
function
clearCar
(){
if
(
$this
->
request
->
isGet
()){
$c_id
=
$this
->
request
->
get
(
'id'
);
//购物车id,以逗号隔开字符(“1,2,3”)
$rule
=
config
(
'site.cars'
);
$validate
=
new
Validate
(
$rule
[
'rule'
],
$rule
[
'msg'
]);
if
(
!
$validate
->
check
([
'id'
=>
$c_id
]))
{
$this
->
error
(
$validate
->
getError
());
}
$c_ids
=
explode
(
','
,
$c_id
);
$data
=
Db
::
table
(
'gc_car'
)
->
whereIn
(
'id'
,
$c_ids
)
->
where
([
'uid'
=>
$this
->
user_id
])
->
delete
();
if
(
$data
){
$this
->
success
(
'删除成功'
,
$data
);
}
else
{
$this
->
error
(
'删除失败'
);
}
}
else
{
$this
->
error
(
'请求方式错误'
);
}
}
}
...
...
application/extra/site.php
查看文件 @
727402e
...
...
@@ -308,4 +308,12 @@ return array (
'type'
=>
'请选择支付类型'
,
]
],
'cars'
=>
[
'rule'
=>
[
'id'
=>
'require'
,
],
'msg'
=>
[
'id.require'
=>
'购物车id不能为空'
,
]
],
);
\ No newline at end of file
...
...
public/api.html
查看文件 @
727402e
此 diff 太大无法显示。
请
注册
或
登录
后发表评论