From 655e64e92777a6a81926dd902a04750f056be8c6 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Fri, 21 Feb 2025 15:35:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=A7=86=E9=A2=91=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=88=86=E7=B1=BB=E6=B7=BB=E5=8A=A0=E8=BD=AF=E4=BB=B6?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/model/v1/VideoCategoryModel.php | 8 ++++++++ app/common/model/VideoCategoryBaseModel.php | 1 + .../migrations/20241220073105_create_video_category.php | 1 + 3 files changed, 10 insertions(+) diff --git a/app/admin/model/v1/VideoCategoryModel.php b/app/admin/model/v1/VideoCategoryModel.php index 0ad1941f..1f2c9571 100644 --- a/app/admin/model/v1/VideoCategoryModel.php +++ b/app/admin/model/v1/VideoCategoryModel.php @@ -4,6 +4,7 @@ declare (strict_types = 1); namespace app\admin\model\v1; use app\common\model\VideoCategoryBaseModel; +use think\model\concern\SoftDelete; /** * 视频分类模型 @@ -11,6 +12,13 @@ use app\common\model\VideoCategoryBaseModel; */ class VideoCategoryModel extends VideoCategoryBaseModel { + // 启用软件删除 + use SoftDelete; + // 软删除字段 + protected $deleteTime = 'deleted_at'; + // 自动写入时间格式 + protected $autoWriteTimestamp = 'datetime'; + // 关联视频模型 public function video() { diff --git a/app/common/model/VideoCategoryBaseModel.php b/app/common/model/VideoCategoryBaseModel.php index 79781b7c..61e9bed8 100644 --- a/app/common/model/VideoCategoryBaseModel.php +++ b/app/common/model/VideoCategoryBaseModel.php @@ -24,5 +24,6 @@ class VideoCategoryBaseModel extends BaseModel 'is_show' => 'int', 'created_at' => 'datetime', 'updated_at' => 'datetime', + 'deleted_at' => 'datetime', ]; } diff --git a/database/migrations/20241220073105_create_video_category.php b/database/migrations/20241220073105_create_video_category.php index 65049a63..733bbb9c 100644 --- a/database/migrations/20241220073105_create_video_category.php +++ b/database/migrations/20241220073105_create_video_category.php @@ -34,6 +34,7 @@ class CreateVideoCategory extends Migrator ->addColumn('is_show', 'boolean', ['null' => false, 'default' => 1, 'comment' => '是否显示:1是,0否']) ->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'comment' => '更新时间']) + ->addColumn('deleted_at', 'timestamp', ['null' => true, 'default' => null, 'comment' => '删除时间']) ->create(); } }