diff --git a/.gitignore b/.gitignore index d465120..0c60eea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.idea /.vscode /vendor +/database *.log .env \ No newline at end of file diff --git a/catchAdmin/permissions/controller/Permissions.php b/catchAdmin/permissions/controller/Permissions.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/catchAdmin/permissions/controller/Permissions.php @@ -0,0 +1 @@ +table('roles',['engine'=>'Innodb', 'comment' => '角色表', 'signed' => false]); + $table->addColumn('name', 'string',['limit' => 15,'default'=>'','comment'=>'角色名']) + ->addColumn('parent_id', 'integer',['default'=>0,'comment'=>'父级ID', 'signed' => false]) + ->addColumn('description', 'string',['default'=> '','comment'=>'角色备注']) + ->addColumn('created_at', 'integer', array('default'=>0,'comment'=>'创建时间', 'signed' => false )) + ->addColumn('updated_at', 'integer', array('default'=>0,'comment'=>'更新时间', 'signed' => false)) + ->addColumn('deleted_at', 'integer', array('null'=>true,'comment'=>'删除状态,0未删除 >0 已删除', 'signed' => false)) + ->create(); + } +} diff --git a/catchAdmin/permissions/database/migrations/20191208125726_permissions.php b/catchAdmin/permissions/database/migrations/20191208125726_permissions.php new file mode 100644 index 0000000..373297b --- /dev/null +++ b/catchAdmin/permissions/database/migrations/20191208125726_permissions.php @@ -0,0 +1,44 @@ +table('roles',['engine'=>'Innodb', 'comment' => '菜单表', 'signed' => false]); + $table->addColumn('name', 'string',['limit' => 15,'default'=>'','comment'=>'菜单名称']) + ->addColumn('parent_id', 'integer',['default'=>0,'comment'=>'父级ID', 'signed' => false]) + ->addColumn('route', 'string', ['default' => '', 'comment' => '路由', 'limit' => 50]) + ->addColumn('permission_mark', 'string', ['null' => false, 'comment' => '权限标识', 'limit' => 50]) + ->addColumn('type', 'integer',['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY,'default'=> 1,'comment'=>'1 菜单 2 按钮']) + ->addColumn('sort', 'integer',['default'=> 0,'comment'=>'排序字段']) + ->addColumn('created_at', 'integer', array('default'=>0,'comment'=>'创建时间', 'signed' => false )) + ->addColumn('updated_at', 'integer', array('default'=>0,'comment'=>'更新时间', 'signed' => false)) + ->addColumn('deleted_at', 'integer', array('null'=>true,'comment'=>'删除状态,null 未删除 timestamp 已删除', 'signed' => false)) + ->create(); + + } +} diff --git a/catchAdmin/permissions/database/migrations/20191208131107_user_has_roles.php b/catchAdmin/permissions/database/migrations/20191208131107_user_has_roles.php new file mode 100644 index 0000000..55d8450 --- /dev/null +++ b/catchAdmin/permissions/database/migrations/20191208131107_user_has_roles.php @@ -0,0 +1,36 @@ +table('user_has_roles',['engine'=>'Innodb', 'comment' => '用户角色表', 'signed' => false]); + $table->addColumn('uid', 'integer',['comment'=>'用户ID', 'signed' => false]) + ->addColumn('role_id', 'integer', ['comment'=>'角色ID', 'signed' => false]) + ->create(); + } +} diff --git a/catchAdmin/permissions/database/migrations/20191208131115_role_has_permissions.php b/catchAdmin/permissions/database/migrations/20191208131115_role_has_permissions.php new file mode 100644 index 0000000..c31c58b --- /dev/null +++ b/catchAdmin/permissions/database/migrations/20191208131115_role_has_permissions.php @@ -0,0 +1,36 @@ +table('role_has_permissions',['engine'=>'Innodb', 'comment' => '角色权限表', 'signed' => false]); + $table->addColumn('role_id', 'integer',['comment'=>'角色ID', 'signed' => false]) + ->addColumn('permission_id', 'integer', ['comment'=>'权限ID', 'signed' => false]) + ->create(); + } +} diff --git a/catchAdmin/permissions/model/HasRolesTrait.php b/catchAdmin/permissions/model/HasRolesTrait.php new file mode 100644 index 0000000..aa5800b --- /dev/null +++ b/catchAdmin/permissions/model/HasRolesTrait.php @@ -0,0 +1,50 @@ +belongsToMany(Roles::class, 'user_has_roles', 'user_id', 'role_id'); + } + + /** + * + * @time 2019年12月08日 + * @param $uid + * @return mixed + */ + public function getRoles($uid) + { + return $this->findBy($uid)->roles()->get(); + } + + /** + * + * @time 2019年12月08日 + * @param $uid + * @param array $roles + * @return mixed + */ + public function attach($uid, array $roles) + { + return $this->findBy($uid)->roles()->attach($roles); + } + + /** + * + * @time 2019年12月08日 + * @param $uid + * @param array $roles + * @return mixed + */ + public function detach($uid, array $roles) + { + return $this->findBy($uid)->roles()->detach($roles); + } +} \ No newline at end of file diff --git a/catchAdmin/permissions/view/roles/create.html b/catchAdmin/permissions/view/roles/create.html new file mode 100644 index 0000000..566549b --- /dev/null +++ b/catchAdmin/permissions/view/roles/create.html @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file diff --git a/catchAdmin/permissions/view/roles/index.html b/catchAdmin/permissions/view/roles/index.html new file mode 100644 index 0000000..566549b --- /dev/null +++ b/catchAdmin/permissions/view/roles/index.html @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file diff --git a/extend/catcher/Form.php b/extend/catcher/Form.php deleted file mode 100644 index 383c8eb..0000000 --- a/extend/catcher/Form.php +++ /dev/null @@ -1,7 +0,0 @@ -