新增附件管理

This commit is contained in:
yanwenwu
2020-02-02 22:11:38 +08:00
parent a752c7914a
commit 766d156bf8
7 changed files with 65 additions and 13 deletions

View File

@@ -0,0 +1,31 @@
<?php
namespace catchAdmin\system\controller;
use catcher\base\CatchController;
use catcher\CatchResponse;
use catchAdmin\system\model\Attachments as AttachmentsModel;
use catcher\Utils;
use think\facade\Filesystem;
class Attachments extends CatchController
{
public function index(AttachmentsModel $model)
{
return CatchResponse::paginate($model->getList());
}
public function delete($id, AttachmentsModel $model)
{
$ids = Utils::stringToArrayBy($id);
foreach ($ids as $id) {
$attachment = $model->findBy($id);
if ($attachment && $model->deleteBy($id)) {
Filesystem::delete($attachment->path);
}
}
return CatchResponse::success();
}
}