作者 郭盛
1 个管道 的构建 通过 耗费 3 秒

搜索页以及历史记录

... ... @@ -18,21 +18,24 @@
<file leaf-file-name="User.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/application/api/controller/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="527">
<caret line="301" column="31" lean-forward="false" selection-start-line="301" selection-start-column="31" selection-end-line="301" selection-end-column="31" />
<state relative-caret-position="327">
<caret line="197" column="33" lean-forward="false" selection-start-line="197" selection-start-column="33" selection-end-line="197" selection-end-column="33" />
<folding>
<element signature="e#38#68#0#PHP" expanded="true" />
<element signature="e#337#456#0#PHP" expanded="false" />
<element signature="e#462#1200#0#PHP" expanded="false" />
<element signature="e#1205#2868#0#PHP" expanded="false" />
<element signature="e#2874#3402#0#PHP" expanded="false" />
<element signature="e#3407#4178#0#PHP" expanded="false" />
<element signature="e#4184#4591#0#PHP" expanded="false" />
<element signature="e#4596#4939#0#PHP" expanded="false" />
<element signature="e#4945#5597#0#PHP" expanded="false" />
<element signature="e#5602#7338#0#PHP" expanded="false" />
<element signature="e#7344#7793#0#PHP" expanded="false" />
<element signature="e#7798#8681#0#PHP" expanded="false" />
<element signature="e#8687#9371#0#PHP" expanded="false" />
<element signature="e#9376#10872#0#PHP" expanded="false" />
<element signature="e#7551#8000#0#PHP" expanded="false" />
<element signature="e#8005#8888#0#PHP" expanded="false" />
<element signature="e#8894#9578#0#PHP" expanded="false" />
<element signature="e#9583#11079#0#PHP" expanded="false" />
<element signature="e#11085#11462#0#PHP" expanded="false" />
<element signature="e#11467#11731#0#PHP" expanded="false" />
</folding>
</state>
</provider>
... ... @@ -107,8 +110,8 @@
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds">
<option name="x" value="534" />
<option name="y" value="81" />
<option name="x" value="311" />
<option name="y" value="58" />
<option name="width" value="1589" />
<option name="height" value="939" />
</component>
... ... @@ -239,7 +242,7 @@
<workItem from="1574122453532" duration="15780000" />
<workItem from="1574141466352" duration="745000" />
<workItem from="1574143209694" duration="3660000" />
<workItem from="1574146994475" duration="8817000" />
<workItem from="1574146994475" duration="12061000" />
</task>
<task id="LOCAL-00001" summary="调试">
<created>1574145133364</created>
... ... @@ -252,7 +255,7 @@
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="57170000" />
<option name="totallyTimeSpent" value="60414000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
... ... @@ -264,7 +267,7 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="534" y="81" width="1589" height="939" extended-state="0" />
<frame x="311" y="58" width="1589" height="939" extended-state="0" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.18574232" sideWeight="0.5" order="1" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32912987" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
... ... @@ -681,21 +684,24 @@
</entry>
<entry file="file://$PROJECT_DIR$/application/api/controller/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="527">
<caret line="301" column="31" lean-forward="false" selection-start-line="301" selection-start-column="31" selection-end-line="301" selection-end-column="31" />
<state relative-caret-position="327">
<caret line="197" column="33" lean-forward="false" selection-start-line="197" selection-start-column="33" selection-end-line="197" selection-end-column="33" />
<folding>
<element signature="e#38#68#0#PHP" expanded="true" />
<element signature="e#337#456#0#PHP" expanded="false" />
<element signature="e#462#1200#0#PHP" expanded="false" />
<element signature="e#1205#2868#0#PHP" expanded="false" />
<element signature="e#2874#3402#0#PHP" expanded="false" />
<element signature="e#3407#4178#0#PHP" expanded="false" />
<element signature="e#4184#4591#0#PHP" expanded="false" />
<element signature="e#4596#4939#0#PHP" expanded="false" />
<element signature="e#4945#5597#0#PHP" expanded="false" />
<element signature="e#5602#7338#0#PHP" expanded="false" />
<element signature="e#7344#7793#0#PHP" expanded="false" />
<element signature="e#7798#8681#0#PHP" expanded="false" />
<element signature="e#8687#9371#0#PHP" expanded="false" />
<element signature="e#9376#10872#0#PHP" expanded="false" />
<element signature="e#7551#8000#0#PHP" expanded="false" />
<element signature="e#8005#8888#0#PHP" expanded="false" />
<element signature="e#8894#9578#0#PHP" expanded="false" />
<element signature="e#9583#11079#0#PHP" expanded="false" />
<element signature="e#11085#11462#0#PHP" expanded="false" />
<element signature="e#11467#11731#0#PHP" expanded="false" />
</folding>
</state>
</provider>
... ...
... ... @@ -184,15 +184,24 @@ class User extends Api
*/
public function search()
{
$user_id = $this->uid;
$rule = config('verify.path');
$type_id = $this->request->post('type_id');
if(empty($type_id)){
$this->error(['code'=>2,'msg'=>'缺少必要参数']);
}
$keyword = $this->request->post('keyword');
if(!empty($keyword)){
$param['user_id'] = $user_id;
$param['title'] = $keyword;
Db::name('history')
->insert($param);
}
if(!empty($keyword)){
if($type_id == 1){
$where['keyword'] = ['like',"%$keyword%"];
$where['title'] = ['like',"%$keyword%"];
$data = Db::name('video')
->where($where)
->where('keyword','like',"%$keyword%")
->whereOr('title','like',"%$keyword%")
->order('id desc')
->select();
foreach ($data as &$v){
... ... @@ -201,10 +210,9 @@ class User extends Api
}
$this->success('SUCCESS',$data);
}elseif($type_id == 2){
$where['keyword'] = ['like',"%$keyword%"];
$where['title'] = ['like',"%$keyword%"];
$data = Db::name('pic')
->where($where)
->where('keyword','like',"%$keyword%")
->whereOr('title','like',"%$keyword%")
->order('id desc')
->select();
foreach ($data as &$v){
... ... @@ -212,9 +220,8 @@ class User extends Api
}
$this->success('SUCCESS',$data);
}else{
$where['keyword'] = ['like',"%$keyword%"];
$data = Db::name('wonderful')
->where($where)
->where('title','like',"%$keyword%")
->order('id desc')
->select();
foreach ($data as &$v){
... ... @@ -338,4 +345,32 @@ class User extends Api
}
}
/**
* @ApiTitle (历史记录)
* @ApiSummary (历史记录)
* @ApiMethod (POST)
* @ApiRoute (/api/user/history)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": 4,//记录id,
"title"://搜索的内容
}
})
*/
public function history()
{
$user_id = $this->uid;
$data = Db::name('history')
->where('user_id',$user_id)
->order('id desc')
->limit(10)
->select();
$this->success('SUCCESS',$data);
}
}
... ...
... ... @@ -170,6 +170,7 @@
<a href="javascript:;" data-id="11" class="list-group-item">搜索页</a>
<a href="javascript:;" data-id="12" class="list-group-item">图片列表</a>
<a href="javascript:;" data-id="13" class="list-group-item">图片详情</a>
<a href="javascript:;" data-id="14" class="list-group-item">历史记录</a>
</div>
</div>
</div>
... ... @@ -1993,13 +1994,141 @@
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" id="heading-14">
<h4 class="panel-title">
<span class="label label-primary">POST</span>
<a data-toggle="collapse" data-parent="#accordion14" href="#collapseOne14"> 历史记录 <span class="text-muted">/api/user/history</span></a>
</h4>
</div>
<div id="collapseOne14" class="panel-collapse collapse">
<div class="panel-body">
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="doctab14">
<li class="active"><a href="#info14" data-toggle="tab">基础信息</a></li>
<li><a href="#sandbox14" data-toggle="tab">在线测试</a></li>
<li><a href="#sample14" data-toggle="tab">返回示例</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="info14">
<div class="well">
历史记录 </div>
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
<table class="table table-hover">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>token</td>
<td>string</td>
<td></td>
<td>请求的Token</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>正文</strong></div>
<div class="panel-body">
</div>
</div>
</div><!-- #info -->
<div class="tab-pane" id="sandbox14">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
<div class="headers">
<div class="form-group">
<label class="control-label" for="token">token</label>
<input type="string" class="form-control input-sm" id="token" required placeholder="请求的Token - Ex: " name="token">
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/history" method="POST" name="form14" id="form14">
<div class="form-group">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="14">提交</button>
<button type="reset" class="btn btn-info" rel="14">重置</button>
</div>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>响应输出</strong></div>
<div class="panel-body">
<div class="row">
<div class="col-md-12" style="overflow-x:auto">
<pre id="response_headers14"></pre>
<pre id="response14"></pre>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>返回参数</strong></div>
<div class="panel-body">
</div>
</div>
</div>
</div>
</div><!-- #sandbox -->
<div class="tab-pane" id="sample14">
<div class="row">
<div class="col-md-12">
<pre id="sample_response14">{
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": 4,//记录id,
"title"://搜索的内容
}
}</pre>
</div>
</div>
</div><!-- #sample -->
</div><!-- .tab-content -->
</div>
</div>
</div>
</div>
<hr>
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2019-11-19 17:30:17 </div>
Generated on 2019-11-19 18:57:51 </div>
<div class="col-md-6" align="right">
<a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
</div>
... ...