切换导航条
此项目
正在载入...
登录
李忠强
/
temporaryfood
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
何书鹏
3 years ago
提交
5bd949ad8aec01a499e5bc94a129804dd5627795
1 个父辈
157b22d0
搜索历史-清空
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
29 行增加
和
6 行删除
application/api/controller/Index.php
application/api/controller/Index.php
查看文件 @
5bd949a
...
...
@@ -5,6 +5,7 @@ namespace app\api\controller;
use
app\api\model\Category
;
use
app\api\model\Goods
;
use
app\api\model\News
;
use
app\api\model\UserSearch
;
use
app\common\controller\Api
;
use
think\Config
;
use
think\Db
;
...
...
@@ -246,7 +247,16 @@ class Index extends Api
$item
[
'line_price'
]
=
$goods_spec
[
'line_price'
];
});
}
Db
::
name
(
'user_search'
)
->
insert
([
'user_id'
=>
$this
->
auth
->
id
,
'text'
=>
$text
,
'createtime'
=>
time
()]);
// 搜索记录
$search_text
=
UserSearch
::
where
([
'user_id'
=>
$this
->
auth
->
id
,
'text'
=>
$text
])
->
find
();
if
(
$search_text
){
$search_text
->
save
([
'updatetime'
=>
time
()]);
}
else
{
UserSearch
::
create
([
'user_id'
=>
$this
->
auth
->
id
,
'text'
=>
$text
]);
}
$this
->
success
(
'搜索'
,
$list
);
}
...
...
@@ -258,17 +268,15 @@ class Index extends Api
* @ApiReturn ({
'code':'1',
'msg':'搜索历史'
'data':{
'data':null
})
*/
public
function
searchHistory
()
{
if
(
$this
->
auth
->
isLogin
()){
$list
=
Db
::
name
(
'user_search'
)
->
where
(
'user_id'
,
$this
->
auth
->
id
)
$list
=
UserSearch
::
where
(
'user_id'
,
$this
->
auth
->
id
)
->
limit
(
10
)
->
order
(
'
id
'
,
'desc'
)
->
order
(
'
updatetime
'
,
'desc'
)
->
column
(
'text'
);
}
else
{
$list
=
[];
...
...
@@ -276,4 +284,19 @@ class Index extends Api
$this
->
success
(
'搜索历史'
,
$list
);
}
/**
* @ApiTitle (搜索历史-清空)
* @ApiMethod (POST)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiReturn ({
'code':'1',
'msg':'成功'
'data':null
})
*/
public
function
searchHistoryClear
()
{
UserSearch
::
where
(
'user_id'
,
$this
->
auth
->
id
)
->
delete
();
$this
->
success
(
'成功'
);
}
}
...
...
请
注册
或
登录
后发表评论