新增附件管理
This commit is contained in:
31
catch/system/controller/Attachments.php
Normal file
31
catch/system/controller/Attachments.php
Normal 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();
|
||||
}
|
||||
}
|
@@ -7,11 +7,6 @@ use think\facade\Db;
|
||||
|
||||
class LoginLog extends CatchController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
return CatchResponse::paginate(Db::name('login_log')->paginate(10));
|
||||
|
@@ -7,11 +7,6 @@ use think\facade\Db;
|
||||
|
||||
class OperateLog extends CatchController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
return CatchResponse::paginate(
|
||||
|
@@ -35,7 +35,9 @@ class Upload extends CatchController
|
||||
*/
|
||||
public function image(CatchRequest $request, CatchUpload $upload): \think\response\Json
|
||||
{
|
||||
return CatchResponse::success($upload->upload($request->file('image')));
|
||||
$images = $request->file();
|
||||
|
||||
return CatchResponse::success($upload->checkImages($images)->multiUpload($images['image']));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,6 +50,8 @@ class Upload extends CatchController
|
||||
*/
|
||||
public function file(CatchRequest $request, CatchUpload $upload): \think\response\Json
|
||||
{
|
||||
return CatchResponse::success($upload->upload($request->file('file')));
|
||||
$files = $request->file();
|
||||
|
||||
return CatchResponse::success($upload->checkFiles($files)->multiUpload($files['file']));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user