所有待办完成

This commit is contained in:
augushong
2019-10-10 21:26:16 +08:00
parent 44da234f53
commit b3c046e1c7
14 changed files with 525 additions and 26 deletions

View File

@@ -28,7 +28,7 @@ class CreateTableUploadFiles extends Migrator
*/
public function change()
{
$table = $this->table('upload_files',['comment'=>'上传的文件']);
$table = $this->table('upload_files',['comment'=>'上传的文件','signed'=>false]);
$table->addColumn('save_name','string',['limit'=>100,'comment'=>'文件存储地址']);
$table->addColumn('file_name','string',['limit'=>100,'comment'=>'文件原始名称']);
$table->addColumn('mime_type','string',['limit'=>30,'comment'=>'mime type 类型']);
@@ -41,12 +41,14 @@ class CreateTableUploadFiles extends Migrator
$table->addColumn('delete_time','integer',['limit'=>10,'comment'=>'删除时间']);
$table->addColumn('clear_time','integer',['limit'=>10,'comment'=>'清空时间']);
$table->addColumn('type','integer',['limit'=>2,'default'=>1,'comment'=>'文件类型1系统logo;2:管理员头像']);
$table->addColumn('status','integer',['limit'=>2,'default'=>0,'comment'=>'文件状态:0,上传未使用,1:已使用,2:已删除,3已清除']);
$table->addIndex('save_name');
$table->addIndex('create_time');
$table->addIndex('used_time');
$table->addIndex('delete_time');
$table->addIndex('clear_time');
$table->addIndex('type');
$table->addIndex('status');
$table->create();

View File

@@ -28,10 +28,10 @@ class CreateTableSystemConfig extends Migrator
*/
public function change()
{
$table = $this->table('system_config',['comment'=>'系统配置表']);
$table = $this->table('system_config',['comment'=>'系统配置表','signed'=>false]);
$table->addColumn('name','string',['limit'=>30,'comment'=>'配置名称']);
$table->addColumn('value','string',['limit'=>500,'comment'=>'值']);
$table->addColumn('value','text',['comment'=>'值']);
$table->addIndex('name');
$table->save();
$table->create();
}
}

View File

@@ -0,0 +1,43 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class CreateTableAdminGroup 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 change()
{
$table = $this->table('admin_group',[
'comment'=>'管理员组',
'signed'=>false
]);
$table->addColumn('name','string',['limit'=>20,'comment'=>'组名']);
$table->addColumn('create_time','integer',['limit'=>11,'default'=>0,'comment'=>'添加时间']);
$table->addColumn('update_time','integer',['limit'=>11,'default'=>0,'comment'=>'更新时间']);
$table->addColumn('delete_time','integer',['limit'=>11,'default'=>0,'comment'=>'删除时间']);
$table->addColumn('permissions','text',['comment'=>'拥有权限']);
$table->create();
}
}

View File

@@ -0,0 +1,53 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class CreateTableAdminLog 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 change()
{
$table = $this->table('admin_log',[
'comment'=>'管理员日志',
'signed'=>false
]);
$table->addColumn('app','string',['limit'=>50,'comment'=>'应用名']);
$table->addColumn('controller','string',['limit'=>50,'comment'=>'控制器名']);
$table->addColumn('action','string',['limit'=>50,'comment'=>'方法名']);
$table->addColumn('param','text',['comment'=>'参数']);
$table->addColumn('create_time','integer',['limit'=>11,'default'=>0,'comment'=>'添加时间']);
$table->addColumn('delete_time','integer',['limit'=>11,'default'=>0,'comment'=>'删除时间']);
$table->addColumn('admin_id','integer',['limit'=>20,'default'=>0,'comment'=>'管理员id']);
$table->addColumn('ip','string',['limit'=>30,'default'=>'','comment'=>'客户端ip']);
$table->addIndex('app');
$table->addIndex('controller');
$table->addIndex('action');
$table->addIndex('delete_time');
$table->addIndex('admin_id');
$table->create();
}
}

View File

@@ -0,0 +1,47 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class CreateTableAdminPermission 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 change()
{
$table = $this->table('admin_permission',[
'comment'=>'后台权限记录',
'signed'=>false
]);
$table->addColumn('name','string',['limit'=>20,'default'=>'0','comment'=>'权限名称']);
$table->addColumn('app','string',['limit'=>50,'comment'=>'应用名']);
$table->addColumn('controller','string',['limit'=>50,'comment'=>'控制器名']);
$table->addColumn('action','string',['limit'=>50,'comment'=>'方法名']);
$table->addColumn('is_log','integer',['limit'=>1,'default'=>0,'comment'=>'是否把这个访问记录下来']);
$table->addIndex('app');
$table->addIndex('controller');
$table->addIndex('action');
$table->addIndex('is_log');
$table->create();
}
}

View File

@@ -0,0 +1,46 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class CreateTableUser 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 change()
{
$table = $this->table('user',['comment'=>'用户表','signed'=>false]);
$table->addColumn('account','string',['limit'=>20,'comment'=>'用户帐号']);
$table->addColumn('password','string',['limit'=>32,'comment'=>'密码']);
$table->addColumn('salt','string',['limit'=>6,'comment'=>'密码盐']);
$table->addColumn('nickname','string',['limit'=>10,'comment'=>'昵称']);
$table->addColumn('avatar','string',['limit'=>40,'comment'=>'头像地址']);
$table->addColumn('create_time','integer',['limit'=>10,'default'=>0,'comment'=>'添加时间']);
$table->addColumn('update_time','integer',['limit'=>10,'default'=>0,'comment'=>'更新时间']);
$table->addColumn('delete_time','integer',['limit'=>10,'default'=>0,'comment'=>'删除时间']);
$table->addColumn('last_login_time','integer',['limit'=>10,'default'=>0,'comment'=>'最后一次登陆时间']);
$table->addColumn('status','integer',['limit'=>1,'default'=>0,'comment'=>'状态']);
$table->addIndex('account');
$table->addIndex('delete_time');
$table->create();
}
}

