初始化
This commit is contained in:
575
database/migrations/20230620180908_install.php
Normal file
575
database/migrations/20230620180908_install.php
Normal file
@@ -0,0 +1,575 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class Install extends Migrator
|
||||
{
|
||||
|
||||
public function change(): void
|
||||
{
|
||||
$this->admin();
|
||||
$this->adminGroup();
|
||||
$this->adminGroupAccess();
|
||||
$this->adminLog();
|
||||
$this->area();
|
||||
$this->attachment();
|
||||
$this->captcha();
|
||||
$this->config();
|
||||
$this->menuRule();
|
||||
$this->securityDataRecycle();
|
||||
$this->securityDataRecycleLog();
|
||||
$this->securitySensitiveData();
|
||||
$this->securitySensitiveDataLog();
|
||||
$this->testBuild();
|
||||
$this->token();
|
||||
$this->user();
|
||||
$this->userGroup();
|
||||
$this->userMoneyLog();
|
||||
$this->userRule();
|
||||
$this->userScoreLog();
|
||||
$this->crudLog();
|
||||
}
|
||||
|
||||
public function admin(): void
|
||||
{
|
||||
if (!$this->hasTable('admin')) {
|
||||
$table = $this->table('admin', [
|
||||
'id' => false,
|
||||
'comment' => '管理员表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('username', 'string', ['limit' => 20, 'default' => '', 'comment' => '用户名', 'null' => false])
|
||||
->addColumn('nickname', 'string', ['limit' => 50, 'default' => '', 'comment' => '昵称', 'null' => false])
|
||||
->addColumn('avatar', 'string', ['limit' => 255, 'default' => '', 'comment' => '头像', 'null' => false])
|
||||
->addColumn('email', 'string', ['limit' => 50, 'default' => '', 'comment' => '邮箱', 'null' => false])
|
||||
->addColumn('mobile', 'string', ['limit' => 11, 'default' => '', 'comment' => '手机', 'null' => false])
|
||||
->addColumn('loginfailure', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '登录失败次数', 'null' => false])
|
||||
->addColumn('lastlogintime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '上次登录时间'])
|
||||
->addColumn('lastloginip', 'string', ['limit' => 50, 'default' => '', 'comment' => '上次登录IP', 'null' => false])
|
||||
->addColumn('password', 'string', ['limit' => 32, 'default' => '', 'comment' => '密码', 'null' => false])
|
||||
->addColumn('salt', 'string', ['limit' => 30, 'default' => '', 'comment' => '密码盐', 'null' => false])
|
||||
->addColumn('motto', 'string', ['limit' => 255, 'default' => '', 'comment' => '签名', 'null' => false])
|
||||
->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false])
|
||||
->addColumn('createtime', 'integer', ['limit' => 10, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->addColumn('updatetime', 'integer', ['limit' => 10, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->addIndex(['username'], [
|
||||
'unique' => true,
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function adminGroup(): void
|
||||
{
|
||||
if (!$this->hasTable('admin_group')) {
|
||||
$table = $this->table('admin_group', [
|
||||
'id' => false,
|
||||
'comment' => '管理分组表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('pid', 'integer', ['comment' => '上级分组', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'comment' => '组名', 'null' => false])
|
||||
->addColumn('rules', 'text', ['null' => true, 'default' => null, 'comment' => '权限规则ID'])
|
||||
->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false])
|
||||
->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function adminGroupAccess(): void
|
||||
{
|
||||
if (!$this->hasTable('admin_group_access')) {
|
||||
$table = $this->table('admin_group_access', [
|
||||
'id' => false,
|
||||
'comment' => '管理分组映射表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('uid', 'integer', ['comment' => '管理员ID', 'signed' => false, 'null' => false])
|
||||
->addColumn('group_id', 'integer', ['comment' => '分组ID', 'signed' => false, 'null' => false])
|
||||
->addIndex(['uid'], [
|
||||
'type' => 'BTREE',
|
||||
])
|
||||
->addIndex(['group_id'], [
|
||||
'type' => 'BTREE',
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function adminLog(): void
|
||||
{
|
||||
if (!$this->hasTable('admin_log')) {
|
||||
$table = $this->table('admin_log', [
|
||||
'id' => false,
|
||||
'comment' => '管理员日志表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('admin_id', 'integer', ['comment' => '管理员ID', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('username', 'string', ['limit' => 20, 'default' => '', 'comment' => '管理员用户名', 'null' => false])
|
||||
->addColumn('url', 'string', ['limit' => 1500, 'default' => '', 'comment' => '操作Url', 'null' => false])
|
||||
->addColumn('title', 'string', ['limit' => 100, 'default' => '', 'comment' => '日志标题', 'null' => false])
|
||||
->addColumn('data', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'default' => null, 'comment' => '请求数据'])
|
||||
->addColumn('ip', 'string', ['limit' => 50, 'default' => '', 'comment' => 'IP', 'null' => false])
|
||||
->addColumn('useragent', 'string', ['limit' => 255, 'default' => '', 'comment' => 'User-Agent', 'null' => false])
|
||||
->addColumn('createtime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function area(): void
|
||||
{
|
||||
if (!$this->hasTable('area')) {
|
||||
$table = $this->table('area', [
|
||||
'id' => false,
|
||||
'comment' => '省份地区表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('pid', 'integer', ['comment' => '父id', 'null' => true, 'default' => null, 'signed' => false])
|
||||
->addColumn('shortname', 'string', ['limit' => 100, 'null' => true, 'default' => null, 'comment' => '简称'])
|
||||
->addColumn('name', 'string', ['limit' => 100, 'null' => true, 'default' => null, 'comment' => '名称'])
|
||||
->addColumn('mergename', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '全称'])
|
||||
->addColumn('level', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => true, 'default' => null, 'comment' => '层级:1=省,2=市,3=区/县'])
|
||||
->addColumn('pinyin', 'string', ['limit' => 100, 'null' => true, 'default' => null, 'comment' => '拼音'])
|
||||
->addColumn('code', 'string', ['limit' => 100, 'null' => true, 'default' => null, 'comment' => '长途区号'])
|
||||
->addColumn('zip', 'string', ['limit' => 100, 'null' => true, 'default' => null, 'comment' => '邮编'])
|
||||
->addColumn('first', 'string', ['limit' => 50, 'null' => true, 'default' => null, 'comment' => '首字母'])
|
||||
->addColumn('lng', 'string', ['limit' => 50, 'null' => true, 'default' => null, 'comment' => '经度'])
|
||||
->addColumn('lat', 'string', ['limit' => 50, 'null' => true, 'default' => null, 'comment' => '纬度'])
|
||||
->addIndex(['pid'], [
|
||||
'type' => 'BTREE',
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function attachment(): void
|
||||
{
|
||||
if (!$this->hasTable('attachment')) {
|
||||
$table = $this->table('attachment', [
|
||||
'id' => false,
|
||||
'comment' => '附件表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('topic', 'string', ['limit' => 20, 'default' => '', 'comment' => '细目', 'null' => false])
|
||||
->addColumn('admin_id', 'integer', ['comment' => '上传管理员ID', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('user_id', 'integer', ['comment' => '上传用户ID', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('url', 'string', ['limit' => 255, 'default' => '', 'comment' => '物理路径', 'null' => false])
|
||||
->addColumn('width', 'integer', ['comment' => '宽度', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('height', 'integer', ['comment' => '高度', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'comment' => '原始名称', 'null' => false])
|
||||
->addColumn('size', 'integer', ['comment' => '大小', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('mimetype', 'string', ['limit' => 100, 'default' => '', 'comment' => 'mime类型', 'null' => false])
|
||||
->addColumn('quote', 'integer', ['comment' => '上传(引用)次数', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('storage', 'string', ['limit' => 50, 'default' => '', 'comment' => '存储方式', 'null' => false])
|
||||
->addColumn('sha1', 'string', ['limit' => 40, 'default' => '', 'comment' => 'sha1编码', 'null' => false])
|
||||
->addColumn('createtime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->addColumn('lastuploadtime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '最后上传时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function captcha(): void
|
||||
{
|
||||
if (!$this->hasTable('captcha')) {
|
||||
$table = $this->table('captcha', [
|
||||
'id' => false,
|
||||
'comment' => '验证码表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'key',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('key', 'string', ['limit' => 32, 'default' => '', 'comment' => '验证码Key', 'null' => false])
|
||||
->addColumn('code', 'string', ['limit' => 32, 'default' => '', 'comment' => '验证码(加密后)', 'null' => false])
|
||||
->addColumn('captcha', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'default' => null, 'comment' => '验证码数据'])
|
||||
->addColumn('createtime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->addColumn('expiretime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '过期时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function config(): void
|
||||
{
|
||||
if (!$this->hasTable('config')) {
|
||||
$table = $this->table('config', [
|
||||
'id' => false,
|
||||
'comment' => '系统配置',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('name', 'string', ['limit' => 30, 'default' => '', 'comment' => '变量名', 'null' => false])
|
||||
->addColumn('group', 'string', ['limit' => 30, 'default' => '', 'comment' => '分组', 'null' => false])
|
||||
->addColumn('title', 'string', ['limit' => 50, 'default' => '', 'comment' => '变量标题', 'null' => false])
|
||||
->addColumn('tip', 'string', ['limit' => 100, 'default' => '', 'comment' => '变量描述', 'null' => false])
|
||||
->addColumn('type', 'string', ['limit' => 30, 'default' => '', 'comment' => '变量输入组件类型', 'null' => false])
|
||||
->addColumn('value', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'default' => null, 'comment' => '变量值'])
|
||||
->addColumn('content', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'default' => null, 'comment' => '字典数据'])
|
||||
->addColumn('rule', 'string', ['limit' => 100, 'default' => '', 'comment' => '验证规则', 'null' => false])
|
||||
->addColumn('extend', 'string', ['limit' => 255, 'default' => '', 'comment' => '扩展属性', 'null' => false])
|
||||
->addColumn('allow_del', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '允许删除:0=否,1=是', 'null' => false])
|
||||
->addColumn('weigh', 'integer', ['comment' => '权重', 'default' => 0, 'null' => false])
|
||||
->addIndex(['name'], [
|
||||
'unique' => true,
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function menuRule(): void
|
||||
{
|
||||
if (!$this->hasTable('menu_rule') && !$this->hasTable('admin_rule')) {
|
||||
$table = $this->table('menu_rule', [
|
||||
'id' => false,
|
||||
'comment' => '菜单和权限规则表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('pid', 'integer', ['comment' => '上级菜单', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('type', 'enum', ['values' => 'menu_dir,menu,button', 'default' => 'menu', 'comment' => '类型:menu_dir=菜单目录,menu=菜单项,button=页面按钮', 'null' => false])
|
||||
->addColumn('title', 'string', ['limit' => 50, 'default' => '', 'comment' => '标题', 'null' => false])
|
||||
->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '规则名称', 'null' => false])
|
||||
->addColumn('path', 'string', ['limit' => 100, 'default' => '', 'comment' => '路由路径', 'null' => false])
|
||||
->addColumn('icon', 'string', ['limit' => 50, 'default' => '', 'comment' => '图标', 'null' => false])
|
||||
->addColumn('menu_type', 'enum', ['values' => 'tab,link,iframe', 'null' => true, 'default' => null, 'comment' => '菜单类型:tab=选项卡,link=链接,iframe=Iframe'])
|
||||
->addColumn('url', 'string', ['limit' => 255, 'default' => '', 'comment' => 'Url', 'null' => false])
|
||||
->addColumn('component', 'string', ['limit' => 100, 'default' => '', 'comment' => '组件路径', 'null' => false])
|
||||
->addColumn('keepalive', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '缓存:0=关闭,1=开启', 'null' => false])
|
||||
->addColumn('extend', 'enum', ['values' => 'none,add_rules_only,add_menu_only', 'default' => 'none', 'comment' => '扩展属性:none=无,add_rules_only=只添加为路由,add_menu_only=只添加为菜单', 'null' => false])
|
||||
->addColumn('remark', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注', 'null' => false])
|
||||
->addColumn('weigh', 'integer', ['comment' => '权重', 'default' => 0, 'null' => false])
|
||||
->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false])
|
||||
->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->addIndex(['pid'], [
|
||||
'type' => 'BTREE',
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function securityDataRecycle(): void
|
||||
{
|
||||
if (!$this->hasTable('security_data_recycle')) {
|
||||
$table = $this->table('security_data_recycle', [
|
||||
'id' => false,
|
||||
'comment' => '回收规则表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '规则名称', 'null' => false])
|
||||
->addColumn('controller', 'string', ['limit' => 100, 'default' => '', 'comment' => '控制器', 'null' => false])
|
||||
->addColumn('controller_as', 'string', ['limit' => 100, 'default' => '', 'comment' => '控制器别名', 'null' => false])
|
||||
->addColumn('data_table', 'string', ['limit' => 100, 'default' => '', 'comment' => '对应数据表', 'null' => false])
|
||||
->addColumn('primary_key', 'string', ['limit' => 50, 'default' => '', 'comment' => '数据表主键', 'null' => false])
|
||||
->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false])
|
||||
->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function securityDataRecycleLog(): void
|
||||
{
|
||||
if (!$this->hasTable('security_data_recycle_log')) {
|
||||
$table = $this->table('security_data_recycle_log', [
|
||||
'id' => false,
|
||||
'comment' => '数据回收记录表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('admin_id', 'integer', ['comment' => '操作管理员', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('recycle_id', 'integer', ['comment' => '回收规则ID', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('data', 'text', ['null' => true, 'default' => null, 'comment' => '回收的数据'])
|
||||
->addColumn('data_table', 'string', ['limit' => 100, 'default' => '', 'comment' => '数据表', 'null' => false])
|
||||
->addColumn('primary_key', 'string', ['limit' => 50, 'default' => '', 'comment' => '数据表主键', 'null' => false])
|
||||
->addColumn('is_restore', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '是否已还原:0=否,1=是', 'null' => false])
|
||||
->addColumn('ip', 'string', ['limit' => 50, 'default' => '', 'comment' => '操作者IP', 'null' => false])
|
||||
->addColumn('useragent', 'string', ['limit' => 255, 'default' => '', 'comment' => 'User-Agent', 'null' => false])
|
||||
->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function securitySensitiveData(): void
|
||||
{
|
||||
if (!$this->hasTable('security_sensitive_data')) {
|
||||
$table = $this->table('security_sensitive_data', [
|
||||
'id' => false,
|
||||
'comment' => '敏感数据规则表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '规则名称', 'null' => false])
|
||||
->addColumn('controller', 'string', ['limit' => 100, 'default' => '', 'comment' => '控制器', 'null' => false])
|
||||
->addColumn('controller_as', 'string', ['limit' => 100, 'default' => '', 'comment' => '控制器别名', 'null' => false])
|
||||
->addColumn('data_table', 'string', ['limit' => 100, 'default' => '', 'comment' => '对应数据表', 'null' => false])
|
||||
->addColumn('primary_key', 'string', ['limit' => 50, 'default' => '', 'comment' => '数据表主键', 'null' => false])
|
||||
->addColumn('data_fields', 'text', ['null' => true, 'default' => null, 'comment' => '敏感数据字段'])
|
||||
->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false])
|
||||
->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function securitySensitiveDataLog(): void
|
||||
{
|
||||
if (!$this->hasTable('security_sensitive_data_log')) {
|
||||
$table = $this->table('security_sensitive_data_log', [
|
||||
'id' => false,
|
||||
'comment' => '敏感数据修改记录',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('admin_id', 'integer', ['comment' => '操作管理员', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('sensitive_id', 'integer', ['comment' => '敏感数据规则ID', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('data_table', 'string', ['limit' => 100, 'default' => '', 'comment' => '数据表', 'null' => false])
|
||||
->addColumn('primary_key', 'string', ['limit' => 50, 'default' => '', 'comment' => '数据表主键', 'null' => false])
|
||||
->addColumn('data_field', 'string', ['limit' => 50, 'default' => '', 'comment' => '被修改字段', 'null' => false])
|
||||
->addColumn('data_comment', 'string', ['limit' => 50, 'default' => '', 'comment' => '被修改项', 'null' => false])
|
||||
->addColumn('id_value', 'integer', ['comment' => '被修改项主键值', 'default' => 0, 'null' => false])
|
||||
->addColumn('before', 'text', ['null' => true, 'default' => null, 'comment' => '修改前'])
|
||||
->addColumn('after', 'text', ['null' => true, 'default' => null, 'comment' => '修改后'])
|
||||
->addColumn('ip', 'string', ['limit' => 50, 'default' => '', 'comment' => '操作者IP', 'null' => false])
|
||||
->addColumn('useragent', 'string', ['limit' => 255, 'default' => '', 'comment' => 'User-Agent', 'null' => false])
|
||||
->addColumn('is_rollback', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '是否已回滚:0=否,1=是', 'null' => false])
|
||||
->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function testBuild(): void
|
||||
{
|
||||
if (!$this->hasTable('test_build')) {
|
||||
$table = $this->table('test_build', [
|
||||
'id' => false,
|
||||
'comment' => '知识库表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('title', 'string', ['limit' => 100, 'default' => '', 'comment' => '标题', 'null' => false])
|
||||
->addColumn('keyword_rows', 'string', ['limit' => 100, 'default' => '', 'comment' => '关键词', 'null' => false])
|
||||
->addColumn('content', 'text', ['null' => true, 'default' => null, 'comment' => '内容'])
|
||||
->addColumn('views', 'integer', ['comment' => '浏览量', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('likes', 'integer', ['comment' => '有帮助数', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('dislikes', 'integer', ['comment' => '无帮助数', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('note_textarea', 'string', ['limit' => 100, 'default' => '', 'comment' => '备注', 'null' => false])
|
||||
->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=隐藏,1=正常', 'null' => false])
|
||||
->addColumn('weigh', 'integer', ['comment' => '权重', 'default' => 0, 'null' => false])
|
||||
->addColumn('update_time', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->addColumn('create_time', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function token(): void
|
||||
{
|
||||
if (!$this->hasTable('token')) {
|
||||
$table = $this->table('token', [
|
||||
'id' => false,
|
||||
'comment' => '用户Token表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'token',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('token', 'string', ['limit' => 50, 'default' => '', 'comment' => 'Token', 'null' => false])
|
||||
->addColumn('type', 'string', ['limit' => 15, 'default' => '', 'comment' => '类型', 'null' => false])
|
||||
->addColumn('user_id', 'integer', ['comment' => '用户ID', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->addColumn('expiretime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '过期时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function user(): void
|
||||
{
|
||||
if (!$this->hasTable('user')) {
|
||||
$table = $this->table('user', [
|
||||
'id' => false,
|
||||
'comment' => '会员表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('group_id', 'integer', ['comment' => '分组ID', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('username', 'string', ['limit' => 32, 'default' => '', 'comment' => '用户名', 'null' => false])
|
||||
->addColumn('nickname', 'string', ['limit' => 50, 'default' => '', 'comment' => '昵称', 'null' => false])
|
||||
->addColumn('email', 'string', ['limit' => 50, 'default' => '', 'comment' => '邮箱', 'null' => false])
|
||||
->addColumn('mobile', 'string', ['limit' => 11, 'default' => '', 'comment' => '手机', 'null' => false])
|
||||
->addColumn('avatar', 'string', ['limit' => 255, 'default' => '', 'comment' => '头像', 'null' => false])
|
||||
->addColumn('gender', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '性别:0=未知,1=男,2=女', 'null' => false])
|
||||
->addColumn('birthday', 'date', ['null' => true, 'default' => null, 'comment' => '生日'])
|
||||
->addColumn('money', 'integer', ['comment' => '余额', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('score', 'integer', ['comment' => '积分', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('lastlogintime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '上次登录时间'])
|
||||
->addColumn('lastloginip', 'string', ['limit' => 50, 'default' => '', 'comment' => '上次登录IP', 'null' => false])
|
||||
->addColumn('loginfailure', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '登录失败次数', 'null' => false])
|
||||
->addColumn('joinip', 'string', ['limit' => 50, 'default' => '', 'comment' => '加入IP', 'null' => false])
|
||||
->addColumn('jointime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '加入时间'])
|
||||
->addColumn('motto', 'string', ['limit' => 255, 'default' => '', 'comment' => '签名', 'null' => false])
|
||||
->addColumn('password', 'string', ['limit' => 32, 'default' => '', 'comment' => '密码', 'null' => false])
|
||||
->addColumn('salt', 'string', ['limit' => 30, 'default' => '', 'comment' => '密码盐', 'null' => false])
|
||||
->addColumn('status', 'string', ['limit' => 30, 'default' => '', 'comment' => '状态', 'null' => false])
|
||||
->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->addIndex(['username'], [
|
||||
'unique' => true,
|
||||
])
|
||||
->addIndex(['email'], [
|
||||
'unique' => true,
|
||||
])
|
||||
->addIndex(['mobile'], [
|
||||
'unique' => true,
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function userGroup(): void
|
||||
{
|
||||
if (!$this->hasTable('user_group')) {
|
||||
$table = $this->table('user_group', [
|
||||
'id' => false,
|
||||
'comment' => '会员组表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '组名', 'null' => false])
|
||||
->addColumn('rules', 'text', ['null' => true, 'default' => null, 'comment' => '权限节点'])
|
||||
->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false])
|
||||
->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function userMoneyLog(): void
|
||||
{
|
||||
if (!$this->hasTable('user_money_log')) {
|
||||
$table = $this->table('user_money_log', [
|
||||
'id' => false,
|
||||
'comment' => '会员余额变动表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('user_id', 'integer', ['comment' => '会员ID', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('money', 'integer', ['comment' => '变更余额', 'default' => 0, 'null' => false])
|
||||
->addColumn('before', 'integer', ['comment' => '变更前余额', 'default' => 0, 'null' => false])
|
||||
->addColumn('after', 'integer', ['comment' => '变更后余额', 'default' => 0, 'null' => false])
|
||||
->addColumn('memo', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注', 'null' => false])
|
||||
->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function userRule(): void
|
||||
{
|
||||
if (!$this->hasTable('user_rule')) {
|
||||
$table = $this->table('user_rule', [
|
||||
'id' => false,
|
||||
'comment' => '会员菜单权限规则表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('pid', 'integer', ['comment' => '上级菜单', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('type', 'enum', ['values' => 'route,menu_dir,menu,nav_user_menu,nav,button', 'default' => 'menu', 'comment' => '类型:route=路由,menu_dir=菜单目录,menu=菜单项,nav_user_menu=顶栏会员菜单下拉项,nav=顶栏菜单项,button=页面按钮', 'null' => false])
|
||||
->addColumn('title', 'string', ['limit' => 50, 'default' => '', 'comment' => '标题', 'null' => false])
|
||||
->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '规则名称', 'null' => false])
|
||||
->addColumn('path', 'string', ['limit' => 100, 'default' => '', 'comment' => '路由路径', 'null' => false])
|
||||
->addColumn('icon', 'string', ['limit' => 50, 'default' => '', 'comment' => '图标', 'null' => false])
|
||||
->addColumn('menu_type', 'enum', ['values' => 'tab,link,iframe', 'default' => 'tab', 'comment' => '菜单类型:tab=选项卡,link=链接,iframe=Iframe', 'null' => false])
|
||||
->addColumn('url', 'string', ['limit' => 255, 'default' => '', 'comment' => 'Url', 'null' => false])
|
||||
->addColumn('component', 'string', ['limit' => 100, 'default' => '', 'comment' => '组件路径', 'null' => false])
|
||||
->addColumn('no_login_valid', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '未登录有效:0=否,1=是', 'null' => false])
|
||||
->addColumn('extend', 'enum', ['values' => 'none,add_rules_only,add_menu_only', 'default' => 'none', 'comment' => '扩展属性:none=无,add_rules_only=只添加为路由,add_menu_only=只添加为菜单', 'null' => false])
|
||||
->addColumn('remark', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注', 'null' => false])
|
||||
->addColumn('weigh', 'integer', ['comment' => '权重', 'default' => 0, 'null' => false])
|
||||
->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false])
|
||||
->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->addIndex(['pid'], [
|
||||
'type' => 'BTREE',
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function userScoreLog(): void
|
||||
{
|
||||
if (!$this->hasTable('user_score_log')) {
|
||||
$table = $this->table('user_score_log', [
|
||||
'id' => false,
|
||||
'comment' => '会员积分变动表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('user_id', 'integer', ['comment' => '会员ID', 'default' => 0, 'signed' => false, 'null' => false])
|
||||
->addColumn('score', 'integer', ['comment' => '变更积分', 'default' => 0, 'null' => false])
|
||||
->addColumn('before', 'integer', ['comment' => '变更前积分', 'default' => 0, 'null' => false])
|
||||
->addColumn('after', 'integer', ['comment' => '变更后积分', 'default' => 0, 'null' => false])
|
||||
->addColumn('memo', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注', 'null' => false])
|
||||
->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function crudLog(): void
|
||||
{
|
||||
if (!$this->hasTable('crud_log')) {
|
||||
$table = $this->table('crud_log', [
|
||||
'id' => false,
|
||||
'comment' => 'CRUD记录表',
|
||||
'row_format' => 'DYNAMIC',
|
||||
'primary_key' => 'id',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
$table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
|
||||
->addColumn('table_name', 'string', ['limit' => 200, 'default' => '', 'comment' => '数据表名', 'null' => false])
|
||||
->addColumn('table', 'text', ['null' => true, 'default' => null, 'comment' => '数据表数据'])
|
||||
->addColumn('fields', 'text', ['null' => true, 'default' => null, 'comment' => '字段数据'])
|
||||
->addColumn('status', 'enum', ['values' => 'delete,success,error,start', 'default' => 'start', 'comment' => '状态:delete=已删除,success=成功,error=失败,start=生成中', 'null' => false])
|
||||
->addColumn('create_time', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
}
|
||||
1418
database/migrations/20230620180916_install_data.php
Normal file
1418
database/migrations/20230620180916_install_data.php
Normal file
@@ -0,0 +1,1418 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\facade\Db;
|
||||
|
||||
class InstallData extends Migrator
|
||||
{
|
||||
public string $nowTime = '';
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
$this->nowTime = time();
|
||||
$this->admin();
|
||||
$this->adminGroup();
|
||||
$this->adminGroupAccess();
|
||||
$this->config();
|
||||
$this->menuRule();
|
||||
$this->securityDataRecycle();
|
||||
$this->securitySensitiveData();
|
||||
$this->user();
|
||||
$this->userGroup();
|
||||
$this->userRule();
|
||||
}
|
||||
|
||||
public function admin(): void
|
||||
{
|
||||
$table = $this->table('admin');
|
||||
$rows = [
|
||||
[
|
||||
'id' => 1,
|
||||
'username' => 'admin',
|
||||
'nickname' => 'Admin',
|
||||
'email' => 'admin@buildadmin.com',
|
||||
'mobile' => '18888888888',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
]
|
||||
];
|
||||
$exist = Db::name('admin')->where('id', 1)->value('id');
|
||||
if (!$exist) {
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public function adminGroup(): void
|
||||
{
|
||||
$table = $this->table('admin_group');
|
||||
$rows = [
|
||||
[
|
||||
'id' => 1,
|
||||
'pid' => 0,
|
||||
'name' => '超级管理组',
|
||||
'rules' => '*',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'pid' => 1,
|
||||
'name' => '一级管理员',
|
||||
'rules' => '1,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,77,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'pid' => 2,
|
||||
'name' => '二级管理员',
|
||||
'rules' => '21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'pid' => 3,
|
||||
'name' => '三级管理员',
|
||||
'rules' => '55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
];
|
||||
$exist = Db::name('admin_group')->where('id', 1)->value('id');
|
||||
if (!$exist) {
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public function adminGroupAccess(): void
|
||||
{
|
||||
$table = $this->table('admin_group_access');
|
||||
$rows = [
|
||||
[
|
||||
'uid' => 1,
|
||||
'group_id' => 1,
|
||||
]
|
||||
];
|
||||
$exist = Db::name('admin_group_access')->where('uid', 1)->value('uid');
|
||||
if (!$exist) {
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public function config(): void
|
||||
{
|
||||
$table = $this->table('config');
|
||||
$rows = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'config_group',
|
||||
'group' => 'basics',
|
||||
'title' => 'Config group',
|
||||
'type' => 'array',
|
||||
'value' => '[{"key":"basics","value":"Basics"},{"key":"mail","value":"Mail"},{"key":"config_quick_entrance","value":"Config Quick entrance"}]',
|
||||
'rule' => 'required',
|
||||
'weigh' => -1,
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'site_name',
|
||||
'group' => 'basics',
|
||||
'title' => 'Site Name',
|
||||
'tip' => '',
|
||||
'type' => 'string',
|
||||
'value' => '站点名称',
|
||||
'rule' => 'required',
|
||||
'weigh' => 99,
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => 'record_number',
|
||||
'group' => 'basics',
|
||||
'title' => 'Record number',
|
||||
'tip' => '域名备案号',
|
||||
'type' => 'string',
|
||||
'value' => '渝ICP备8888888号-1',
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'name' => 'version',
|
||||
'group' => 'basics',
|
||||
'title' => 'Version number',
|
||||
'tip' => '系统版本号',
|
||||
'type' => 'string',
|
||||
'value' => 'v1.0.0',
|
||||
'rule' => 'required',
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'name' => 'time_zone',
|
||||
'group' => 'basics',
|
||||
'title' => 'time zone',
|
||||
'type' => 'string',
|
||||
'value' => 'Asia/Shanghai',
|
||||
'rule' => 'required',
|
||||
],
|
||||
[
|
||||
'id' => 6,
|
||||
'name' => 'no_access_ip',
|
||||
'group' => 'basics',
|
||||
'title' => 'No access ip',
|
||||
'tip' => '禁止访问站点的ip列表,一行一个',
|
||||
'type' => 'textarea',
|
||||
],
|
||||
[
|
||||
'id' => 7,
|
||||
'name' => 'smtp_server',
|
||||
'group' => 'mail',
|
||||
'title' => 'smtp server',
|
||||
'type' => 'string',
|
||||
'value' => 'smtp.qq.com',
|
||||
'weigh' => 9,
|
||||
],
|
||||
[
|
||||
'id' => 8,
|
||||
'name' => 'smtp_port',
|
||||
'group' => 'mail',
|
||||
'title' => 'smtp port',
|
||||
'type' => 'string',
|
||||
'value' => '465',
|
||||
'weigh' => 8,
|
||||
],
|
||||
[
|
||||
'id' => 9,
|
||||
'name' => 'smtp_user',
|
||||
'group' => 'mail',
|
||||
'title' => 'smtp user',
|
||||
'type' => 'string',
|
||||
'weigh' => 7,
|
||||
],
|
||||
[
|
||||
'id' => 10,
|
||||
'name' => 'smtp_pass',
|
||||
'group' => 'mail',
|
||||
'title' => 'smtp pass',
|
||||
'type' => 'string',
|
||||
'weigh' => 6,
|
||||
],
|
||||
[
|
||||
'id' => 11,
|
||||
'name' => 'smtp_verification',
|
||||
'group' => 'mail',
|
||||
'title' => 'smtp verification',
|
||||
'type' => 'select',
|
||||
'value' => 'SSL',
|
||||
'content' => '{"SSL":"SSL","TLS":"TLS"}',
|
||||
'weigh' => 5,
|
||||
],
|
||||
[
|
||||
'id' => 12,
|
||||
'name' => 'smtp_sender_mail',
|
||||
'group' => 'mail',
|
||||
'title' => 'smtp sender mail',
|
||||
'type' => 'string',
|
||||
'rule' => 'email',
|
||||
'weigh' => 4,
|
||||
],
|
||||
[
|
||||
'id' => 13,
|
||||
'name' => 'config_quick_entrance',
|
||||
'group' => 'config_quick_entrance',
|
||||
'title' => 'Config Quick entrance',
|
||||
'type' => 'array',
|
||||
'value' => '[{"key":"数据回收规则配置","value":"/admin/security/dataRecycle"},{"key":"敏感数据规则配置","value":"/admin/security/sensitiveData"}]',
|
||||
],
|
||||
];
|
||||
$exist = Db::name('config')->where('id', 1)->value('id');
|
||||
if (!$exist) {
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public function menuRule(): void
|
||||
{
|
||||
if (!$this->hasTable('menu_rule')) return;
|
||||
$table = $this->table('menu_rule');
|
||||
$rows = [
|
||||
[
|
||||
'id' => '1',
|
||||
'type' => 'menu',
|
||||
'title' => '控制台',
|
||||
'name' => 'dashboard/dashboard',
|
||||
'path' => 'dashboard',
|
||||
'icon' => 'fa fa-dashboard',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/dashboard.vue',
|
||||
'keepalive' => '1',
|
||||
'remark' => 'Remark lang',
|
||||
'weigh' => '999',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '2',
|
||||
'type' => 'menu_dir',
|
||||
'title' => '权限管理',
|
||||
'name' => 'auth',
|
||||
'path' => 'auth',
|
||||
'icon' => 'fa fa-group',
|
||||
'weigh' => '100',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '3',
|
||||
'pid' => '2',
|
||||
'type' => 'menu',
|
||||
'title' => '角色组管理',
|
||||
'name' => 'auth/group',
|
||||
'path' => 'auth/group',
|
||||
'icon' => 'fa fa-group',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/auth/group/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '99',
|
||||
'remark' => 'Remark lang',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '4',
|
||||
'pid' => '3',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'auth/group/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '5',
|
||||
'pid' => '3',
|
||||
'type' => 'button',
|
||||
'title' => '添加',
|
||||
'name' => 'auth/group/add',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '6',
|
||||
'pid' => '3',
|
||||
'type' => 'button',
|
||||
'title' => '编辑',
|
||||
'name' => 'auth/group/edit',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '7',
|
||||
'pid' => '3',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'auth/group/del',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '8',
|
||||
'pid' => '2',
|
||||
'type' => 'menu',
|
||||
'title' => '管理员管理',
|
||||
'name' => 'auth/admin',
|
||||
'path' => 'auth/admin',
|
||||
'icon' => 'el-icon-UserFilled',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/auth/admin/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '98',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '9',
|
||||
'pid' => '8',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'auth/admin/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '10',
|
||||
'pid' => '8',
|
||||
'type' => 'button',
|
||||
'title' => '添加',
|
||||
'name' => 'auth/admin/add',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '11',
|
||||
'pid' => '8',
|
||||
'type' => 'button',
|
||||
'title' => '编辑',
|
||||
'name' => 'auth/admin/edit',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '12',
|
||||
'pid' => '8',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'auth/admin/del',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '13',
|
||||
'pid' => '2',
|
||||
'type' => 'menu',
|
||||
'title' => '菜单规则管理',
|
||||
'name' => 'auth/menu',
|
||||
'path' => 'auth/menu',
|
||||
'icon' => 'el-icon-Grid',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/auth/menu/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '97',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '14',
|
||||
'pid' => '13',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'auth/menu/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '15',
|
||||
'pid' => '13',
|
||||
'type' => 'button',
|
||||
'title' => '添加',
|
||||
'name' => 'auth/menu/add',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '16',
|
||||
'pid' => '13',
|
||||
'type' => 'button',
|
||||
'title' => '编辑',
|
||||
'name' => 'auth/menu/edit',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '17',
|
||||
'pid' => '13',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'auth/menu/del',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '18',
|
||||
'pid' => '13',
|
||||
'type' => 'button',
|
||||
'title' => '快速排序',
|
||||
'name' => 'auth/menu/sortable',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '19',
|
||||
'pid' => '2',
|
||||
'type' => 'menu',
|
||||
'title' => '管理员日志管理',
|
||||
'name' => 'auth/adminLog',
|
||||
'path' => 'auth/adminLog',
|
||||
'icon' => 'el-icon-List',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/auth/adminLog/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '96',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '20',
|
||||
'pid' => '19',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'auth/adminLog/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '21',
|
||||
'type' => 'menu_dir',
|
||||
'title' => '会员管理',
|
||||
'name' => 'user',
|
||||
'path' => 'user',
|
||||
'icon' => 'fa fa-drivers-license',
|
||||
'weigh' => '95',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '22',
|
||||
'pid' => '21',
|
||||
'type' => 'menu',
|
||||
'title' => '会员管理',
|
||||
'name' => 'user/user',
|
||||
'path' => 'user/user',
|
||||
'icon' => 'fa fa-user',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/user/user/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '94',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '23',
|
||||
'pid' => '22',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'user/user/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '24',
|
||||
'pid' => '22',
|
||||
'type' => 'button',
|
||||
'title' => '添加',
|
||||
'name' => 'user/user/add',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '25',
|
||||
'pid' => '22',
|
||||
'type' => 'button',
|
||||
'title' => '编辑',
|
||||
'name' => 'user/user/edit',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '26',
|
||||
'pid' => '22',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'user/user/del',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '27',
|
||||
'pid' => '21',
|
||||
'type' => 'menu',
|
||||
'title' => '会员分组管理',
|
||||
'name' => 'user/group',
|
||||
'path' => 'user/group',
|
||||
'icon' => 'fa fa-group',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/user/group/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '93',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '28',
|
||||
'pid' => '27',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'user/group/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '29',
|
||||
'pid' => '27',
|
||||
'type' => 'button',
|
||||
'title' => '添加',
|
||||
'name' => 'user/group/add',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '30',
|
||||
'pid' => '27',
|
||||
'type' => 'button',
|
||||
'title' => '编辑',
|
||||
'name' => 'user/group/edit',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '31',
|
||||
'pid' => '27',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'user/group/del',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '32',
|
||||
'pid' => '21',
|
||||
'type' => 'menu',
|
||||
'title' => '会员规则管理',
|
||||
'name' => 'user/rule',
|
||||
'path' => 'user/rule',
|
||||
'icon' => 'fa fa-th-list',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/user/rule/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '92',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '33',
|
||||
'pid' => '32',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'user/rule/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '34',
|
||||
'pid' => '32',
|
||||
'type' => 'button',
|
||||
'title' => '添加',
|
||||
'name' => 'user/rule/add',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '35',
|
||||
'pid' => '32',
|
||||
'type' => 'button',
|
||||
'title' => '编辑',
|
||||
'name' => 'user/rule/edit',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '36',
|
||||
'pid' => '32',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'user/rule/del',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '37',
|
||||
'pid' => '32',
|
||||
'type' => 'button',
|
||||
'title' => '快速排序',
|
||||
'name' => 'user/rule/sortable',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '38',
|
||||
'pid' => '21',
|
||||
'type' => 'menu',
|
||||
'title' => '会员余额管理',
|
||||
'name' => 'user/moneyLog',
|
||||
'path' => 'user/moneyLog',
|
||||
'icon' => 'el-icon-Money',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/user/moneyLog/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '91',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '39',
|
||||
'pid' => '38',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'user/moneyLog/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '40',
|
||||
'pid' => '38',
|
||||
'type' => 'button',
|
||||
'title' => '添加',
|
||||
'name' => 'user/moneyLog/add',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '41',
|
||||
'pid' => '21',
|
||||
'type' => 'menu',
|
||||
'title' => '会员积分管理',
|
||||
'name' => 'user/scoreLog',
|
||||
'path' => 'user/scoreLog',
|
||||
'icon' => 'el-icon-Discount',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/user/scoreLog/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '90',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '42',
|
||||
'pid' => '41',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'user/scoreLog/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '43',
|
||||
'pid' => '41',
|
||||
'type' => 'button',
|
||||
'title' => '添加',
|
||||
'name' => 'user/scoreLog/add',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '44',
|
||||
'type' => 'menu_dir',
|
||||
'title' => '常规管理',
|
||||
'name' => 'routine',
|
||||
'path' => 'routine',
|
||||
'icon' => 'fa fa-cogs',
|
||||
'weigh' => '89',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '45',
|
||||
'pid' => '44',
|
||||
'type' => 'menu',
|
||||
'title' => '系统配置',
|
||||
'name' => 'routine/config',
|
||||
'path' => 'routine/config',
|
||||
'icon' => 'el-icon-Tools',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/routine/config/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '88',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '46',
|
||||
'pid' => '45',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'routine/config/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '47',
|
||||
'pid' => '45',
|
||||
'type' => 'button',
|
||||
'title' => '编辑',
|
||||
'name' => 'routine/config/edit',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '48',
|
||||
'pid' => '44',
|
||||
'type' => 'menu',
|
||||
'title' => '附件管理',
|
||||
'name' => 'routine/attachment',
|
||||
'path' => 'routine/attachment',
|
||||
'icon' => 'fa fa-folder',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/routine/attachment/index.vue',
|
||||
'keepalive' => '1',
|
||||
'remark' => 'Remark lang',
|
||||
'weigh' => '87',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '49',
|
||||
'pid' => '48',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'routine/attachment/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '50',
|
||||
'pid' => '48',
|
||||
'type' => 'button',
|
||||
'title' => '编辑',
|
||||
'name' => 'routine/attachment/edit',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '51',
|
||||
'pid' => '48',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'routine/attachment/del',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '52',
|
||||
'pid' => '44',
|
||||
'type' => 'menu',
|
||||
'title' => '个人资料',
|
||||
'name' => 'routine/adminInfo',
|
||||
'path' => 'routine/adminInfo',
|
||||
'icon' => 'fa fa-user',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/routine/adminInfo.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '86',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '53',
|
||||
'pid' => '52',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'routine/adminInfo/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '54',
|
||||
'pid' => '52',
|
||||
'type' => 'button',
|
||||
'title' => '编辑',
|
||||
'name' => 'routine/adminInfo/edit',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '55',
|
||||
'type' => 'menu_dir',
|
||||
'title' => '数据安全管理',
|
||||
'name' => 'security',
|
||||
'path' => 'security',
|
||||
'icon' => 'fa fa-shield',
|
||||
'weigh' => '85',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '56',
|
||||
'pid' => '55',
|
||||
'type' => 'menu',
|
||||
'title' => '数据回收站',
|
||||
'name' => 'security/dataRecycleLog',
|
||||
'path' => 'security/dataRecycleLog',
|
||||
'icon' => 'fa fa-database',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/security/dataRecycleLog/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '84',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '57',
|
||||
'pid' => '56',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'security/dataRecycleLog/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '58',
|
||||
'pid' => '56',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'security/dataRecycleLog/del',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '59',
|
||||
'pid' => '56',
|
||||
'type' => 'button',
|
||||
'title' => '还原',
|
||||
'name' => 'security/dataRecycleLog/restore',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '60',
|
||||
'pid' => '56',
|
||||
'type' => 'button',
|
||||
'title' => '查看详情',
|
||||
'name' => 'security/dataRecycleLog/info',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '61',
|
||||
'pid' => '55',
|
||||
'type' => 'menu',
|
||||
'title' => '敏感数据修改记录',
|
||||
'name' => 'security/sensitiveDataLog',
|
||||
'path' => 'security/sensitiveDataLog',
|
||||
'icon' => 'fa fa-expeditedssl',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/security/sensitiveDataLog/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '83',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '62',
|
||||
'pid' => '61',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'security/sensitiveDataLog/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '63',
|
||||
'pid' => '61',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'security/sensitiveDataLog/del',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '64',
|
||||
'pid' => '61',
|
||||
'type' => 'button',
|
||||
'title' => '回滚',
|
||||
'name' => 'security/sensitiveDataLog/rollback',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '65',
|
||||
'pid' => '61',
|
||||
'type' => 'button',
|
||||
'title' => '查看详情',
|
||||
'name' => 'security/sensitiveDataLog/info',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '66',
|
||||
'pid' => '55',
|
||||
'type' => 'menu',
|
||||
'title' => '数据回收规则管理',
|
||||
'name' => 'security/dataRecycle',
|
||||
'path' => 'security/dataRecycle',
|
||||
'icon' => 'fa fa-database',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/security/dataRecycle/index.vue',
|
||||
'keepalive' => '1',
|
||||
'remark' => 'Remark lang',
|
||||
'weigh' => '82',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '67',
|
||||
'pid' => '66',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'security/dataRecycle/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '68',
|
||||
'pid' => '66',
|
||||
'type' => 'button',
|
||||
'title' => '添加',
|
||||
'name' => 'security/dataRecycle/add',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '69',
|
||||
'pid' => '66',
|
||||
'type' => 'button',
|
||||
'title' => '编辑',
|
||||
'name' => 'security/dataRecycle/edit',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '70',
|
||||
'pid' => '66',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'security/dataRecycle/del',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '71',
|
||||
'pid' => '55',
|
||||
'type' => 'menu',
|
||||
'title' => '敏感字段规则管理',
|
||||
'name' => 'security/sensitiveData',
|
||||
'path' => 'security/sensitiveData',
|
||||
'icon' => 'fa fa-expeditedssl',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/security/sensitiveData/index.vue',
|
||||
'keepalive' => '1',
|
||||
'remark' => 'Remark lang',
|
||||
'weigh' => '81',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '72',
|
||||
'pid' => '71',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'security/sensitiveData/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '73',
|
||||
'pid' => '71',
|
||||
'type' => 'button',
|
||||
'title' => '添加',
|
||||
'name' => 'security/sensitiveData/add',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '74',
|
||||
'pid' => '71',
|
||||
'type' => 'button',
|
||||
'title' => '编辑',
|
||||
'name' => 'security/sensitiveData/edit',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '75',
|
||||
'pid' => '71',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'security/sensitiveData/del',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '76',
|
||||
'type' => 'menu',
|
||||
'title' => 'BuildAdmin',
|
||||
'name' => 'buildadmin/buildadmin',
|
||||
'path' => 'buildadmin',
|
||||
'icon' => 'local-logo',
|
||||
'menu_type' => 'link',
|
||||
'url' => 'https://doc.buildadmin.com',
|
||||
'status' => '0',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '77',
|
||||
'pid' => '45',
|
||||
'type' => 'button',
|
||||
'title' => '添加',
|
||||
'name' => 'routine/config/add',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '78',
|
||||
'type' => 'menu',
|
||||
'title' => '模块市场',
|
||||
'name' => 'moduleStore/moduleStore',
|
||||
'path' => 'moduleStore',
|
||||
'icon' => 'el-icon-GoodsFilled',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/module/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '86',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '79',
|
||||
'pid' => '78',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'moduleStore/moduleStore/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '80',
|
||||
'pid' => '78',
|
||||
'type' => 'button',
|
||||
'title' => '安装',
|
||||
'name' => 'moduleStore/moduleStore/install',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '81',
|
||||
'pid' => '78',
|
||||
'type' => 'button',
|
||||
'title' => '调整状态',
|
||||
'name' => 'moduleStore/moduleStore/changeState',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '82',
|
||||
'pid' => '78',
|
||||
'type' => 'button',
|
||||
'title' => '卸载',
|
||||
'name' => 'moduleStore/moduleStore/uninstall',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '83',
|
||||
'pid' => '78',
|
||||
'type' => 'button',
|
||||
'title' => '更新',
|
||||
'name' => 'moduleStore/moduleStore/update',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '84',
|
||||
'type' => 'menu',
|
||||
'title' => 'CRUD代码生成',
|
||||
'name' => 'crud/crud',
|
||||
'path' => 'crud/crud',
|
||||
'icon' => 'fa fa-code',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/backend/crud/index.vue',
|
||||
'keepalive' => '1',
|
||||
'weigh' => '80',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '85',
|
||||
'pid' => '84',
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'crud/crud/index',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '86',
|
||||
'pid' => '84',
|
||||
'type' => 'button',
|
||||
'title' => '生成',
|
||||
'name' => 'crud/crud/generate',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '87',
|
||||
'pid' => '84',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'crud/crud/delete',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => '88',
|
||||
'pid' => '45',
|
||||
'type' => 'button',
|
||||
'title' => '删除',
|
||||
'name' => 'routine/config/del',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
];
|
||||
$exist = Db::name('menu_rule')->where('id', 1)->value('id');
|
||||
if (!$exist) {
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public function securityDataRecycle(): void
|
||||
{
|
||||
$table = $this->table('security_data_recycle');
|
||||
$rows = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => '管理员',
|
||||
'controller' => 'auth/Admin.php',
|
||||
'controller_as' => 'auth/admin',
|
||||
'data_table' => 'admin',
|
||||
'primary_key' => 'id',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => '管理员日志',
|
||||
'controller' => 'auth/AdminLog.php',
|
||||
'controller_as' => 'auth/adminlog',
|
||||
'data_table' => 'admin_log',
|
||||
'primary_key' => 'id',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => '菜单规则',
|
||||
'controller' => 'auth/Menu.php',
|
||||
'controller_as' => 'auth/menu',
|
||||
'data_table' => 'menu_rule',
|
||||
'primary_key' => 'id',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'name' => '系统配置项',
|
||||
'controller' => 'routine/Config.php',
|
||||
'controller_as' => 'routine/config',
|
||||
'data_table' => 'config',
|
||||
'primary_key' => 'id',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'name' => '会员',
|
||||
'controller' => 'user/User.php',
|
||||
'controller_as' => 'user/user',
|
||||
'data_table' => 'user',
|
||||
'primary_key' => 'id',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 6,
|
||||
'name' => '数据回收规则',
|
||||
'controller' => 'security/DataRecycle.php',
|
||||
'controller_as' => 'security/datarecycle',
|
||||
'data_table' => 'security_data_recycle',
|
||||
'primary_key' => 'id',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
];
|
||||
$exist = Db::name('security_data_recycle')->where('id', 1)->value('id');
|
||||
if (!$exist) {
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public function securitySensitiveData(): void
|
||||
{
|
||||
$table = $this->table('security_sensitive_data');
|
||||
$rows = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => '管理员数据',
|
||||
'controller' => 'auth/Admin.php',
|
||||
'controller_as' => 'auth/admin',
|
||||
'data_table' => 'admin',
|
||||
'primary_key' => 'id',
|
||||
'data_fields' => '{"username":"用户名","mobile":"手机","password":"密码","status":"状态"}',
|
||||
'status' => '1',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => '会员数据',
|
||||
'controller' => 'user/User.php',
|
||||
'controller_as' => 'user/user',
|
||||
'data_table' => 'user',
|
||||
'primary_key' => 'id',
|
||||
'data_fields' => '{"username":"用户名","mobile":"手机号","password":"密码","status":"状态","email":"邮箱地址"}',
|
||||
'status' => '1',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => '管理员权限',
|
||||
'controller' => 'auth/Group.php',
|
||||
'controller_as' => 'auth/group',
|
||||
'data_table' => 'admin_group',
|
||||
'primary_key' => 'id',
|
||||
'data_fields' => '{"rules":"权限规则ID"}',
|
||||
'status' => '1',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
];
|
||||
$exist = Db::name('security_sensitive_data')->where('id', 1)->value('id');
|
||||
if (!$exist) {
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public function user(): void
|
||||
{
|
||||
$table = $this->table('user');
|
||||
$rows = [
|
||||
[
|
||||
'id' => 1,
|
||||
'group_id' => 1,
|
||||
'username' => 'user',
|
||||
'nickname' => 'User',
|
||||
'email' => '18888888888@qq.com',
|
||||
'mobile' => '18888888888',
|
||||
'gender' => '2',
|
||||
'birthday' => date('Y-m-d'),
|
||||
'status' => 'enable',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
]
|
||||
];
|
||||
$exist = Db::name('user')->where('id', 1)->value('id');
|
||||
if (!$exist) {
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public function userGroup(): void
|
||||
{
|
||||
$table = $this->table('user_group');
|
||||
$rows = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => '默认分组',
|
||||
'rules' => '*',
|
||||
'status' => '1',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
]
|
||||
];
|
||||
$exist = Db::name('user_group')->where('id', 1)->value('id');
|
||||
if (!$exist) {
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public function userRule(): void
|
||||
{
|
||||
$table = $this->table('user_rule');
|
||||
$rows = [
|
||||
[
|
||||
'id' => 1,
|
||||
'pid' => 0,
|
||||
'type' => 'menu_dir',
|
||||
'title' => '我的账户',
|
||||
'name' => 'account',
|
||||
'path' => 'account',
|
||||
'icon' => 'fa fa-user-circle',
|
||||
'menu_type' => 'tab',
|
||||
'weigh' => '98',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'pid' => 1,
|
||||
'type' => 'menu',
|
||||
'title' => '账户概览',
|
||||
'name' => 'account/overview',
|
||||
'path' => 'account/overview',
|
||||
'icon' => 'fa fa-home',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/frontend/user/account/overview.vue',
|
||||
'weigh' => '99',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'pid' => 1,
|
||||
'type' => 'menu',
|
||||
'title' => '个人资料',
|
||||
'name' => 'account/profile',
|
||||
'path' => 'account/profile',
|
||||
'icon' => 'fa fa-user-circle-o',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/frontend/user/account/profile.vue',
|
||||
'weigh' => '98',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'pid' => 1,
|
||||
'type' => 'menu',
|
||||
'title' => '修改密码',
|
||||
'name' => 'account/changePassword',
|
||||
'path' => 'account/changePassword',
|
||||
'icon' => 'fa fa-shield',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/frontend/user/account/changePassword.vue',
|
||||
'weigh' => '97',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'pid' => 1,
|
||||
'type' => 'menu',
|
||||
'title' => '积分记录',
|
||||
'name' => 'account/integral',
|
||||
'path' => 'account/integral',
|
||||
'icon' => 'fa fa-tag',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/frontend/user/account/integral.vue',
|
||||
'weigh' => '96',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
[
|
||||
'id' => 6,
|
||||
'pid' => 1,
|
||||
'type' => 'menu',
|
||||
'title' => '余额记录',
|
||||
'name' => 'account/balance',
|
||||
'path' => 'account/balance',
|
||||
'icon' => 'fa fa-money',
|
||||
'menu_type' => 'tab',
|
||||
'component' => '/src/views/frontend/user/account/balance.vue',
|
||||
'weigh' => '95',
|
||||
'updatetime' => $this->nowTime,
|
||||
'createtime' => $this->nowTime,
|
||||
]
|
||||
];
|
||||
$exist = Db::name('user_rule')->where('id', 1)->value('id');
|
||||
if (!$exist) {
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
}
|
||||
}
|
||||
179
database/migrations/20230622221507_version200.php
Normal file
179
database/migrations/20230622221507_version200.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
use think\facade\Db;
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class Version200 extends Migrator
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$admin = $this->table('admin');
|
||||
if ($admin->hasColumn('loginfailure')) {
|
||||
// 字段改名
|
||||
$admin->renameColumn('loginfailure', 'login_failure')
|
||||
->renameColumn('lastlogintime', 'last_login_time')
|
||||
->renameColumn('lastloginip', 'last_login_ip')
|
||||
->renameColumn('updatetime', 'update_time')
|
||||
->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->changeColumn('create_time', 'biginteger', ['after' => 'update_time', 'limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->save();
|
||||
}
|
||||
|
||||
$adminGroup = $this->table('admin_group');
|
||||
if ($adminGroup->hasColumn('updatetime')) {
|
||||
$adminGroup->renameColumn('updatetime', 'update_time')
|
||||
->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->save();
|
||||
}
|
||||
|
||||
$adminLog = $this->table('admin_log');
|
||||
if ($adminLog->hasColumn('createtime')) {
|
||||
$adminLog->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->changeColumn('data', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'default' => null, 'comment' => '请求数据'])
|
||||
->save();
|
||||
}
|
||||
|
||||
$attachment = $this->table('attachment');
|
||||
if ($attachment->hasColumn('createtime')) {
|
||||
$attachment->renameColumn('createtime', 'create_time')
|
||||
->renameColumn('lastuploadtime', 'last_upload_time')
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->changeColumn('last_upload_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '最后上传时间'])
|
||||
->save();
|
||||
}
|
||||
|
||||
$captcha = $this->table('captcha');
|
||||
if ($captcha->hasColumn('createtime')) {
|
||||
$captcha->renameColumn('createtime', 'create_time')
|
||||
->renameColumn('expiretime', 'expire_time')
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->changeColumn('expire_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '过期时间'])
|
||||
->changeColumn('captcha', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR, 'null' => true, 'default' => null, 'comment' => '验证码数据'])
|
||||
->save();
|
||||
}
|
||||
|
||||
if ($this->hasTable('menu_rule')) {
|
||||
$menuRule = $this->table('menu_rule');
|
||||
if ($menuRule->hasColumn('updatetime') && $this->hasTable('menu_rule')) {
|
||||
$menuRule->renameColumn('updatetime', 'update_time')
|
||||
->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->save();
|
||||
$menuRule->rename('admin_rule')->save();
|
||||
Db::name('admin_rule')
|
||||
->where('name', 'auth/menu')
|
||||
->update([
|
||||
'name' => 'auth/rule',
|
||||
'path' => 'auth/rule',
|
||||
'component' => '/src/views/backend/auth/rule/index.vue',
|
||||
]);
|
||||
Db::name('admin_rule')->where('name', 'auth/menu/index')->update(['name' => 'auth/rule/index']);
|
||||
Db::name('admin_rule')->where('name', 'auth/menu/add')->update(['name' => 'auth/rule/add']);
|
||||
Db::name('admin_rule')->where('name', 'auth/menu/edit')->update(['name' => 'auth/rule/edit']);
|
||||
Db::name('admin_rule')->where('name', 'auth/menu/del')->update(['name' => 'auth/rule/del']);
|
||||
Db::name('admin_rule')->where('name', 'auth/menu/sortable')->update(['name' => 'auth/rule/sortable']);
|
||||
Db::name('admin_rule')->whereIn('name', [
|
||||
'dashboard/dashboard',
|
||||
'routine/attachment',
|
||||
])->update(['remark' => 'Remark lang']);
|
||||
}
|
||||
}
|
||||
|
||||
$securityDataRecycle = $this->table('security_data_recycle');
|
||||
if ($securityDataRecycle->hasColumn('updatetime')) {
|
||||
$securityDataRecycle->renameColumn('updatetime', 'update_time')
|
||||
->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->save();
|
||||
}
|
||||
|
||||
$securityDataRecycleLog = $this->table('security_data_recycle_log');
|
||||
if ($securityDataRecycleLog->hasColumn('createtime')) {
|
||||
$securityDataRecycleLog->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->save();
|
||||
}
|
||||
|
||||
$securitySensitiveData = $this->table('security_sensitive_data');
|
||||
if ($securitySensitiveData->hasColumn('updatetime')) {
|
||||
$securitySensitiveData->renameColumn('updatetime', 'update_time')
|
||||
->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->save();
|
||||
}
|
||||
|
||||
$securitySensitiveDataLog = $this->table('security_sensitive_data_log');
|
||||
if ($securitySensitiveDataLog->hasColumn('createtime')) {
|
||||
$securitySensitiveDataLog->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->save();
|
||||
}
|
||||
|
||||
$token = $this->table('token');
|
||||
if ($token->hasColumn('createtime')) {
|
||||
$token->renameColumn('createtime', 'create_time')
|
||||
->renameColumn('expiretime', 'expire_time')
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->changeColumn('expire_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '过期时间'])
|
||||
->save();
|
||||
}
|
||||
|
||||
$userGroup = $this->table('user_group');
|
||||
if ($userGroup->hasColumn('createtime')) {
|
||||
$userGroup->renameColumn('updatetime', 'update_time')
|
||||
->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->save();
|
||||
}
|
||||
|
||||
$userMoneyLog = $this->table('user_money_log');
|
||||
if ($userMoneyLog->hasColumn('createtime')) {
|
||||
$userMoneyLog->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->save();
|
||||
}
|
||||
|
||||
$userRule = $this->table('user_rule');
|
||||
if ($userRule->hasColumn('createtime')) {
|
||||
$userRule->renameColumn('updatetime', 'update_time')
|
||||
->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->changeColumn('type', 'enum', ['values' => 'route,menu_dir,menu,nav_user_menu,nav,button', 'default' => 'menu', 'comment' => '类型:route=路由,menu_dir=菜单目录,menu=菜单项,nav_user_menu=顶栏会员菜单下拉项,nav=顶栏菜单项,button=页面按钮', 'null' => false]);
|
||||
if (!$userRule->hasColumn('no_login_valid')) {
|
||||
$userRule->addColumn('no_login_valid', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '未登录有效:0=否,1=是']);
|
||||
}
|
||||
$userRule->save();
|
||||
}
|
||||
|
||||
$userScoreLog = $this->table('user_score_log');
|
||||
if ($userScoreLog->hasColumn('createtime')) {
|
||||
$userScoreLog->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->save();
|
||||
}
|
||||
|
||||
$user = $this->table('user');
|
||||
if ($user->hasColumn('loginfailure')) {
|
||||
$user->renameColumn('lastlogintime', 'last_login_time')
|
||||
->renameColumn('lastloginip', 'last_login_ip')
|
||||
->renameColumn('loginfailure', 'login_failure')
|
||||
->renameColumn('joinip', 'join_ip')
|
||||
->renameColumn('jointime', 'join_time')
|
||||
->renameColumn('updatetime', 'update_time')
|
||||
->renameColumn('createtime', 'create_time')
|
||||
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
|
||||
->changeColumn('create_time', 'biginteger', ['after' => 'update_time', 'limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
|
||||
->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
16
database/migrations/20230719211338_version201.php
Normal file
16
database/migrations/20230719211338_version201.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
|
||||
class Version201 extends Migrator
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$user = $this->table('user');
|
||||
if ($user->hasIndex('email')) {
|
||||
$user->removeIndexByName('email')
|
||||
->removeIndexByName('mobile')
|
||||
->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
68
database/migrations/20230905060702_version202.php
Normal file
68
database/migrations/20230905060702_version202.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
use think\facade\Db;
|
||||
use think\migration\Migrator;
|
||||
|
||||
class Version202 extends Migrator
|
||||
{
|
||||
/**
|
||||
* 规范菜单规则
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$dashboardId = Db::name('admin_rule')
|
||||
->where('name', 'dashboard/dashboard')
|
||||
->lock(true)
|
||||
->value('id');
|
||||
if ($dashboardId) {
|
||||
// 修改name
|
||||
Db::name('admin_rule')
|
||||
->where('name', 'dashboard/dashboard')
|
||||
->update([
|
||||
'name' => 'dashboard',
|
||||
]);
|
||||
|
||||
// 增加一个查看的权限节点
|
||||
$dashboardIndexId = Db::name('admin_rule')->insertGetId([
|
||||
'pid' => $dashboardId,
|
||||
'type' => 'button',
|
||||
'title' => '查看',
|
||||
'name' => 'dashboard/index',
|
||||
'update_time' => time(),
|
||||
'create_time' => time(),
|
||||
]);
|
||||
|
||||
// 原本有控制台权限的管理员,给予新增的查看权限
|
||||
$group = Db::name('admin_group')
|
||||
->where('rules', 'find in set', $dashboardId)
|
||||
->select();
|
||||
foreach ($group as $item) {
|
||||
|
||||
$newRules = trim($item['rules'], ',');
|
||||
$newRules = $newRules . ',' . $dashboardIndexId;
|
||||
|
||||
Db::name('admin_group')
|
||||
->where('id', $item['id'])
|
||||
->update([
|
||||
'rules' => $newRules
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 修改name
|
||||
Db::name('admin_rule')
|
||||
->where('name', 'buildadmin/buildadmin')
|
||||
->update([
|
||||
'name' => 'buildadmin',
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
} catch (Throwable $e) {
|
||||
Db::rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
database/migrations/20231112093414_version205.php
Normal file
24
database/migrations/20231112093414_version205.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use think\facade\Db;
|
||||
use app\admin\model\Config;
|
||||
use think\migration\Migrator;
|
||||
|
||||
class Version205 extends Migrator
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$configQuickEntrance = Config::where('name', 'config_quick_entrance')->find();
|
||||
$value = $configQuickEntrance->value;
|
||||
foreach ($value as &$item) {
|
||||
if (str_starts_with($item['value'], '/admin/')) {
|
||||
$pathData = Db::name('admin_rule')->where('path', substr($item['value'], 7))->find();
|
||||
if ($pathData) {
|
||||
$item['value'] = $pathData['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$configQuickEntrance->value = $value;
|
||||
$configQuickEntrance->save();
|
||||
}
|
||||
}
|
||||
60
database/migrations/20231229043002_version206.php
Normal file
60
database/migrations/20231229043002_version206.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use think\facade\Db;
|
||||
use think\migration\Migrator;
|
||||
|
||||
class Version206 extends Migrator
|
||||
{
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$exist = Db::name('config')->where('name', 'backend_entrance')->value('id');
|
||||
if (!$exist) {
|
||||
$rows = [
|
||||
[
|
||||
'name' => 'backend_entrance',
|
||||
'group' => 'basics',
|
||||
'title' => 'Backend entrance',
|
||||
'type' => 'string',
|
||||
'value' => '/admin',
|
||||
'rule' => 'required',
|
||||
'weigh' => 1,
|
||||
],
|
||||
];
|
||||
$table = $this->table('config');
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
|
||||
$crudLog = $this->table('crud_log');
|
||||
if (!$crudLog->hasColumn('connection')) {
|
||||
$crudLog->addColumn('connection', 'string', ['limit' => 100, 'default' => '', 'comment' => '数据库连接配置标识', 'null' => false, 'after' => 'status']);
|
||||
$crudLog->save();
|
||||
}
|
||||
|
||||
$securityDataRecycle = $this->table('security_data_recycle');
|
||||
if (!$securityDataRecycle->hasColumn('connection')) {
|
||||
$securityDataRecycle->addColumn('connection', 'string', ['limit' => 100, 'default' => '', 'comment' => '数据库连接配置标识', 'null' => false, 'after' => 'data_table']);
|
||||
$securityDataRecycle->save();
|
||||
}
|
||||
|
||||
$securityDataRecycleLog = $this->table('security_data_recycle_log');
|
||||
if (!$securityDataRecycleLog->hasColumn('connection')) {
|
||||
$securityDataRecycleLog->addColumn('connection', 'string', ['limit' => 100, 'default' => '', 'comment' => '数据库连接配置标识', 'null' => false, 'after' => 'data_table']);
|
||||
$securityDataRecycleLog->save();
|
||||
}
|
||||
|
||||
$securitySensitiveData = $this->table('security_sensitive_data');
|
||||
if (!$securitySensitiveData->hasColumn('connection')) {
|
||||
$securitySensitiveData->addColumn('connection', 'string', ['limit' => 100, 'default' => '', 'comment' => '数据库连接配置标识', 'null' => false, 'after' => 'data_table']);
|
||||
$securitySensitiveData->save();
|
||||
}
|
||||
|
||||
$securitySensitiveDataLog = $this->table('security_sensitive_data_log');
|
||||
if (!$securitySensitiveDataLog->hasColumn('connection')) {
|
||||
$securitySensitiveDataLog->addColumn('connection', 'string', ['limit' => 100, 'default' => '', 'comment' => '数据库连接配置标识', 'null' => false, 'after' => 'data_table']);
|
||||
$securitySensitiveDataLog->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
80
database/migrations/20250412134127_version222.php
Normal file
80
database/migrations/20250412134127_version222.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
use think\facade\Db;
|
||||
use app\admin\model\CrudLog;
|
||||
use think\migration\Migrator;
|
||||
|
||||
class Version222 extends Migrator
|
||||
{
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
/**
|
||||
* 修复附件表 name 字段长度可能不够的问题
|
||||
*/
|
||||
$attachment = $this->table('attachment');
|
||||
$attachment->changeColumn('name', 'string', ['limit' => 120, 'default' => '', 'comment' => '原始名称', 'null' => false])->save();
|
||||
|
||||
/**
|
||||
* 用户表
|
||||
* 1. status 注释优化
|
||||
* 2. password 增加长度至 password_hash 建议值
|
||||
* 3. salt 注释中标记废弃待删除
|
||||
*/
|
||||
$user = $this->table('user');
|
||||
$user->changeColumn('status', 'string', ['limit' => 30, 'default' => '', 'comment' => '状态:enable=启用,disable=禁用', 'null' => false])
|
||||
->changeColumn('password', 'string', ['limit' => 255, 'default' => '', 'comment' => '密码', 'null' => false])
|
||||
->changeColumn('salt', 'string', ['limit' => 30, 'default' => '', 'comment' => '密码盐(废弃待删)', 'null' => false])
|
||||
->save();
|
||||
|
||||
/**
|
||||
* 管理员表
|
||||
* 1. status 改为字符串存储
|
||||
* 2. 其他和以上用户表的改动相同
|
||||
*/
|
||||
$admin = $this->table('admin');
|
||||
$admin->changeColumn('status', 'string', ['limit' => 30, 'default' => '', 'comment' => '状态:enable=启用,disable=禁用', 'null' => false])
|
||||
->changeColumn('password', 'string', ['limit' => 255, 'default' => '', 'comment' => '密码', 'null' => false])
|
||||
->changeColumn('salt', 'string', ['limit' => 30, 'default' => '', 'comment' => '密码盐(废弃待删)', 'null' => false])
|
||||
->save();
|
||||
|
||||
Db::name('admin')->where('status', '0')->update(['status' => 'disable']);
|
||||
Db::name('admin')->where('status', '1')->update(['status' => 'enable']);
|
||||
|
||||
/**
|
||||
* CRUD 历史记录表
|
||||
*/
|
||||
$crudLog = $this->table('crud_log');
|
||||
if (!$crudLog->hasColumn('comment')) {
|
||||
$crudLog
|
||||
->addColumn('comment', 'string', ['limit' => 255, 'default' => '', 'comment' => '注释', 'null' => false, 'after' => 'table_name'])
|
||||
->addColumn('sync', 'integer', ['default' => 0, 'signed' => false, 'comment' => '同步记录', 'null' => false, 'after' => 'fields'])
|
||||
->save();
|
||||
|
||||
$logs = CrudLog::select();
|
||||
foreach ($logs as $log) {
|
||||
if ($log->table['comment']) {
|
||||
$log->comment = $log->table['comment'];
|
||||
$log->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 多个数据表的 status 字段类型修改为更合理的类型
|
||||
*/
|
||||
$tables = ['admin_group', 'admin_rule', 'user_group', 'user_rule', 'security_data_recycle', 'security_sensitive_data', 'test_build'];
|
||||
foreach ($tables as $table) {
|
||||
if ($this->hasTable($table)) {
|
||||
$mTable = $this->table($table);
|
||||
$mTable->changeColumn('status', 'boolean', ['default' => 1, 'signed' => false, 'comment' => '状态:0=禁用,1=启用', 'null' => false])->save();
|
||||
|
||||
// 原状态值兼容至新类型
|
||||
Db::name($table)->where('status', 1)->update(['status' => 0]);
|
||||
Db::name($table)->where('status', 2)->update(['status' => 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user