refactor: 视频信息分类添加软件删除

This commit is contained in:
2025-02-21 15:35:51 +08:00
parent af9ab0f4ab
commit 8a5b1bdaa7
3 changed files with 10 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ declare (strict_types = 1);
namespace app\admin\model\v1; namespace app\admin\model\v1;
use app\common\model\VideoCategoryBaseModel; use app\common\model\VideoCategoryBaseModel;
use think\model\concern\SoftDelete;
/** /**
* 视频分类模型 * 视频分类模型
@@ -11,6 +12,13 @@ use app\common\model\VideoCategoryBaseModel;
*/ */
class VideoCategoryModel extends VideoCategoryBaseModel class VideoCategoryModel extends VideoCategoryBaseModel
{ {
// 启用软件删除
use SoftDelete;
// 软删除字段
protected $deleteTime = 'deleted_at';
// 自动写入时间格式
protected $autoWriteTimestamp = 'datetime';
// 关联视频模型 // 关联视频模型
public function video() public function video()
{ {

View File

@@ -24,5 +24,6 @@ class VideoCategoryBaseModel extends BaseModel
'is_show' => 'int', 'is_show' => 'int',
'created_at' => 'datetime', 'created_at' => 'datetime',
'updated_at' => 'datetime', 'updated_at' => 'datetime',
'deleted_at' => 'datetime',
]; ];
} }

View File

@@ -34,6 +34,7 @@ class CreateVideoCategory extends Migrator
->addColumn('is_show', 'boolean', ['null' => false, 'default' => 1, 'comment' => '是否显示:1是,0否']) ->addColumn('is_show', 'boolean', ['null' => false, 'default' => 1, 'comment' => '是否显示:1是,0否'])
->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->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('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'comment' => '更新时间'])
->addColumn('deleted_at', 'timestamp', ['null' => true, 'default' => null, 'comment' => '删除时间'])
->create(); ->create();
} }
} }