mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-11-10 04:50:50 +08:00
feat(notice): 通知三表与 SystemAdmin email 字段 Scheme 及迁移
This commit is contained in:
@@ -56,4 +56,7 @@ class SystemAdmin extends BaseScheme
|
|||||||
|
|
||||||
#[Field(length: 50, precision: 50, default: '', comment: '昵称')]
|
#[Field(length: 50, precision: 50, default: '', comment: '昵称')]
|
||||||
public $nickname;
|
public $nickname;
|
||||||
|
|
||||||
|
#[Field(type: 'char', length: 100, precision: 100, default: '', comment: '电子邮箱')]
|
||||||
|
public $email;
|
||||||
}
|
}
|
||||||
42
app/admin/scheme/SystemNotice.php
Normal file
42
app/admin/scheme/SystemNotice.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\scheme;
|
||||||
|
|
||||||
|
use app\common\scheme\BaseScheme;
|
||||||
|
use app\common\scheme\attribute\Table;
|
||||||
|
use app\common\scheme\attribute\Field;
|
||||||
|
use app\common\scheme\attribute\Component;
|
||||||
|
use app\common\scheme\attribute\Index;
|
||||||
|
|
||||||
|
#[Table(name: 'ul_system_notice', comment: '系统通知表')]
|
||||||
|
#[Index(columns: ['scene'], name: 'idx_scene', type: 'NORMAL')]
|
||||||
|
#[Index(columns: ['create_time'], name: 'idx_create_time', type: 'NORMAL')]
|
||||||
|
class SystemNotice extends BaseScheme
|
||||||
|
{
|
||||||
|
#[Field(type: 'int', length: 11, nullable: false, unsigned: true, autoIncrement: true, primary: true)]
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
#[Field(type: 'varchar', length: 50, precision: 50, default: 'common', comment: '通知场景')]
|
||||||
|
public $scene;
|
||||||
|
|
||||||
|
#[Field(type: 'varchar', length: 255, precision: 255, comment: '通知标题')]
|
||||||
|
public $title;
|
||||||
|
|
||||||
|
#[Field(type: 'text', nullable: true, comment: '通知内容')]
|
||||||
|
public $content;
|
||||||
|
|
||||||
|
#[Field(type: 'varchar', length: 64, precision: 64, default: '', comment: '业务关联ID')]
|
||||||
|
public $biz_id;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', comment: '发送管理员ID', unsigned: true)]
|
||||||
|
public $send_admin_id;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', comment: '创建时间', unsigned: true)]
|
||||||
|
public $create_time;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', unsigned: true)]
|
||||||
|
public $update_time;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', unsigned: true)]
|
||||||
|
public $delete_time;
|
||||||
|
}
|
||||||
35
app/admin/scheme/SystemNoticeSubscribe.php
Normal file
35
app/admin/scheme/SystemNoticeSubscribe.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\scheme;
|
||||||
|
|
||||||
|
use app\common\scheme\BaseScheme;
|
||||||
|
use app\common\scheme\attribute\Table;
|
||||||
|
use app\common\scheme\attribute\Field;
|
||||||
|
use app\common\scheme\attribute\Component;
|
||||||
|
use app\common\scheme\attribute\Index;
|
||||||
|
|
||||||
|
#[Table(name: 'ul_system_notice_subscribe', comment: '系统通知订阅表')]
|
||||||
|
#[Index(columns: ['admin_id', 'scene', 'channel'], name: 'uniq_admin_scene_channel', type: 'UNIQUE')]
|
||||||
|
class SystemNoticeSubscribe extends BaseScheme
|
||||||
|
{
|
||||||
|
#[Field(type: 'int', length: 11, nullable: false, unsigned: true, autoIncrement: true, primary: true)]
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', comment: '管理员ID', unsigned: true)]
|
||||||
|
public $admin_id;
|
||||||
|
|
||||||
|
#[Field(type: 'varchar', length: 50, precision: 50, comment: '通知场景')]
|
||||||
|
public $scene;
|
||||||
|
|
||||||
|
#[Field(type: 'varchar', length: 20, precision: 20, comment: '投递渠道')]
|
||||||
|
public $channel;
|
||||||
|
|
||||||
|
#[Field(type: 'tinyint', length: 1, default: '1', comment: '订阅状态:0=退订,1=订阅')]
|
||||||
|
public $status;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', comment: '创建时间', unsigned: true)]
|
||||||
|
public $create_time;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', unsigned: true)]
|
||||||
|
public $update_time;
|
||||||
|
}
|
||||||
61
app/admin/scheme/SystemNoticeTarget.php
Normal file
61
app/admin/scheme/SystemNoticeTarget.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\scheme;
|
||||||
|
|
||||||
|
use app\common\scheme\BaseScheme;
|
||||||
|
use app\common\scheme\attribute\Table;
|
||||||
|
use app\common\scheme\attribute\Field;
|
||||||
|
use app\common\scheme\attribute\Component;
|
||||||
|
use app\common\scheme\attribute\Index;
|
||||||
|
|
||||||
|
#[Table(name: 'ul_system_notice_target', comment: '系统通知投递目标表')]
|
||||||
|
#[Index(columns: ['status', 'id'], name: 'idx_status_id', type: 'NORMAL')]
|
||||||
|
#[Index(columns: ['admin_id', 'channel', 'read_time'], name: 'idx_admin_channel_read', type: 'NORMAL')]
|
||||||
|
#[Index(columns: ['notice_id'], name: 'idx_notice_id', type: 'NORMAL')]
|
||||||
|
class SystemNoticeTarget extends BaseScheme
|
||||||
|
{
|
||||||
|
#[Field(type: 'int', length: 11, nullable: false, unsigned: true, autoIncrement: true, primary: true)]
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', comment: '通知ID', unsigned: true)]
|
||||||
|
public $notice_id;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', comment: '接收管理员ID', unsigned: true)]
|
||||||
|
public $admin_id;
|
||||||
|
|
||||||
|
#[Field(type: 'varchar', length: 20, precision: 20, comment: '投递渠道')]
|
||||||
|
public $channel;
|
||||||
|
|
||||||
|
#[Field(type: 'varchar', length: 255, precision: 255, default: '', comment: '投递目标地址')]
|
||||||
|
public $target_addr;
|
||||||
|
|
||||||
|
#[Field(type: 'tinyint', length: 1, default: '0', comment: '状态:0=待发,1=发送中,2=成功,3=失败')]
|
||||||
|
public $status;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', comment: '发送时间', unsigned: true)]
|
||||||
|
public $send_time;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', comment: '阅读时间', unsigned: true)]
|
||||||
|
public $read_time;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', comment: '抢占时间', unsigned: true)]
|
||||||
|
public $claim_time;
|
||||||
|
|
||||||
|
#[Field(type: 'varchar', length: 32, precision: 32, default: '', comment: '抢占令牌')]
|
||||||
|
public $claim_token;
|
||||||
|
|
||||||
|
#[Field(type: 'tinyint', length: 1, default: '0', comment: '重试次数')]
|
||||||
|
public $retry_count;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', comment: '下次重试时间', unsigned: true)]
|
||||||
|
public $next_retry_time;
|
||||||
|
|
||||||
|
#[Field(type: 'varchar', length: 500, precision: 500, default: '', comment: '错误信息')]
|
||||||
|
public $error_message;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', comment: '创建时间', unsigned: true)]
|
||||||
|
public $create_time;
|
||||||
|
|
||||||
|
#[Field(type: 'int', length: 11, default: '0', unsigned: true)]
|
||||||
|
public $update_time;
|
||||||
|
}
|
||||||
62
database/migrations/20261012000001_system_notice_tables.php
Normal file
62
database/migrations/20261012000001_system_notice_tables.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use think\migration\Migrator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知系统三张表(全新库安装用,存量库由 scheme:sync 维护).
|
||||||
|
*
|
||||||
|
* system_notice:通知主体(软删)。
|
||||||
|
* system_notice_target:接收人 x 渠道投递行(队列字段齐全,无软删)。
|
||||||
|
* system_notice_subscribe:订阅矩阵,UNIQUE(admin_id, scene, channel)。
|
||||||
|
*/
|
||||||
|
class SystemNoticeTables extends Migrator
|
||||||
|
{
|
||||||
|
public function change()
|
||||||
|
{
|
||||||
|
$this->table('system_notice')
|
||||||
|
->setComment('系统通知表')
|
||||||
|
->addColumn('scene', 'string', ['limit' => 50, 'null' => true, 'default' => 'common', 'comment' => '通知场景'])
|
||||||
|
->addColumn('title', 'string', ['limit' => 255, 'null' => true, 'comment' => '通知标题'])
|
||||||
|
->addColumn('content', 'text', ['null' => true, 'comment' => '通知内容'])
|
||||||
|
->addColumn('biz_id', 'string', ['limit' => 64, 'null' => true, 'default' => '', 'comment' => '业务关联ID'])
|
||||||
|
->addColumn('send_admin_id', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '发送管理员ID'])
|
||||||
|
->addColumn('create_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '创建时间'])
|
||||||
|
->addColumn('update_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false])
|
||||||
|
->addColumn('delete_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false])
|
||||||
|
->addIndex(['scene'], ['name' => 'idx_scene'])
|
||||||
|
->addIndex(['create_time'], ['name' => 'idx_create_time'])
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$this->table('system_notice_target')
|
||||||
|
->setComment('系统通知投递目标表')
|
||||||
|
->addColumn('notice_id', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '通知ID'])
|
||||||
|
->addColumn('admin_id', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '接收管理员ID'])
|
||||||
|
->addColumn('channel', 'string', ['limit' => 20, 'null' => true, 'comment' => '投递渠道'])
|
||||||
|
->addColumn('target_addr', 'string', ['limit' => 255, 'null' => true, 'default' => '', 'comment' => '投递目标地址'])
|
||||||
|
->addColumn('status', 'tinyinteger', ['limit' => 1, 'null' => true, 'default' => 0, 'comment' => '状态:0=待发,1=发送中,2=成功,3=失败'])
|
||||||
|
->addColumn('send_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '发送时间'])
|
||||||
|
->addColumn('read_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '阅读时间'])
|
||||||
|
->addColumn('claim_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '抢占时间'])
|
||||||
|
->addColumn('claim_token', 'string', ['limit' => 32, 'null' => true, 'default' => '', 'comment' => '抢占令牌'])
|
||||||
|
->addColumn('retry_count', 'tinyinteger', ['limit' => 1, 'null' => true, 'default' => 0, 'comment' => '重试次数'])
|
||||||
|
->addColumn('next_retry_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '下次重试时间'])
|
||||||
|
->addColumn('error_message', 'string', ['limit' => 500, 'null' => true, 'default' => '', 'comment' => '错误信息'])
|
||||||
|
->addColumn('create_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '创建时间'])
|
||||||
|
->addColumn('update_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false])
|
||||||
|
->addIndex(['status', 'id'], ['name' => 'idx_status_id'])
|
||||||
|
->addIndex(['admin_id', 'channel', 'read_time'], ['name' => 'idx_admin_channel_read'])
|
||||||
|
->addIndex(['notice_id'], ['name' => 'idx_notice_id'])
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$this->table('system_notice_subscribe')
|
||||||
|
->setComment('系统通知订阅表')
|
||||||
|
->addColumn('admin_id', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '管理员ID'])
|
||||||
|
->addColumn('scene', 'string', ['limit' => 50, 'null' => true, 'comment' => '通知场景'])
|
||||||
|
->addColumn('channel', 'string', ['limit' => 20, 'null' => true, 'comment' => '投递渠道'])
|
||||||
|
->addColumn('status', 'tinyinteger', ['limit' => 1, 'null' => true, 'default' => 1, 'comment' => '订阅状态:0=退订,1=订阅'])
|
||||||
|
->addColumn('create_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '创建时间'])
|
||||||
|
->addColumn('update_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false])
|
||||||
|
->addIndex(['admin_id', 'scene', 'channel'], ['unique' => true, 'name' => 'uniq_admin_scene_channel'])
|
||||||
|
->create();
|
||||||
|
}
|
||||||
|
}
|
||||||
20
database/migrations/20261012000002_system_admin_email.php
Normal file
20
database/migrations/20261012000002_system_admin_email.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use think\migration\Migrator;
|
||||||
|
use think\migration\db\Column;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* system_admin 追加电子邮箱字段(幂等,已存在则跳过).
|
||||||
|
*/
|
||||||
|
class SystemAdminEmail extends Migrator
|
||||||
|
{
|
||||||
|
public function change()
|
||||||
|
{
|
||||||
|
$table = $this->table('system_admin');
|
||||||
|
|
||||||
|
if(!$table->hasColumn('email')){
|
||||||
|
$table->addColumn(Column::char('email', 100)->setDefault('')->setComment('电子邮箱'));
|
||||||
|
$table->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user