| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- /**
- *
- * @copyright ©2020 点小铺
- * @author hanj
- * @link: https://dyuit.com
- * Created by VSCode
- */
- namespace app\store\controller\content;
- use app\store\controller\Controller;
- use app\store\model\UploadFile as UploadFileModel;
- /**
- * 文件库管理
- * Class Files
- * @package app\store\controller
- */
- class Files extends Controller
- {
- /**
- * 文件列表
- * @return mixed
- * @throws \think\exception\DbException
- */
- public function index()
- {
- $model = new UploadFileModel;
- $list = $model->getList(-1, '', 0);
- return $this->fetch('index', compact('list'));
- }
- /**
- * 回收站列表
- * @return mixed
- * @throws \think\exception\DbException
- */
- public function recycle()
- {
- $model = new UploadFileModel;
- $list = $model->getList(-1, '', 1);
- return $this->fetch('recycle', compact('list'));
- }
- /**
- * 移入回收站
- * @param $file_id
- * @return array
- * @throws \think\exception\DbException
- */
- public function recovery($file_id)
- {
- // 文章详情
- $model = UploadFileModel::detail($file_id);
- if (!$model->setRecycle(true)) {
- return $this->renderError($model->getError() ?: '操作失败');
- }
- return $this->renderSuccess('操作成功');
- }
- /**
- * 移出回收站
- * @param $file_id
- * @return array
- * @throws \think\exception\DbException
- */
- public function restore($file_id)
- {
- // 商品详情
- $model = UploadFileModel::detail($file_id);
- if (!$model->setRecycle(false)) {
- return $this->renderError('操作失败');
- }
- return $this->renderSuccess('操作成功');
- }
- /**
- * 删除文件
- * @param $file_id
- * @return array|bool
- * @throws \think\Exception
- * @throws \think\exception\DbException
- */
- public function delete($file_id)
- {
- // 商品详情
- $model = UploadFileModel::detail($file_id);
- if (!$model->setDelete()) {
- return $this->renderError($model->getError() ?: '操作失败');
- }
- return $this->renderSuccess('操作成功');
- }
- }
|