作者 郭宇鹏
1 个管道 的构建 通过 耗费 1 秒

'1-6'

... ... @@ -114,7 +114,6 @@ class Production extends BaseApi
$data['user_id'] = $this->auth->id;
$data['avatar'] = $this->auth->avatar;
$data['nickname'] = $this->auth->nickname;
$data['images'] = $data['images'];
//5.增加作品
$production = model('production')->create($data);
//6.查询数据
... ...
... ... @@ -26,6 +26,7 @@ class User extends BaseApi
* @ApiTitle (会员中心)
* @ApiMethod (POST)
* @ApiRoute (/api/user/index)
* @ApiParams (name="user_id", type="integer", required=true, description="用户id")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -61,8 +62,18 @@ class User extends BaseApi
*/
public function index()
{
//获取用户id
$user_id = $this->get_data('user_id','用户id不能为空');
//更新用户的查看浏览量
//获取用户信息
$user = model('user')->where('id',$this->auth->id)->find();
$user = model('user')->where('id',$user_id)->find();
//查看数量
if (!$user){
$this->error('该用户不存在');
}
//判断用户
$user->show_num += 1;
$user->save();
$this->success('查询用户信息成功', $user);
}
... ...
... ... @@ -7,6 +7,11 @@ namespace app\common\model;
class Production extends BaseModel
{
// 追加属性
protected $append = [
'one_image'
];
/**
* 关联用户表
*/
... ... @@ -14,4 +19,17 @@ class Production extends BaseModel
return $this->belongsTo('user','user_id','id');
}
public function getOneImageAttr($value,$data)
{
$arr = explode(',',$data['images']);
foreach ($arr as $key => $val){
$arr[$key] = cdnurl($val);
}
if (empty($arr)){
return '';
}
return $arr[0];
}
}
\ No newline at end of file
... ...
... ... @@ -10278,7 +10278,24 @@
<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>user_id</td>
<td>integer</td>
<td></td>
<td>用户id</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-default">
... ... @@ -10296,7 +10313,8 @@
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/index" method="POST" name="form66" id="form66">
<div class="form-group">
<label class="control-label" for="user_id">user_id</label>
<input type="integer" class="form-control input-sm" id="user_id" required placeholder="用户id" name="user_id">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="66">提交</button>
... ... @@ -10377,6 +10395,7 @@
"brief": "个人简介",
"show_array":"显示字段",
"is_ok_arr":"获取可以显示隐藏的字段",
"is_expert":"是否是专家:0=不是,1=是",
"createtime": 0,
"updatetime": 1608086439,
"url": "/u/1"
... ... @@ -13316,7 +13335,7 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2021-01-06 15:30:48 </div>
Generated on 2021-01-06 17:19:50 </div>
<div class="col-md-6" align="right">
<a href="./" target="_blank">书法公众号</a>
</div>
... ...