View File

@@ -0,0 +1,262 @@
<?php
use think\migration\Seeder;
class InitAdminPermission extends Seeder
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* http://docs.phinx.org/en/latest/seeding.html
*/
public function run()
{
$permission_content = '
[
{
"id" : 3,
"name" : "系统设置",
"app" : "admin",
"controller" : "System",
"action" : "index",
"is_log" : 1
},
{
"id" : 9,
"name" : "系统第三方设置",
"app" : "admin",
"controller" : "System",
"action" : "others",
"is_log" : 1
},
{
"id" : 12,
"name" : "登录页面",
"app" : "admin",
"controller" : "Login",
"action" : "index",
"is_log" : 1
},
{
"id" : 13,
"name" : "登录验证",
"app" : "admin",
"controller" : "Login",
"action" : "auth",
"is_log" : 1
},
{
"id" : 18,
"name" : "退出",
"app" : "admin",
"controller" : "Login",
"action" : "logout",
"is_log" : 1
},
{
"id" : 21,
"name" : "系统设置更新",
"app" : "admin",
"controller" : "System",
"action" : "update",
"is_log" : 1
},
{
"id" : 24,
"name" : "管理员权限-删除",
"app" : "admin",
"controller" : "AdminPermission",
"action" : "delete",
"is_log" : 0
},
{
"id" : 25,
"name" : "管理员权限-列表",
"app" : "admin",
"controller" : "AdminPermission",
"action" : "index",
"is_log" : 0
},
{
"id" : 26,
"name" : "后台首页",
"app" : "admin",
"controller" : "Index",
"action" : "index",
"is_log" : 0
},
{
"id" : 27,
"name" : "管理员分组-列表",
"app" : "admin",
"controller" : "AdminGroup",
"action" : "index",
"is_log" : 0
},
{
"id" : 29,
"name" : "文件-列表",
"app" : "admin",
"controller" : "File",
"action" : "index",
"is_log" : 0
},
{
"id" : 30,
"name" : "管理员帐号-列表",
"app" : "admin",
"controller" : "Admin",
"action" : "index",
"is_log" : 1
},
{
"id" : 31,
"name" : "管理员权限-保存编辑",
"app" : "admin",
"controller" : "AdminPermission",
"action" : "update",
"is_log" : 0
},
{
"id" : 32,
"name" : "管理员-编辑(登陆的人自己改自己)",
"app" : "admin",
"controller" : "Admin",
"action" : "edit",
"is_log" : 0
},
{
"id" : 33,
"name" : "管理员日志-列表",
"app" : "admin",
"controller" : "Admin",
"action" : "adminLog",
"is_log" : 0
},
{
"id" : 34,
"name" : "管理员-改密码(自己改自己)",
"app" : "admin",
"controller" : "Admin",
"action" : "password",
"is_log" : 0
},
{
"id" : 35,
"name" : "管理员分组-添加",
"app" : "admin",
"controller" : "AdminGroup",
"action" : "create",
"is_log" : 0
},
{
"id" : 36,
"name" : "管理员分组-保存添加",
"app" : "admin",
"controller" : "AdminGroup",
"action" : "save",
"is_log" : 0
},
{
"id" : 37,
"name" : "管理员分组-删除",
"app" : "admin",
"controller" : "AdminGroup",
"action" : "delete",
"is_log" : 0
},
{
"id" : 38,
"name" : "管理员分组-编辑",
"app" : "admin",
"controller" : "AdminGroup",
"action" : "edit",
"is_log" : 0
},
{
"id" : 39,
"name" : "管理员分组-保存编辑",
"app" : "admin",
"controller" : "AdminGroup",
"action" : "update",
"is_log" : 0
},
{
"id" : 40,
"name" : "管理员-保存更新",
"app" : "admin",
"controller" : "Admin",
"action" : "update",
"is_log" : 0
},
{
"id" : 41,
"name" : "文件-磁盘清空",
"app" : "admin",
"controller" : "File",
"action" : "clear",
"is_log" : 0
},
{
"id" : 42,
"name" : "管理员帐号-添加",
"app" : "admin",
"controller" : "Admin",
"action" : "create",
"is_log" : 0
},
{
"id" : 43,
"name" : "管理员帐号-保存添加",
"app" : "admin",
"controller" : "Admin",
"action" : "save",
"is_log" : 0
},
{
"id" : 45,
"name" : "管理员帐号-编辑",
"app" : "admin",
"controller" : "Admin",
"action" : "editAccount",
"is_log" : 0
},
{
"id" : 46,
"name" : "管理员帐号-删除",
"app" : "admin",
"controller" : "Admin",
"action" : "delete",
"is_log" : 0
},
{
"id" : 47,
"name" : "管理员帐号-保存编辑",
"app" : "admin",
"controller" : "Admin",
"action" : "updateAccount",
"is_log" : 0
}
]
';
$permissions = json_decode($permission_content);
foreach ($permissions as $permission) {
$current_access_info = [
'app'=>$permission['app'],
'controller'=>$permission['controller'],
'action'=>$permission['action'],
];
$model_permission = AdminPermission::where($current_access_info)->find();
if(empty($model_permission)){
$current_access_info['name'] = $permissions['name'];
AdminPermission::create($current_access_info);
}
}
}
}