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

图片接口

... ... @@ -2,8 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="e93f11c2-a7d9-4d35-8b1c-8dd18e7f5fef" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/application/api/controller/User.php" afterPath="$PROJECT_DIR$/application/api/controller/User.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/application/common/library/Auth.php" afterPath="$PROJECT_DIR$/application/common/library/Auth.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/public/api.html" afterPath="$PROJECT_DIR$/public/api.html" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
... ... @@ -18,22 +18,31 @@
<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="329">
<caret line="271" column="5" lean-forward="true" selection-start-line="271" selection-start-column="5" selection-end-line="271" selection-end-column="5" />
<state relative-caret-position="219">
<caret line="306" column="30" lean-forward="true" selection-start-line="306" selection-start-column="30" selection-end-line="306" selection-end-column="30" />
<folding>
<element signature="e#38#68#0#PHP" expanded="true" />
<element signature="e#312#384#0#PHP" expanded="false" />
<element signature="e#390#1128#0#PHP" expanded="false" />
<element signature="e#1133#2796#0#PHP" expanded="false" />
<element signature="e#2802#3330#0#PHP" expanded="false" />
<element signature="e#3335#4106#0#PHP" expanded="false" />
<element signature="e#4112#4519#0#PHP" expanded="false" />
<element signature="e#4873#5474#0#PHP" expanded="false" />
<element signature="e#462#1200#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#7344#7793#0#PHP" expanded="false" />
<element signature="e#7798#8681#0#PHP" expanded="false" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Auth.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/common/library/Auth.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="585">
<caret line="105" column="38" lean-forward="true" selection-start-line="105" selection-start-column="38" selection-end-line="105" selection-end-column="38" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="verify.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/extra/verify.php">
<provider selected="true" editor-type-id="text-editor">
... ... @@ -49,6 +58,7 @@
<component name="FindInProjectRecents">
<findStrings>
<find>image</find>
<find>init($token)</find>
</findStrings>
</component>
<component name="Git.Settings">
... ... @@ -91,8 +101,8 @@
<option value="$PROJECT_DIR$/.gitlab-ci.yml" />
<option value="$PROJECT_DIR$/.gitignore" />
<option value="$PROJECT_DIR$/public/.gitignore" />
<option value="$PROJECT_DIR$/application/common/library/Auth.php" />
<option value="$PROJECT_DIR$/application/extra/verify.php" />
<option value="$PROJECT_DIR$/application/common/library/Auth.php" />
<option value="$PROJECT_DIR$/application/api/controller/User.php" />
</list>
</option>
... ... @@ -112,10 +122,10 @@
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds">
<option name="x" value="667" />
<option name="y" value="102" />
<option name="x" value="529" />
<option name="y" value="29" />
<option name="width" value="1589" />
<option name="height" value="930" />
<option name="height" value="939" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
... ... @@ -148,14 +158,14 @@
<item name="areial" type="b2602c69:ProjectViewProjectNode" />
<item name="areial" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="application" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="admin" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="common" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="areial" type="b2602c69:ProjectViewProjectNode" />
<item name="areial" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="application" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="admin" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="model" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="common" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="library" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="areial" type="b2602c69:ProjectViewProjectNode" />
... ... @@ -209,7 +219,7 @@
<workItem from="1574122453532" duration="15780000" />
<workItem from="1574141466352" duration="745000" />
<workItem from="1574143209694" duration="3660000" />
<workItem from="1574146994475" duration="4813000" />
<workItem from="1574146994475" duration="7109000" />
</task>
<task id="LOCAL-00001" summary="调试">
<created>1574145133364</created>
... ... @@ -222,7 +232,7 @@
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="53166000" />
<option name="totallyTimeSpent" value="55462000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
... ... @@ -234,7 +244,7 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="667" y="102" width="1589" height="930" extended-state="0" />
<frame x="529" y="29" 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" />
... ... @@ -244,7 +254,7 @@
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.26986128" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2319202" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
... ... @@ -600,16 +610,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/common/library/Auth.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="650">
<caret line="212" column="0" lean-forward="true" selection-start-line="212" selection-start-column="0" selection-end-line="212" selection-end-column="0" />
<folding>
<element signature="e#38#64#0#PHP" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/thinkphp/library/think/Validate.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="453">
... ... @@ -639,19 +639,26 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/common/library/Auth.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="585">
<caret line="105" column="38" lean-forward="true" selection-start-line="105" selection-start-column="38" selection-end-line="105" selection-end-column="38" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/api/controller/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="329">
<caret line="271" column="5" lean-forward="true" selection-start-line="271" selection-start-column="5" selection-end-line="271" selection-end-column="5" />
<state relative-caret-position="219">
<caret line="306" column="30" lean-forward="true" selection-start-line="306" selection-start-column="30" selection-end-line="306" selection-end-column="30" />
<folding>
<element signature="e#38#68#0#PHP" expanded="true" />
<element signature="e#312#384#0#PHP" expanded="false" />
<element signature="e#390#1128#0#PHP" expanded="false" />
<element signature="e#1133#2796#0#PHP" expanded="false" />
<element signature="e#2802#3330#0#PHP" expanded="false" />
<element signature="e#3335#4106#0#PHP" expanded="false" />
<element signature="e#4112#4519#0#PHP" expanded="false" />
<element signature="e#4873#5474#0#PHP" expanded="false" />
<element signature="e#462#1200#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#7344#7793#0#PHP" expanded="false" />
<element signature="e#7798#8681#0#PHP" expanded="false" />
</folding>
</state>
</provider>
... ...
... ... @@ -17,10 +17,12 @@ class User extends Api
{
protected $noNeedLogin = ['login'];
protected $noNeedRight = '*';
protected $uid = '';
public function _initialize()
{
parent::_initialize();
$this->uid = $this->auth->getUserId();
}
/**
... ... @@ -166,17 +168,18 @@ class User extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/user/search)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="type_id", type="inter", required=false, description="视频/图片 (视频为1 图片为2 精美大片为3)")
* @ApiParams (name="keyword", type="string", required=true, description="关键字")
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": 4,//视频id/图片id,
"thumbnail": //视频封面图地址/图片地址,
"video": //视频路径/精美大片视频路径,
}
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": 4,//视频id/图片id,
"thumbnail": //视频封面图地址/图片地址,
"video": //视频路径/精美大片视频路径,
}
})
*/
public function search()
... ... @@ -271,4 +274,62 @@ class User extends Api
}
}
/**
* @ApiTitle (图片详情)
* @ApiSummary (图片详情)
* @ApiMethod (POST)
* @ApiRoute (/api/user/picdetail)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="pic_id", type="inter", required=true, description="图片ID")
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": 4,//图片id,
"thumbnail": //缩略图,
"water_url": //带水印的地址,
"url": //高清地址,
"price"://正常价格,
"vip_price"://vip价格,
"content"://图片介绍,
"is_vip"://是否为会员(0否 1是)
}
})
*/
public function picdetail()
{
$uid = $this->uid;
$rule = config('verify.path');
$res = Db::name('user')
->where('id',$uid)
->field('id,is_vip')
->find();
if($res['is_vip'] == 0){
$pic_id = $this->request->post('pic_id');
if(empty($pic_id)){
$this->error(['code'=>2,'msg'=>'缺少必要参数']);
}
$data = Db::name('pic')
->where('id',$pic_id)
->find();
$data['thumbnail'] = $rule.$data['thumbnail'];
$data['is_vip'] = 0;
$this->success('SUCCESS',$data);
}elseif($res['is_vip'] == 1){
$pic_id = $this->request->post('pic_id');
if(empty($pic_id)){
$this->error(['code'=>2,'msg'=>'缺少必要参数']);
}
$data = Db::name('pic')
->where('id',$pic_id)
->find();
$data['is_vip'] = 1;
$data['thumbnail'] = $rule.$data['thumbnail'];
$this->success('SUCCESS',$data);
}
}
}
... ...
... ... @@ -23,6 +23,7 @@ class Auth
protected $keeptime = 2592000;
protected $requestUri = '';
protected $rules = [];
protected $user_id = '';
//默认配置
protected $config = [];
protected $options = [];
... ... @@ -102,6 +103,7 @@ class Auth
$this->_user = $user;
$this->_logined = true;
$this->_token = $token;
$this->user_id = $user_id;
//初始化成功的事件
Hook::listen("user_init_successed", $this->_user);
... ... @@ -220,6 +222,7 @@ class Auth
} else {
$result['jointime'] = time();
$result['joinip'] = request()->ip();
$result['status'] = 'normal';
$userModel->create($result);
}
$user = User::get($where);
... ... @@ -571,4 +574,13 @@ class Auth
{
return $this->_error ? __($this->_error) : '';
}
/**
* 获取user_id
* @return mixed
*/
public function getUserId()
{
return $this->user_id;
}
}
... ...
... ... @@ -169,6 +169,7 @@
<a href="javascript:;" data-id="10" class="list-group-item">地区分类</a>
<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>
</div>
</div>
</div>
... ... @@ -1676,14 +1677,14 @@
<div class="row">
<div class="col-md-12">
<pre id="sample_response11">{
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": 4,//视频id/图片id,
"thumbnail": //视频封面图地址/图片地址,
"video": //视频路径/精美大片视频路径,
}
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": 4,//视频id/图片id,
"thumbnail": //视频封面图地址/图片地址,
"video": //视频路径/精美大片视频路径,
}
}</pre>
</div>
</div>
... ... @@ -1839,13 +1840,166 @@
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" id="heading-13">
<h4 class="panel-title">
<span class="label label-primary">POST</span>
<a data-toggle="collapse" data-parent="#accordion13" href="#collapseOne13"> 图片详情 <span class="text-muted">/api/user/picdetail</span></a>
</h4>
</div>
<div id="collapseOne13" class="panel-collapse collapse">
<div class="panel-body">
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="doctab13">
<li class="active"><a href="#info13" data-toggle="tab">基础信息</a></li>
<li><a href="#sandbox13" data-toggle="tab">在线测试</a></li>
<li><a href="#sample13" data-toggle="tab">返回示例</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="info13">
<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">
<table class="table table-hover">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>pic_id</td>
<td>inter</td>
<td></td>
<td>图片ID</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><!-- #info -->
<div class="tab-pane" id="sandbox13">
<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/picdetail" method="POST" name="form13" id="form13">
<div class="form-group">
<label class="control-label" for="pic_id">pic_id</label>
<input type="inter" class="form-control input-sm" id="pic_id" required placeholder="图片ID" name="pic_id">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="13">提交</button>
<button type="reset" class="btn btn-info" rel="13">重置</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_headers13"></pre>
<pre id="response13"></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="sample13">
<div class="row">
<div class="col-md-12">
<pre id="sample_response13">{
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": 4,//图片id,
"thumbnail": //缩略图,
"water_url": //带水印的地址,
"url": //高清地址,
"price"://正常价格,
"vip_price"://vip价格,
"content"://图片介绍,
"is_vip"://是否为会员(0否 1是)
}
}</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 16:23:27 </div>
Generated on 2019-11-19 17:01:47 </div>
<div class="col-md-6" align="right">
<a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
</div>
... ...