diff --git a/catchAdmin/index/view/index.html b/catchAdmin/index/view/index.html
index 0d59d0d..fa6325a 100644
--- a/catchAdmin/index/view/index.html
+++ b/catchAdmin/index/view/index.html
@@ -84,7 +84,7 @@
权限管理
- 用户管理
- - 角色管理
+ - 角色管理
- 菜单管理
- 登录日志
diff --git a/catchAdmin/permissions/controller/Roles.php b/catchAdmin/permissions/controller/Roles.php
index b3d9bbc..02b4c0a 100644
--- a/catchAdmin/permissions/controller/Roles.php
+++ b/catchAdmin/permissions/controller/Roles.php
@@ -1 +1,79 @@
role = $role;
+ }
+
+ /**
+ *
+ * @time 2019年12月09日
+ * @throws \Exception
+ * @return string
+ */
+ public function index()
+ {
+ return $this->fetch();
+ }
+
+ public function roles()
+ {
+
+ }
+
+ public function create()
+ {
+ $form = new CatchForm();
+ $form->formId('roles');
+ $form->text('name', '角色名称');
+ $form->formBtn('submitRoles');
+
+ return $this->fetch([
+ 'form' => $form->render()
+ ]);
+ }
+
+ public function save()
+ {}
+
+ public function read($id)
+ {
+
+ }
+
+ public function edit($id)
+ {
+ $form = new CatchForm();
+ $form->formId('roles');
+ $form->text('name', '角色名称');
+ $form->formBtn('submitRoles');
+
+ return $this->fetch([
+ 'form' => $form->render()
+ ]);
+ }
+
+ public function update($id, UpdateRequest $request)
+ {
+ }
+
+ public function delete($id)
+ {
+ return CatchResponse::success($this->role->deleteBy($id));
+ }
+
+ public function list(Request $request)
+ {
+ return CatchResponse::paginate($this->role->getList($request->param()));
+ }
+}
\ No newline at end of file
diff --git a/catchAdmin/permissions/database/migrations/20191208125726_permissions.php b/catchAdmin/permissions/database/migrations/20191208125726_permissions.php
index 373297b..5db13c9 100644
--- a/catchAdmin/permissions/database/migrations/20191208125726_permissions.php
+++ b/catchAdmin/permissions/database/migrations/20191208125726_permissions.php
@@ -28,7 +28,7 @@ class Permissions extends Migrator
*/
public function change()
{
- $table = $this->table('roles',['engine'=>'Innodb', 'comment' => '菜单表', 'signed' => false]);
+ $table = $this->table('permissions',['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])
diff --git a/catchAdmin/permissions/model/HasRolesTrait.php b/catchAdmin/permissions/model/HasRolesTrait.php
index aa5800b..03ec27b 100644
--- a/catchAdmin/permissions/model/HasRolesTrait.php
+++ b/catchAdmin/permissions/model/HasRolesTrait.php
@@ -1,7 +1,7 @@
belongsToMany(Roles::class, 'role_has_permissions');
+ }
+}
\ No newline at end of file
diff --git a/catchAdmin/permissions/model/Roles.php b/catchAdmin/permissions/model/Roles.php
new file mode 100644
index 0000000..f17b2ea
--- /dev/null
+++ b/catchAdmin/permissions/model/Roles.php
@@ -0,0 +1,83 @@
+0 已删除
+
+ ];
+
+ public function getList($search)
+ {
+ return $this->when($search['name'] ?? false, function ($query) use ($search){
+ $query->whereLike('name', $search['name']);
+ })->paginate($search['limit'] ?? $this->limit);
+ }
+
+ /**
+ *
+ * @time 2019年12月08日
+ * @return \think\model\relation\BelongsToMany
+ */
+ public function users(): \think\model\relation\BelongsToMany
+ {
+ return $this->belongsToMany(Users::class, 'user_has_roles');
+ }
+
+ /**
+ *
+ * @time 2019年12月09日
+ * @return \think\model\relation\BelongsToMany
+ */
+ public function permissions(): \think\model\relation\BelongsToMany
+ {
+ return $this->belongsToMany(Permissions::class, 'role_has_permissions', 'role_id', 'permission_id');
+ }
+
+ /**
+ *
+ * @time 2019年12月08日
+ * @param $rid
+ * @return mixed
+ */
+ public function getRoles($rid)
+ {
+ return $this->findBy($rid)->permissions()->get();
+ }
+
+ /**
+ *
+ * @time 2019年12月08日
+ * @param $rid
+ * @param array $roles
+ * @return mixed
+ */
+ public function attach($rid, array $roles)
+ {
+ return $this->findBy($rid)->permissions()->attach($roles);
+ }
+
+ /**
+ *
+ * @time 2019年12月08日
+ * @param $rid
+ * @param array $roles
+ * @return mixed
+ */
+ public function detach($rid, array $roles)
+ {
+ return $this->findBy($rid)->permissions()->detach($roles);
+ }
+}
\ No newline at end of file
diff --git a/catchAdmin/permissions/route.php b/catchAdmin/permissions/route.php
index b3d9bbc..1aab024 100644
--- a/catchAdmin/permissions/route.php
+++ b/catchAdmin/permissions/route.php
@@ -1 +1,4 @@
resource('role', '\catchAdmin\permissions\controller\Roles');
+// 用户列表
+$router->get('roles', '\catchAdmin\permissions\controller\Roles/list');
diff --git a/catchAdmin/permissions/view/roles/create.html b/catchAdmin/permissions/view/roles/create.html
index 566549b..590c7a1 100644
--- a/catchAdmin/permissions/view/roles/create.html
+++ b/catchAdmin/permissions/view/roles/create.html
@@ -1,10 +1 @@
-
-
-
-
- Title
-
-
-
-
-
\ No newline at end of file
+{$form|raw}
\ No newline at end of file
diff --git a/catchAdmin/permissions/view/roles/index.html b/catchAdmin/permissions/view/roles/index.html
index 566549b..d14b400 100644
--- a/catchAdmin/permissions/view/roles/index.html
+++ b/catchAdmin/permissions/view/roles/index.html
@@ -1,10 +1,159 @@
-
-
-
-
- Title
-
-
+{extend name="../../../view/layout"}
+{block name="title"}角色管理{/block}
+{block name="search"}
+
+{/block}
+{block name="table"}
+
+
+
+{/block}
+{block name="script"}
+
+{/block}
\ No newline at end of file
diff --git a/catchAdmin/user/model/Users.php b/catchAdmin/user/model/Users.php
index db8450f..db2b8f0 100644
--- a/catchAdmin/user/model/Users.php
+++ b/catchAdmin/user/model/Users.php
@@ -1,10 +1,13 @@
when($search['username'] ?? false, function ($query) use ($search){
return $query->whereLike('username', $search['username']);
diff --git a/config/route.php b/config/route.php
index 955eeec..8d9b272 100644
--- a/config/route.php
+++ b/config/route.php
@@ -7,11 +7,11 @@ return [
// pathinfo分隔符
'pathinfo_depr' => '/',
// URL伪静态后缀
- 'url_html_suffix' => 'html',
+ 'url_html_suffix' => '',
// URL普通方式参数 用于自动生成
'url_common_param' => true,
// 是否开启路由延迟解析
- 'url_lazy_route' => false,
+ 'url_lazy_route' => true,
// 是否强制使用路由
'url_route_must' => false,
// 合并路由规则
diff --git a/database/migrations/20191128114204_any_class_name_you_want.php b/database/migrations/20191128114204_any_class_name_you_want.php
deleted file mode 100644
index 67a90d7..0000000
--- a/database/migrations/20191128114204_any_class_name_you_want.php
+++ /dev/null
@@ -1,33 +0,0 @@
-app->getRootPath() . '.env')) {
return false;
@@ -140,33 +141,16 @@ class InstallCommand extends Command
*/
protected function secondStep(): void
{
- $modulePaths = glob(root_path('module') . '*');
+ $php = getenv('_');
- $this->checkRootDatabase();
+ $think = root_path() . DIRECTORY_SEPARATOR . 'think';
- foreach ($modulePaths as $path) {
- if (is_dir($path)) {
- $moduleDatabasePath = $path . DIRECTORY_SEPARATOR . 'database' . DIRECTORY_SEPARATOR;
- if (is_dir($moduleDatabasePath)) {
- if (is_dir($moduleDatabasePath . 'migrations' . DIRECTORY_SEPARATOR)) {
- $migrationFiles = glob($moduleDatabasePath . 'migrations' . DIRECTORY_SEPARATOR . '*.php');
- foreach ($migrationFiles as $file) {
- copy($file,
- root_path('database') . 'migrations'. DIRECTORY_SEPARATOR .
- pathinfo($file, PATHINFO_BASENAME));
- }
- }
+ foreach (CatchAdmin::getModulesDirectory() as $directory) {
+ $moduleInfo = CatchAdmin::getModuleInfo($directory);
- if (is_dir($moduleDatabasePath . 'seeds' . DIRECTORY_SEPARATOR)) {
- $seedFiles = glob($moduleDatabasePath . 'seeds' . DIRECTORY_SEPARATOR . '*.php');
- foreach ($seedFiles as $file) {
- copy($file,
- root_path('database') . 'seeds' . DIRECTORY_SEPARATOR .
- pathinfo($file, PATHINFO_BASENAME));
- }
- }
- }
- }
+ $this->output->info(
+ sprintf('module [%s] migrations ', $moduleInfo['alias']) .
+ exec(sprintf('%s %s catch-migrate:run %s', $php, $think, $moduleInfo['alias'])));
}
}
@@ -190,9 +174,7 @@ class InstallCommand extends Command
protected function finished(): void
{
// todo something
- if ($this->dataInstall) {
- rmdir($this->app->getRootPath() . 'database');
- }
+
}
/**
@@ -241,23 +223,11 @@ class InstallCommand extends Command
if ($this->getEnvFile()) {
$this->output->info('env file has been generated');
}
-
if ((new \mysqli($host, $username, $password, null, $port))->query(sprintf('CREATE DATABASE IF NOT EXISTS %s DEFAULT CHARSET %s COLLATE %s_general_ci;',
$database, $charset, $charset))) {
$this->output->info(sprintf('🎉 create database %s successfully', $database));
-
- exec(sprintf('%s %s migrate:run', getenv('_'), root_path() . DIRECTORY_SEPARATOR . 'think'));
-
- $this->output->info('🎉 database table install successfully');
-
- exec(sprintf('%s %s seed:run', getenv('_'),root_path() . DIRECTORY_SEPARATOR . 'think'));
-
- $this->output->info('🎉 Fill database table successfully ');
} else {
- $this->dataInstall = false;
- $this->output->warning(sprintf('create database %s failed, you should create it by yourself', $database));
- $this->output->warning('you should use `php think migrate:run` to create tables');
- $this->output->warning('you should use `php think seed:run` to fill tables data');
+ $this->output->warning(sprintf('create database %s failed,you need create database first by yourself', $database));
}
}
diff --git a/extend/catcher/command/ModelGeneratorCommand.php b/extend/catcher/command/ModelGeneratorCommand.php
index 66e68e1..4595a71 100644
--- a/extend/catcher/command/ModelGeneratorCommand.php
+++ b/extend/catcher/command/ModelGeneratorCommand.php
@@ -80,9 +80,9 @@ class ModelGeneratorCommand extends Command