mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2024-11-29 18:47:35 +08:00
modified 添加相关的数据库迁移脚本
This commit is contained in:
parent
f942e50720
commit
aa14f1e2c1
@ -22,7 +22,8 @@
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"topthink/framework": "^6.0",
|
||||
"topthink/think-orm": "^2.0"
|
||||
"topthink/think-orm": "^2.0",
|
||||
"topthink/think-migration": "^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/var-dumper": "^4.2",
|
||||
|
58
composer.lock
generated
58
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "d0bae3786336b8fb3f12db9ee5514cfc",
|
||||
"content-hash": "58a42c05e879b20be89bd2a57fd4b31e",
|
||||
"packages": [
|
||||
{
|
||||
"name": "league/flysystem",
|
||||
@ -591,6 +591,62 @@
|
||||
"description": "The ThinkPHP6 Helper Package",
|
||||
"time": "2019-11-08T08:01:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "topthink/think-migration",
|
||||
"version": "v3.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/top-think/think-migration.git",
|
||||
"reference": "e8b3396505617732a57309d2818d70ffe187385c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/top-think/think-migration/zipball/e8b3396505617732a57309d2818d70ffe187385c",
|
||||
"reference": "e8b3396505617732a57309d2818d70ffe187385c",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"topthink/framework": "^6.0.0",
|
||||
"topthink/think-helper": "^3.0.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "^1.8"
|
||||
},
|
||||
"suggest": {
|
||||
"fzaninotto/faker": "Required to use the factory builder (^1.8)."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"think": {
|
||||
"services": [
|
||||
"think\\migration\\Service"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Phinx\\": "phinx/src/Phinx",
|
||||
"think\\migration\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "yunwuxin",
|
||||
"email": "448901948@qq.com"
|
||||
}
|
||||
],
|
||||
"time": "2019-06-17T10:13:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "topthink/think-orm",
|
||||
"version": "v2.0.33",
|
||||
|
85
database/migrations/20190425073802_admin_app.php
Normal file
85
database/migrations/20190425073802_admin_app.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class AdminApp extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREATE TABLE `admin_app` (
|
||||
* `id` int(11) unsigned NOT NULL,
|
||||
* `app_id` varchar(50) NOT NULL DEFAULT '' COMMENT '应用id',
|
||||
* `app_secret` varchar(50) NOT NULL DEFAULT '' COMMENT '应用密码',
|
||||
* `app_name` varchar(50) NOT NULL DEFAULT '' COMMENT '应用名称',
|
||||
* `app_status` int(2) NOT NULL DEFAULT '1' COMMENT '应用状态:0表示禁用,1表示启用',
|
||||
* `app_info` text COMMENT '应用说明',
|
||||
* `app_api` text COMMENT '当前应用允许请求的全部API接口',
|
||||
* `app_group` varchar(128) NOT NULL DEFAULT 'default' COMMENT '当前应用所属的应用组唯一标识',
|
||||
* `app_addTime` int(11) NOT NULL DEFAULT '0' COMMENT '应用创建时间',
|
||||
* `app_api_show` text COMMENT '前台样式显示所需数据格式',
|
||||
* PRIMARY KEY (`id`),
|
||||
* UNIQUE KEY `app_id` (`app_id`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='appId和appSecret表';
|
||||
*/
|
||||
public function change() {
|
||||
$table = $this->table('admin_app', [
|
||||
'comment' => 'appId和appSecret表',
|
||||
])->setCollation('utf8mb4_general_ci');
|
||||
$table->addColumn('app_id', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => '应用id'
|
||||
])->addColumn('app_secret', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => '应用密码'
|
||||
])->addColumn('app_name', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => '应用名称'
|
||||
])->addColumn('app_status', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '应用状态:0表示禁用,1表示启用'
|
||||
])->addColumn('app_info', 'text', [
|
||||
'comment' => '应用说明',
|
||||
'null' => true
|
||||
])->addColumn('app_api', 'text', [
|
||||
'comment' => '当前应用允许请求的全部API接口',
|
||||
'null' => true
|
||||
])->addColumn('app_group', 'string', [
|
||||
'limit' => 128,
|
||||
'default' => 'default',
|
||||
'comment' => '当前应用所属的应用组唯一标识'
|
||||
])->addColumn('app_add_time', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '应用创建时间'
|
||||
])->addColumn('app_api_show', 'text', [
|
||||
'comment' => '前台样式显示所需数据格式',
|
||||
'null' => true
|
||||
])->addIndex(['app_id'], ['unique' => true])->create();
|
||||
}
|
||||
}
|
61
database/migrations/20190425094427_admin_app_group.php
Normal file
61
database/migrations/20190425094427_admin_app_group.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class AdminAppGroup extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREATE TABLE `admin_app_group` (
|
||||
* `id` int(11) unsigned NOT NULL,
|
||||
* `name` varchar(128) NOT NULL DEFAULT '' COMMENT '组名称',
|
||||
* `description` text COMMENT '组说明',
|
||||
* `status` int(2) NOT NULL DEFAULT '1' COMMENT '组状态:0表示禁用,1表示启用',
|
||||
* `hash` varchar(128) NOT NULL DEFAULT '' COMMENT '组标识',
|
||||
* PRIMARY KEY (`id`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用组,目前只做管理使用,没有实际权限控制';
|
||||
*/
|
||||
public function change() {
|
||||
$table = $this->table('admin_app_group', [
|
||||
'comment' => '应用组,目前只做管理使用,没有实际权限控制'
|
||||
])->setCollation('utf8mb4_general_ci');
|
||||
$table->addColumn('name', 'string', [
|
||||
'limit' => 128,
|
||||
'default' => '',
|
||||
'comment' => '组名称'
|
||||
])->addColumn('description', 'text', [
|
||||
'comment' => '组说明',
|
||||
'null' => true
|
||||
])->addColumn('status', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '组状态:0表示禁用,1表示启用'
|
||||
])->addColumn('hash', 'string', [
|
||||
'limit' => 128,
|
||||
'default' => '',
|
||||
'comment' => '组标识'
|
||||
])->create();
|
||||
}
|
||||
}
|
56
database/migrations/20190508070533_admin_auth_group.php
Normal file
56
database/migrations/20190508070533_admin_auth_group.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class AdminAuthGroup extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREATE TABLE `admin_auth_group` (
|
||||
* `id` int(11) unsigned NOT NULL,
|
||||
* `name` varchar(50) NOT NULL DEFAULT '' COMMENT '组名称',
|
||||
* `description` text COMMENT '组描述',
|
||||
* `status` int(2) NOT NULL DEFAULT '1' COMMENT '组状态:为1正常,为0禁用',
|
||||
* PRIMARY KEY (`id`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='权限组';
|
||||
*/
|
||||
public function change() {
|
||||
$table = $this->table('admin_auth_group', [
|
||||
'comment' => '权限组'
|
||||
])->setCollation('utf8mb4_general_ci');
|
||||
$table->addColumn('name', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => '组名称'
|
||||
])->addColumn('description', 'text', [
|
||||
'comment' => '组描述',
|
||||
'null' => true
|
||||
])->addColumn('status', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '组状态:为1正常,为0禁用'
|
||||
])->create();
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
|
||||
class AdminAuthGroupAccess extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREATE TABLE `admin_auth_group_access` (
|
||||
* `id` int(11) unsigned NOT NULL,
|
||||
* `uid` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
* `groupId` varchar(255) NOT NULL DEFAULT '',
|
||||
* PRIMARY KEY (`id`),
|
||||
* KEY `uid` (`uid`),
|
||||
* KEY `groupId` (`groupId`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户和组的对应关系';
|
||||
*/
|
||||
public function change() {
|
||||
$table = $this->table('admin_auth_group_access', [
|
||||
'comment' => '用户和组的对应关系'
|
||||
])->setCollation('utf8mb4_general_ci');
|
||||
$table->addColumn('uid', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'signed' => false,
|
||||
'comment' => ''
|
||||
])->addColumn('group_id', 'string', [
|
||||
'limit' => 255,
|
||||
'default' => '',
|
||||
'comment' => ''
|
||||
])->addIndex(['uid'])->addIndex(['group_id'])->create();
|
||||
}
|
||||
}
|
64
database/migrations/20190508101122_admin_auth_rule.php
Normal file
64
database/migrations/20190508101122_admin_auth_rule.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class AdminAuthRule extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREATE TABLE `admin_auth_rule` (
|
||||
* `id` int(11) unsigned NOT NULL,
|
||||
* `url` varchar(80) NOT NULL DEFAULT '' COMMENT '规则唯一标识',
|
||||
* `groupId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '权限所属组的ID',
|
||||
* `auth` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '权限数值',
|
||||
* `status` int(1) NOT NULL DEFAULT '1' COMMENT '状态:为1正常,为0禁用',
|
||||
* PRIMARY KEY (`id`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='权限细节';
|
||||
*/
|
||||
public function change() {
|
||||
$table = $this->table('admin_auth_rule', [
|
||||
'comment' => '权限细节'
|
||||
])->setCollation('utf8mb4_general_ci');
|
||||
$table->addColumn('url', 'string', [
|
||||
'limit' => 80,
|
||||
'default' => '',
|
||||
'comment' => '规则唯一标识'
|
||||
])->addColumn('group_id', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'signed' => false,
|
||||
'comment' => '权限所属组的ID'
|
||||
])->addColumn('auth', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'signed' => false,
|
||||
'comment' => '权限数值'
|
||||
])->addColumn('status', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '状态:为1正常,为0禁用'
|
||||
])->create();
|
||||
}
|
||||
}
|
88
database/migrations/20190508152801_admin_fields.php
Normal file
88
database/migrations/20190508152801_admin_fields.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class AdminFields extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREATE TABLE `admin_fields` (
|
||||
* `id` int(11) unsigned NOT NULL,
|
||||
* `field_name` varchar(50) NOT NULL DEFAULT '' COMMENT '字段名称',
|
||||
* `hash` varchar(50) NOT NULL DEFAULT '' COMMENT '权限所属组的ID',
|
||||
* `data_type` int(2) NOT NULL DEFAULT '0' COMMENT '数据类型,来源于DataType类库',
|
||||
* `default` varchar(500) NOT NULL DEFAULT '' COMMENT '默认值',
|
||||
* `is_must` int(2) NOT NULL DEFAULT '0' COMMENT '是否必须 0为不必须,1为必须',
|
||||
* `range` varchar(500) NOT NULL DEFAULT '' COMMENT '范围,Json字符串,根据数据类型有不一样的含义',
|
||||
* `info` varchar(500) NOT NULL DEFAULT '' COMMENT '字段说明',
|
||||
* `type` int(2) NOT NULL DEFAULT '0' COMMENT '字段用处:0为request,1为response',
|
||||
* `show_name` varchar(50) NOT NULL DEFAULT '' COMMENT 'wiki显示用字段',
|
||||
* PRIMARY KEY (`id`),
|
||||
* KEY `hash` (`hash`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用于保存各个API的字段规则';
|
||||
*/
|
||||
public function change() {
|
||||
$table = $this->table('admin_fields', [
|
||||
'comment' => '用于保存各个API的字段规则'
|
||||
])->setCollation('utf8mb4_general_ci');
|
||||
$table->addColumn('field_name', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => '字段名称'
|
||||
])->addColumn('hash', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => '权限所属组的ID'
|
||||
])->addColumn('data_type', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 0,
|
||||
'comment' => '数据类型,来源于DataType类库'
|
||||
])->addColumn('default', 'string', [
|
||||
'limit' => 500,
|
||||
'default' => '',
|
||||
'comment' => '默认值'
|
||||
])->addColumn('is_must', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 0,
|
||||
'comment' => '是否必须 0为不必须,1为必须'
|
||||
])->addColumn('range', 'string', [
|
||||
'limit' => 500,
|
||||
'default' => '',
|
||||
'comment' => '范围,Json字符串,根据数据类型有不一样的含义'
|
||||
])->addColumn('info', 'string', [
|
||||
'limit' => 500,
|
||||
'default' => '',
|
||||
'comment' => '字段说明'
|
||||
])->addColumn('type', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 0,
|
||||
'comment' => '字段用处:0为request,1为response'
|
||||
])->addColumn('show_name', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => 'wiki显示用字段'
|
||||
])->addIndex(['hash'])->create();
|
||||
}
|
||||
}
|
81
database/migrations/20190508153800_admin_group.php
Normal file
81
database/migrations/20190508153800_admin_group.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class AdminGroup extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREATE TABLE `admin_group` (
|
||||
* `id` int(11) unsigned NOT NULL,
|
||||
* `name` varchar(128) NOT NULL DEFAULT '' COMMENT '组名称',
|
||||
* `description` text COMMENT '组说明',
|
||||
* `status` int(1) NOT NULL DEFAULT '1' COMMENT '状态:为1正常,为0禁用',
|
||||
* `hash` varchar(128) NOT NULL DEFAULT '' COMMENT '组标识',
|
||||
* `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
* `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
* `image` varchar(256) DEFAULT NULL COMMENT '分组封面图',
|
||||
* `hot` int(11) NOT NULL DEFAULT '0' COMMENT '分组热度',
|
||||
* PRIMARY KEY (`id`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='接口组管理';
|
||||
*/
|
||||
public function change() {
|
||||
$table = $this->table('admin_group', [
|
||||
'comment' => '接口组管理'
|
||||
])->setCollation('utf8mb4_general_ci');
|
||||
$table->addColumn('name', 'string', [
|
||||
'limit' => 128,
|
||||
'default' => '',
|
||||
'comment' => '组名称'
|
||||
])->addColumn('description', 'text', [
|
||||
'comment' => '组说明',
|
||||
'null' => true
|
||||
])->addColumn('status', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '状态:为1正常,为0禁用'
|
||||
])->addColumn('hash', 'string', [
|
||||
'limit' => 128,
|
||||
'default' => '',
|
||||
'comment' => '组标识'
|
||||
])->addColumn('create_time', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '创建时间'
|
||||
])->addColumn('update_time', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '修改时间'
|
||||
])->addColumn('image', 'string', [
|
||||
'limit' => 256,
|
||||
'null' => true,
|
||||
'comment' => '分组封面图'
|
||||
])->addColumn('hot', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '分组热度'
|
||||
])->create();
|
||||
}
|
||||
}
|
88
database/migrations/20190513065521_admin_list.php
Normal file
88
database/migrations/20190513065521_admin_list.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class AdminList extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREATE TABLE `admin_list` (
|
||||
* `id` int(11) unsigned NOT NULL,
|
||||
* `api_class` varchar(50) NOT NULL DEFAULT '' COMMENT 'api索引,保存了类和方法',
|
||||
* `hash` varchar(50) NOT NULL DEFAULT '' COMMENT 'api唯一标识',
|
||||
* `access_token` int(2) NOT NULL DEFAULT '1' COMMENT '是否需要认证AccessToken 1:需要,0:不需要',
|
||||
* `need_login` int(2) NOT NULL DEFAULT '1' COMMENT '是否需要认证用户token 1:需要 0:不需要',
|
||||
* `status` int(2) NOT NULL DEFAULT '1' COMMENT 'API状态:0表示禁用,1表示启用',
|
||||
* `method` int(2) NOT NULL DEFAULT '2' COMMENT '请求方式0:不限1:Post,2:Get',
|
||||
* `info` varchar(500) NOT NULL DEFAULT '' COMMENT 'api中文说明',
|
||||
* `is_test` int(2) NOT NULL DEFAULT '0' COMMENT '是否是测试模式:0:生产模式,1:测试模式',
|
||||
* `return_str` text COMMENT '返回数据示例',
|
||||
* `group_hash` varchar(64) NOT NULL DEFAULT 'default' COMMENT '当前接口所属的接口分组',
|
||||
* PRIMARY KEY (`id`),
|
||||
* KEY `hash` (`hash`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用于维护接口信息';
|
||||
*/
|
||||
public function change() {
|
||||
$table = $this->table('admin_list', [
|
||||
'comment' => '用于维护接口信息'
|
||||
])->setCollation('utf8mb4_general_ci');
|
||||
$table->addColumn('api_class', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => 'api索引,保存了类和方法'
|
||||
])->addColumn('hash', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => 'api唯一标识'
|
||||
])->addColumn('access_token', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '认证方式 1:复杂认证,0:简易认证'
|
||||
])->addColumn('status', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => 'API状态:0表示禁用,1表示启用'
|
||||
])->addColumn('method', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 2,
|
||||
'comment' => '请求方式0:不限1:Post,2:Get'
|
||||
])->addColumn('info', 'string', [
|
||||
'limit' => 500,
|
||||
'default' => '',
|
||||
'comment' => 'api中文说明'
|
||||
])->addColumn('is_test', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 0,
|
||||
'comment' => '是否是测试模式:0:生产模式,1:测试模式'
|
||||
])->addColumn('return_str', 'text', [
|
||||
'null' => true,
|
||||
'comment' => '返回数据示例'
|
||||
])->addColumn('group_hash', 'string', [
|
||||
'limit' => 64,
|
||||
'default' => 'default',
|
||||
'comment' => '当前接口所属的接口分组'
|
||||
])->addIndex(['hash'])->create();
|
||||
}
|
||||
}
|
82
database/migrations/20190513070628_admin_menu.php
Normal file
82
database/migrations/20190513070628_admin_menu.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class AdminMenu extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREATE TABLE `admin_menu` (
|
||||
* `id` int(11) unsigned NOT NULL,
|
||||
* `name` varchar(50) NOT NULL DEFAULT '' COMMENT '菜单名',
|
||||
* `fid` int(11) NOT NULL DEFAULT '0' COMMENT '父级菜单ID',
|
||||
* `url` varchar(50) NOT NULL DEFAULT '' COMMENT '链接',
|
||||
* `auth` int(2) NOT NULL DEFAULT '0' COMMENT '访客权限',
|
||||
* `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序',
|
||||
* `hide` int(2) NOT NULL DEFAULT '0' COMMENT '是否显示',
|
||||
* `icon` varchar(50) NOT NULL DEFAULT '' COMMENT '菜单图标',
|
||||
* `level` int(2) NOT NULL DEFAULT '0' COMMENT '菜单认证等级',
|
||||
* PRIMARY KEY (`id`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='目录信息';
|
||||
*/
|
||||
public function change() {
|
||||
$table = $this->table('admin_menu', [
|
||||
'comment' => '目录信息'
|
||||
])->setCollation('utf8mb4_general_ci');
|
||||
$table->addColumn('name', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => '菜单名'
|
||||
])->addColumn('fid', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '父级菜单ID'
|
||||
])->addColumn('url', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => '链接'
|
||||
])->addColumn('auth', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 0,
|
||||
'comment' => '访客权限'
|
||||
])->addColumn('sort', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '排序'
|
||||
])->addColumn('hide', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 0,
|
||||
'comment' => '是否显示'
|
||||
])->addColumn('icon', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => '菜单图标'
|
||||
])->addColumn('level', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 0,
|
||||
'comment' => '菜单认证等级'
|
||||
])->create();
|
||||
}
|
||||
}
|
84
database/migrations/20190513081034_admin_user.php
Normal file
84
database/migrations/20190513081034_admin_user.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class AdminUser extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREATE TABLE `admin_user` (
|
||||
* `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
* `username` varchar(64) NOT NULL DEFAULT '' COMMENT '用户名',
|
||||
* `nickname` varchar(64) NOT NULL DEFAULT '' COMMENT '用户昵称',
|
||||
* `password` char(32) NOT NULL DEFAULT '' COMMENT '用户密码',
|
||||
* `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '注册时间',
|
||||
* `create_ip` bigint(11) NOT NULL COMMENT '注册IP',
|
||||
* `update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',
|
||||
* `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '账号状态 0封号 1正常',
|
||||
* `openid` varchar(100) DEFAULT NULL COMMENT '三方登录唯一ID',
|
||||
* PRIMARY KEY (`id`),
|
||||
* KEY `create_time` (`create_time`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理员认证信息';
|
||||
*/
|
||||
public function change() {
|
||||
$table = $this->table('admin_user', [
|
||||
'comment' => '管理员认证信息'
|
||||
])->setCollation('utf8mb4_general_ci');
|
||||
$table->addColumn('username', 'string', [
|
||||
'limit' => 64,
|
||||
'default' => '',
|
||||
'comment' => '用户名'
|
||||
])->addColumn('nickname', 'string', [
|
||||
'limit' => 64,
|
||||
'default' => '',
|
||||
'comment' => '用户昵称'
|
||||
])->addColumn('password', 'char', [
|
||||
'limit' => 32,
|
||||
'default' => '',
|
||||
'comment' => '用户密码'
|
||||
])->addColumn('create_time', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '注册时间'
|
||||
])->addColumn('create_ip', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_BIG,
|
||||
'default' => 0,
|
||||
'comment' => '注册IP'
|
||||
])->addColumn('update_time', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '更新时间'
|
||||
])->addColumn('status', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 0,
|
||||
'comment' => '账号状态 0封号 1正常'
|
||||
])->addColumn('openid', 'string', [
|
||||
'limit' => 100,
|
||||
'null' => true,
|
||||
'default' => '',
|
||||
'comment' => '三方登录唯一ID'
|
||||
])->addIndex(['create_time'])->create();
|
||||
}
|
||||
}
|
71
database/migrations/20190513082503_admin_user_action.php
Normal file
71
database/migrations/20190513082503_admin_user_action.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
|
||||
class AdminUserAction extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREATE TABLE `admin_user_action` (
|
||||
* `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
* `action_name` varchar(50) NOT NULL DEFAULT '' COMMENT '行为名称',
|
||||
* `uid` int(11) NOT NULL DEFAULT '0' COMMENT '操作用户ID',
|
||||
* `nickname` varchar(50) NOT NULL DEFAULT '' COMMENT '用户昵称',
|
||||
* `add_time` int(11) NOT NULL DEFAULT '0' COMMENT '操作时间',
|
||||
* `data` text COMMENT '用户提交的数据',
|
||||
* `url` varchar(200) NOT NULL DEFAULT '' COMMENT '操作URL',
|
||||
* PRIMARY KEY (`id`),
|
||||
* KEY `uid` (`uid`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户操作日志';
|
||||
*/
|
||||
public function change() {
|
||||
$table = $this->table('admin_user_action', [
|
||||
'comment' => '用户操作日志'
|
||||
])->setCollation('utf8mb4_general_ci');
|
||||
$table->addColumn('action_name', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => '行为名称'
|
||||
])->addColumn('uid', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '操作用户ID'
|
||||
])->addColumn('nickname', 'string', [
|
||||
'limit' => 50,
|
||||
'default' => '',
|
||||
'comment' => '用户昵称'
|
||||
])->addColumn('add_time', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '操作时间'
|
||||
])->addColumn('data', 'text', [
|
||||
'null' => true,
|
||||
'comment' => '用户提交的数据'
|
||||
])->addColumn('url', 'string', [
|
||||
'limit' => 200,
|
||||
'default' => 0,
|
||||
'comment' => '操作URL'
|
||||
])->addIndex(['uid'])->create();
|
||||
}
|
||||
}
|
67
database/migrations/20190513085755_admin_user_data.php
Normal file
67
database/migrations/20190513085755_admin_user_data.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class AdminUserData extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREATE TABLE `admin_user_data` (
|
||||
* `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
* `login_times` int(11) NOT NULL DEFAULT '0' COMMENT '账号登录次数',
|
||||
* `last_login_ip` bigint(11) NOT NULL DEFAULT '0' COMMENT '最后登录IP',
|
||||
* `last_login_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后登录时间',
|
||||
* `uid` int(11) NOT NULL DEFAULT '' COMMENT '用户ID',
|
||||
* `head_img` text COMMENT '用户头像',
|
||||
* PRIMARY KEY (`id`)
|
||||
* KEY `uid` (`uid`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理员数据表';
|
||||
*/
|
||||
public function change() {
|
||||
$table = $this->table('admin_user_data', [
|
||||
'comment' => '管理员数据表'
|
||||
])->setCollation('utf8mb4_general_ci');
|
||||
$table->addColumn('login_times', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '账号登录次数'
|
||||
])->addColumn('last_login_ip', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_BIG,
|
||||
'default' => 0,
|
||||
'comment' => '最后登录IP'
|
||||
])->addColumn('last_login_time', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '最后登录时间'
|
||||
])->addColumn('uid', 'integer', [
|
||||
'limit' => 11,
|
||||
'default' => 0,
|
||||
'comment' => '用户ID'
|
||||
])->addColumn('head_img', 'text', [
|
||||
'null' => true,
|
||||
'comment' => '用户头像'
|
||||
])->addIndex(['uid'])->create();
|
||||
}
|
||||
}
|
718
database/migrations/20190513155519_ini_admin_menu.php
Normal file
718
database/migrations/20190513155519_ini_admin_menu.php
Normal file
@ -0,0 +1,718 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
|
||||
class IniAdminMenu extends Migrator {
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
public function up() {
|
||||
$data = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => '用户登录',
|
||||
'fid' => 0,
|
||||
'url' => 'admin/Login/index',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 2,
|
||||
'name' => '用户登出',
|
||||
'fid' => 0,
|
||||
'url' => 'admin/Login/logout',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 3,
|
||||
'name' => '系统管理',
|
||||
'fid' => 0,
|
||||
'url' => '',
|
||||
'auth' => 0,
|
||||
'sort' => 1,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 4,
|
||||
'name' => '菜单维护',
|
||||
'fid' => 3,
|
||||
'url' => '',
|
||||
'auth' => 0,
|
||||
'sort' => 1,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 5,
|
||||
'name' => '菜单状态修改',
|
||||
'fid' => 4,
|
||||
'url' => 'admin/Menu/changeStatus',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 6,
|
||||
'name' => '新增菜单',
|
||||
'fid' => 4,
|
||||
'url' => 'admin/Menu/add',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 7,
|
||||
'name' => '编辑菜单',
|
||||
'fid' => 4,
|
||||
'url' => 'admin/Menu/edit',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 8,
|
||||
'name' => '菜单删除',
|
||||
'fid' => 4,
|
||||
'url' => 'admin/Menu/del',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 9,
|
||||
'name' => '用户管理',
|
||||
'fid' => 3,
|
||||
'url' => '',
|
||||
'auth' => 0,
|
||||
'sort' => 2,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 10,
|
||||
'name' => '获取当前组的全部用户',
|
||||
'fid' => 9,
|
||||
'url' => 'admin/User/getUsers',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 11,
|
||||
'name' => '用户状态修改',
|
||||
'fid' => 9,
|
||||
'url' => 'admin/User/changeStatus',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 12,
|
||||
'name' => '新增用户',
|
||||
'fid' => 9,
|
||||
'url' => 'admin/User/add',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 13,
|
||||
'name' => '用户编辑',
|
||||
'fid' => 9,
|
||||
'url' => 'admin/User/edit',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 14,
|
||||
'name' => '用户删除',
|
||||
'fid' => 9,
|
||||
'url' => 'admin/User/del',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 15,
|
||||
'name' => '权限管理',
|
||||
'fid' => 3,
|
||||
'url' => '',
|
||||
'auth' => 0,
|
||||
'sort' => 3,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 16,
|
||||
'name' => '权限组状态编辑',
|
||||
'fid' => 15,
|
||||
'url' => 'admin/Auth/changeStatus',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 17,
|
||||
'name' => '从指定组中删除指定用户',
|
||||
'fid' => 15,
|
||||
'url' => 'admin/Auth/delMember',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 18,
|
||||
'name' => '新增权限组',
|
||||
'fid' => 15,
|
||||
'url' => 'admin/Auth/add',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 19,
|
||||
'name' => '权限组编辑',
|
||||
'fid' => 15,
|
||||
'url' => 'admin/Auth/edit',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 20,
|
||||
'name' => '删除权限组',
|
||||
'fid' => 15,
|
||||
'url' => 'admin/Auth/del',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 21,
|
||||
'name' => '获取全部已开放的可选组',
|
||||
'fid' => 15,
|
||||
'url' => 'admin/Auth/getGroups',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 22,
|
||||
'name' => '获取组所有的权限列表',
|
||||
'fid' => 15,
|
||||
'url' => 'admin/Auth/getRuleList',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 23,
|
||||
'name' => '应用接入',
|
||||
'fid' => 0,
|
||||
'url' => '',
|
||||
'auth' => 0,
|
||||
'sort' => 2,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 24,
|
||||
'name' => '应用管理',
|
||||
'fid' => 23,
|
||||
'url' => '',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 25,
|
||||
'name' => '应用状态编辑',
|
||||
'fid' => 24,
|
||||
'url' => 'admin/App/changeStatus',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 26,
|
||||
'name' => '获取AppId,AppSecret,接口列表,应用接口权限细节',
|
||||
'fid' => 24,
|
||||
'url' => 'admin/App/getAppInfo',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 27,
|
||||
'name' => '新增应用',
|
||||
'fid' => 24,
|
||||
'url' => 'admin/App/add',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 28,
|
||||
'name' => '编辑应用',
|
||||
'fid' => 24,
|
||||
'url' => 'admin/App/edit',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 29,
|
||||
'name' => '删除应用',
|
||||
'fid' => 24,
|
||||
'url' => 'admin/App/del',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 30,
|
||||
'name' => '接口管理',
|
||||
'fid' => 0,
|
||||
'url' => '',
|
||||
'auth' => 0,
|
||||
'sort' => 3,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 31,
|
||||
'name' => '接口维护',
|
||||
'fid' => 30,
|
||||
'url' => '',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 32,
|
||||
'name' => '接口状态编辑',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/InterfaceList/changeStatus',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 33,
|
||||
'name' => '获取接口唯一标识',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/InterfaceList/getHash',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 34,
|
||||
'name' => '添加接口',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/InterfaceList/add',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 35,
|
||||
'name' => '编辑接口',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/InterfaceList/edit',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 36,
|
||||
'name' => '删除接口',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/InterfaceList/del',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 37,
|
||||
'name' => '获取接口请求字段',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/Fields/request',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 38,
|
||||
'name' => '获取接口返回字段',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/Fields/response',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 39,
|
||||
'name' => '添加接口字段',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/Fields/add',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 40,
|
||||
'name' => '上传接口返回字段',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/Fields/upload',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 41,
|
||||
'name' => '编辑接口字段',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/Fields/edit',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 42,
|
||||
'name' => '删除接口字段',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/Fields/del',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 43,
|
||||
'name' => '接口分组',
|
||||
'fid' => 30,
|
||||
'url' => '',
|
||||
'auth' => 0,
|
||||
'sort' => 1,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 44,
|
||||
'name' => '添加接口组',
|
||||
'fid' => 43,
|
||||
'url' => 'admin/InterfaceGroup/add',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 45,
|
||||
'name' => '编辑接口组',
|
||||
'fid' => 43,
|
||||
'url' => 'admin/InterfaceGroup/edit',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 46,
|
||||
'name' => '删除接口组',
|
||||
'fid' => 43,
|
||||
'url' => 'admin/InterfaceGroup/del',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 47,
|
||||
'name' => '获取全部有效的接口组',
|
||||
'fid' => 43,
|
||||
'url' => 'admin/InterfaceGroup/getAll',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 48,
|
||||
'name' => '接口组状态维护',
|
||||
'fid' => 43,
|
||||
'url' => 'admin/InterfaceGroup/changeStatus',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 49,
|
||||
'name' => '应用分组',
|
||||
'fid' => 23,
|
||||
'url' => '',
|
||||
'auth' => 0,
|
||||
'sort' => 1,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 50,
|
||||
'name' => '添加应用组',
|
||||
'fid' => 49,
|
||||
'url' => 'admin/AppGroup/add',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 51,
|
||||
'name' => '编辑应用组',
|
||||
'fid' => 49,
|
||||
'url' => 'admin/AppGroup/edit',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 52,
|
||||
'name' => '删除应用组',
|
||||
'fid' => 49,
|
||||
'url' => 'admin/AppGroup/del',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 53,
|
||||
'name' => '获取全部可用应用组',
|
||||
'fid' => 49,
|
||||
'url' => 'admin/AppGroup/getAll',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 54,
|
||||
'name' => '应用组状态编辑',
|
||||
'fid' => 49,
|
||||
'url' => 'admin/AppGroup/changeStatus',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 55,
|
||||
'name' => '菜单列表',
|
||||
'fid' => 4,
|
||||
'url' => 'admin/Menu/index',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 56,
|
||||
'name' => '用户列表',
|
||||
'fid' => 9,
|
||||
'url' => 'admin/User/index',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 57,
|
||||
'name' => '权限列表',
|
||||
'fid' => 15,
|
||||
'url' => 'admin/Auth/index',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 58,
|
||||
'name' => '应用列表',
|
||||
'fid' => 24,
|
||||
'url' => 'admin/App/index',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 59,
|
||||
'name' => '应用分组列表',
|
||||
'fid' => 49,
|
||||
'url' => 'admin/AppGroup/index',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 60,
|
||||
'name' => '接口列表',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/InterfaceList/index',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 61,
|
||||
'name' => '接口分组列表',
|
||||
'fid' => 43,
|
||||
'url' => 'admin/InterfaceGroup/index',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 62,
|
||||
'name' => '日志管理',
|
||||
'fid' => 3,
|
||||
'url' => '',
|
||||
'auth' => 0,
|
||||
'sort' => 4,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 63,
|
||||
'name' => '获取操作日志列表',
|
||||
'fid' => 62,
|
||||
'url' => 'admin/Log/index',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 64,
|
||||
'name' => '删除单条日志记录',
|
||||
'fid' => 62,
|
||||
'url' => 'admin/Log/del',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 65,
|
||||
'name' => '刷新路由',
|
||||
'fid' => 31,
|
||||
'url' => 'admin/InterfaceList/refresh',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 67,
|
||||
'name' => '文件上传',
|
||||
'fid' => 0,
|
||||
'url' => 'admin/Index/upload',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 68,
|
||||
'name' => '更新个人信息',
|
||||
'fid' => 9,
|
||||
'url' => 'admin/User/own',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 69,
|
||||
'name' => '刷新AppSecret',
|
||||
'fid' => 24,
|
||||
'url' => 'admin/App/refreshAppSecret',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 70,
|
||||
'name' => '获取用户信息',
|
||||
'fid' => 9,
|
||||
'url' => 'admin/Login/getUserInfo',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
], [
|
||||
'id' => 71,
|
||||
'name' => '编辑权限细节',
|
||||
'fid' => 15,
|
||||
'url' => 'admin/Auth/editRule',
|
||||
'auth' => 0,
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'icon' => '',
|
||||
'level' => 0
|
||||
]
|
||||
];
|
||||
|
||||
$this->table('admin_menu')->insert($data)->saveData();
|
||||
}
|
||||
}
|
47
database/migrations/20190514034923_ini_admin_group.php
Normal file
47
database/migrations/20190514034923_ini_admin_group.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
|
||||
class IniAdminGroup extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
/** INSERT INTO `admin_group` (`id`, `name`, `description`, `status`, `hash`, `addTime`, `updateTime`, `image`, `hot`)
|
||||
* VALUES
|
||||
* (1, '默认分组', '默认分组', 1, 'default', 0, 0, '', 0);
|
||||
*/
|
||||
public function up() {
|
||||
$data = [
|
||||
'name' => '默认分组',
|
||||
'description' => '默认分组',
|
||||
'status' => 1,
|
||||
'hash' => 'default',
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
'image' => '',
|
||||
'hot' => 0
|
||||
];
|
||||
|
||||
$this->table('admin_group')->insert($data)->saveData();
|
||||
}
|
||||
}
|
53
database/migrations/20190515031308_ini_admin_user.php
Normal file
53
database/migrations/20190515031308_ini_admin_user.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use think\facade\Env;
|
||||
use think\migration\Migrator;
|
||||
use \app\util\Strs;
|
||||
use \app\util\Tools;
|
||||
|
||||
class IniAdminUser extends Migrator {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function up() {
|
||||
$pass = Strs::randString(8);
|
||||
$lockFile = Env::get('app_path') . 'install' . DIRECTORY_SEPARATOR . 'lock.ini';
|
||||
$authKey = file_get_contents($lockFile);
|
||||
|
||||
$data = [
|
||||
'id' => 1,
|
||||
'username' => 'root',
|
||||
'nickname' => 'root',
|
||||
'password' => Tools::userMd5($pass, $authKey),
|
||||
'create_time' => time(),
|
||||
'create_ip' => ip2long('127.0.0.1'),
|
||||
'update_time' => time(),
|
||||
'status' => 1,
|
||||
'openid' => null
|
||||
];
|
||||
|
||||
$this->table('admin_user')->insert($data)->saveData();
|
||||
|
||||
$lockFile = Env::get('app_path') . 'install' . DIRECTORY_SEPARATOR . 'lock.ini';
|
||||
file_put_contents($lockFile, "username:root, password:{$pass}" . PHP_EOL);
|
||||
}
|
||||
}
|
39
database/migrations/20200318084219_add_admin_list_field.php
Normal file
39
database/migrations/20200318084219_add_admin_list_field.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class AddAdminListField extends Migrator {
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function up() {
|
||||
$this->table('admin_list')->addColumn('hash_type', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 2,
|
||||
'comment' => '是否采用hash映射, 1:普通模式 2:加密模式'
|
||||
])->update();
|
||||
}
|
||||
|
||||
public function down() {
|
||||
$this->table('admin_list')->removeColumn('hash_type')->update();
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class ChangeAdminMenuField extends Migrator {
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function up() {
|
||||
$this->table('admin_menu')
|
||||
->renameColumn('hide', 'show')
|
||||
->renameColumn('name', 'title')
|
||||
->changeColumn('level', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '菜单层级,1-一级菜单,2-二级菜单,3-按钮'
|
||||
])->changeColumn('auth', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '是否需要登录才可以访问,1-需要,0-不需要'
|
||||
])->changeColumn('show', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '是否显示,1-显示,0-隐藏'
|
||||
])->addColumn('component', 'string', [
|
||||
'limit' => 255,
|
||||
'default' => '',
|
||||
'comment' => '前端组件'
|
||||
])->addColumn('router', 'string', [
|
||||
'limit' => 255,
|
||||
'default' => '',
|
||||
'comment' => '前端路由'
|
||||
])->addColumn('log', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '是否记录日志,1-记录,0-不记录'
|
||||
])->addColumn('permission', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '是否验证权限,1-鉴权,0-放行'
|
||||
])->addColumn('method', 'integer', [
|
||||
'limit' => MysqlAdapter::INT_TINY,
|
||||
'default' => 1,
|
||||
'comment' => '请求方式,1-GET, 2-POST, 3-PUT, 4-DELETE'
|
||||
])->update();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
|
||||
class UpdateAdminMenuData extends Migrator {
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function up() {
|
||||
$this->execute('UPDATE `admin_menu` SET `show` = 2 WHERE `show` = 0;');
|
||||
$this->execute('UPDATE `admin_menu` SET `show` = 0 WHERE `show` = 1;');
|
||||
$this->execute('UPDATE `admin_menu` SET `show` = 1 WHERE `show` = 2;');
|
||||
$this->execute('UPDATE `admin_menu` SET `level` = 1 WHERE `fid` = 0;');
|
||||
$this->execute('UPDATE `admin_menu` SET `level` = 3 WHERE `url` != "";');
|
||||
$this->execute('UPDATE `admin_menu` SET `level` = 2 WHERE `level` = 0;');
|
||||
$this->execute('UPDATE `admin_menu` SET `auth` = 1 WHERE `url` != "admin/Login/index";');
|
||||
$this->execute('UPDATE `admin_menu` SET `method` = 2 WHERE `url` LIKE "%/upload" OR `url` LIKE "%/add" OR `url` LIKE "%/edit%";');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "ios-build", `component` = "", `router` = "/system" WHERE `id` = 3;');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "md-menu", `component` = "system/menu", `router` = "menu" WHERE `id` = 4;');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "ios-people", `component` = "system/user", `router` = "user" WHERE `id` = 9;');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "md-lock", `component` = "system/auth", `router` = "auth" WHERE `id` = 15;');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "ios-appstore", `component` = "", `router` = "/apps" WHERE `id` = 23;');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "md-list-box", `component` = "app/list", `router` = "appsList" WHERE `id` = 24;');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "ios-link", `component` = "", `router` = "/interface" WHERE `id` = 30;');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "md-infinite", `component` = "interface/list", `router` = "interfaceList" WHERE `id` = 31;');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "", `component` = "interface/request", `router` = "request/:hash" WHERE `id` = 37;');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "", `component` = "interface/response", `router` = "response/:hash" WHERE `id` = 38;');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "md-archive", `component` = "interface/group", `router` = "interfaceGroup" WHERE `id` = 43;');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "ios-archive", `component` = "app/group", `router` = "appsGroup" WHERE `id` = 49;');
|
||||
$this->execute('UPDATE `admin_menu` SET `icon` = "md-clipboard", `component` = "system/log", `router` = "log" WHERE `id` = 62;');
|
||||
$this->execute("INSERT INTO `admin_menu` (`id`, `title`, `fid`, `url`, `auth`, `sort`, `show`, `icon`, `level`, `component`, `router`, `log`, `permission`, `method`) VALUES (72, '获取用户有权限的菜单', 73, 'admin/Login/getAccessMenu', 1, 0, 0, '', 2, '', '', 0, 0, 1);");
|
||||
$this->execute("INSERT INTO `admin_menu` (`id`, `title`, `fid`, `url`, `auth`, `sort`, `show`, `icon`, `level`, `component`, `router`, `log`, `permission`, `method`) VALUES (73, '系统支撑', 0, '', 0, 0, 0, 'logo-tux', 1, '', '', 0, 0, 1);");
|
||||
$this->execute('UPDATE `admin_menu` SET `fid` = 73, `show` = 0, `level` = 2, `log` = 0, `permission` = 0, `method` = 2 WHERE `id` = 1;');
|
||||
$this->execute('UPDATE `admin_menu` SET `fid` = 73, `show` = 0, `level` = 2, `log` = 1, `permission` = 0, `method` = 1 WHERE `id` = 2;');
|
||||
$this->execute('UPDATE `admin_menu` SET `fid` = 73, `show` = 0, `level` = 2, `log` = 1, `permission` = 1, `method` = 2 WHERE `id` = 67;');
|
||||
$this->execute('UPDATE `admin_menu` SET `fid` = 73, `show` = 0, `level` = 2, `log` = 1, `permission` = 1, `method` = 2 WHERE `id` = 68;');
|
||||
$this->execute('UPDATE `admin_menu` SET `fid` = 73, `show` = 0, `level` = 2, `log` = 0, `permission` = 1, `method` = 1 WHERE `id` = 70;');
|
||||
}
|
||||
}
|
30
database/migrations/20200614170824_change_menu_fid.php
Normal file
30
database/migrations/20200614170824_change_menu_fid.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
|
||||
class ChangeMenuFid extends Migrator {
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function up() {
|
||||
$this->execute('UPDATE `admin_menu` SET `fid` = 30 WHERE `id` = 37 OR `id` = 38;');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user