接口文档更新

This commit is contained in:
2018-08-12 17:42:34 +08:00
parent 7433530805
commit 1f251a9103
7 changed files with 289 additions and 40 deletions

View File

@@ -3,21 +3,54 @@ namespace app\api\controller;
class Content extends \app\common\controller\Api{
public function lists($page = 1, $pagesize = 25){
$list = db('Article')->page($page . ',' . $pagesize)->order('id desc')->select();
foreach($list as $key => $value){
$list[$key]['create_time'] = date('Y-m-d H:i:s', $value['create_time']);
$list[$key]['cover'] = 'https://www.tensent.cn' . get_cover($value['cover_id'], 'path');
public function category(){
$model_id = $this->request->param('model_id', 0);
$map = array();
if ($model_id) {
$map['model_id'] = $model_id;
}
$this->data['list'] = $list;
$list = db('Category')->where($map)->order('sort asc')->select();
$this->data['data'] = $list;
return $this->data;
}
public function detail($id = 0){
$info = db('Article')->where('id', $id)->find();
public function lists(){
$pagesize = $this->request->param('pagesize', 25);
$category_id = $this->request->param('category_id', 0);
$model = $this->request->param('model', 'Article');
$map = array();
if ($category_id) {
$map['category_id'] = $category_id;
}
$res = db($model)->where($map)->order('id desc')->paginate($pagesize);
$data = $res->toArray();
$list = array();
foreach($data['data'] as $key => $value){
$value['create_time'] = date('Y-m-d H:i:s', $value['create_time']);
$value['cover'] = $this->serverurl . get_cover($value['cover_id'], 'path');
$list[] = $value;
}
$data['data'] = $list;
$this->data['data'] = $data;
return $this->data;
}
public function detail($id = 0, $model = 'Article'){
$info = db($model)->where('id', $id)->find();
$info['create_time'] = date('Y-m-d H:i:s', $info['create_time']);
$info['content'] = str_replace('/uploads/', 'https://www.tensent.cn/uploads/', $info['content']);
$info['cover'] = 'https://www.tensent.cn' . get_cover($info['cover_id'], 'path');
$info['content'] = str_replace('/uploads/', $this->serverurl . '/uploads/', $info['content']);
$info['cover'] = $this->serverurl . get_cover($info['cover_id'], 'path');
$info['download'] = get_file($info['download_file']);
if (isset($info['download']['url'])) {
$info['download']['url'] = $this->serverurl . $info['download']['url'];
}
$this->data['info'] = $info;
return $this->data;