From 9746493f6b556f502d4ecc04c89c1806cee1dd5b Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 25 Feb 2025 09:49:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=99=84=E4=BB=B6=EF=BC=88=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E7=AE=A1=E7=90=86=EF=BC=89=E6=B7=BB=E5=8A=A0=E7=A6=81?= =?UTF-8?q?/=E5=90=AF=E7=94=A8=E6=93=8D=E4=BD=9C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/v1/Attachment.php | 19 +++++++++++++++++++ app/admin/route/v1.php | 3 +++ app/common/model/AttachmentBaseModel.php | 1 + 3 files changed, 23 insertions(+) diff --git a/app/admin/controller/v1/Attachment.php b/app/admin/controller/v1/Attachment.php index a4109b6c..611c2621 100644 --- a/app/admin/controller/v1/Attachment.php +++ b/app/admin/controller/v1/Attachment.php @@ -173,6 +173,25 @@ class Attachment return success('操作成功'); } + /** + * 禁/启用 + */ + public function enable() + { + $id = request()->param('id'); + + $attachment = AttachmentModel::bypk($id)->find(); + if (empty($attachment)) { + return error('请确认操作对象是否存在'); + } + + $attachment->status = $attachment->status == 1 ? -1 : 1; + if (!$attachment->save()) { + return error('操作失败'); + } + return success('操作成功'); + } + /** * 附件删除 */ diff --git a/app/admin/route/v1.php b/app/admin/route/v1.php index 461c908d..2584a725 100644 --- a/app/admin/route/v1.php +++ b/app/admin/route/v1.php @@ -292,6 +292,9 @@ Route::group('v1', function () { // 附件(下载管理)设置排序值 Route::post('sort/:id', 'Attachment/sort'); + // 附件(下载管理)禁/启用 + Route::get('enable/:id', 'Attachment/enable'); + // 附件(下载管理)删除 Route::delete('delete/:id', 'Attachment/delete'); diff --git a/app/common/model/AttachmentBaseModel.php b/app/common/model/AttachmentBaseModel.php index a4cb562b..4154ab59 100644 --- a/app/common/model/AttachmentBaseModel.php +++ b/app/common/model/AttachmentBaseModel.php @@ -28,6 +28,7 @@ class AttachmentBaseModel extends BaseModel 'attach' => 'string', 'sort' => 'int', 'recommend' => 'int', + 'status' => 'int', 'seo_title' => 'string', 'seo_keywords' => 'string', 'seo_desc' => 'string',