checkToken(); if ($token[ 'code' ] < 0) { echo $this->response($token); exit; } } /** * 获取相册分组 * @return false|string */ public function lists() { $album_model = new AlbumModel(); $type = $this->params['type'] ?? 'img'; $album_list = $album_model->getAlbumListTree([ [ 'site_id', "=", $this->site_id ], ['type', '=', $type] ]); return $this->response($album_list); } /** * 获取图片列表 * @return false|string */ public function picList() { $page = isset($this->params[ 'page' ]) ? $this->params[ 'page' ] : 1; $limit = isset($this->params[ 'page_size' ]) ? $this->params[ 'page_size' ] : PAGE_LIST_ROWS; $album_id = isset($this->params[ 'album_id' ]) ? $this->params[ 'album_id' ] : 0; $album_model = new AlbumModel(); $condition = array ( [ 'site_id', "=", $this->site_id ], [ 'album_id', "=", $album_id ], ); if (!empty($pic_name)) { $condition[] = [ 'pic_name', 'like', '%' . $pic_name . '%' ]; } $list = $album_model->getAlbumPicPageList($condition, $page, $limit, 'update_time desc','pic_path'); return $this->response($list); } /** * 生成缩略图 */ public function createThumb() { ignore_user_abort(true); $upload_model = new AlbumModel(); $pic_path = isset($this->params[ 'pic_path' ]) ? $this->params[ 'pic_path' ] : ''; $pic_ids = $upload_model->getAlbumPicList([ ['pic_path', 'in', $pic_path], ['site_id', '=', $this->site_id] ], 'pic_id')['data'] ?? []; $pic_ids = array_column($pic_ids, 'pic_id'); $thumb_batch = $upload_model->createThumbBatch($this->site_id, $pic_ids); return $this->response($thumb_batch); } }