作者 何书鹏
1 个管道 的构建 通过 耗费 0 秒

11

... ... @@ -166,7 +166,8 @@ class User extends Api
* 我的-积分记录
* @ApiMethod (GET)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="page", type="integer", description="页码")
* @ApiParams (name="rows", type="integer", required=true, description="每页条数")
* @ApiParams (name="page", type="integer", required=true, description="页码")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -176,9 +177,10 @@ class User extends Api
})
*/
public function scoreLog(){
$page = $this->request->request('page');
$rows = $this->request->request('rows',config('paginate.list_rows'));// 每页条数
$page = $this->request->request('page',1);// 页码
$score = $this->user['score'];
$list = $this->model->scoreLog($this->user['id'],$page);
$list = $this->model->scoreLog($this->user['id'],$page,$rows);
$this->success(__('成功'),compact('score','list'));
}
... ...
... ... @@ -54,12 +54,15 @@ class User extends Model
/**
* 积分记录
*/
public function scoreLog($user_id,$page)
public function scoreLog($user_id,$page,$rows=15)
{
return ScoreLog::where('user_id',$user_id)
$list = ScoreLog::where('user_id',$user_id)
->order(['createtime' => 'desc'])
->page(15, false, [
'query' => ['page'=>$page]
])->select();
->paginate($rows,false,['page'=>$page])
->each(function($v){
$v['createtime'] = date('Y-m-d H:i',$v['createtime']);
$v->visible(['score','memo','createtime']);
})->toArray();
return ['total'=>$list['total'],'list'=>$list['data']];
}
}
... ...