diff --git a/app/admin/controller/AdminGroup.php b/app/admin/controller/AdminGroup.php index bf863f8..92b27ee 100644 --- a/app/admin/controller/AdminGroup.php +++ b/app/admin/controller/AdminGroup.php @@ -3,6 +3,7 @@ namespace app\admin\controller; use app\model\AdminGroup as AppAdminGroup; +use app\model\AdminPermission; use think\facade\View; use think\Request; @@ -16,7 +17,7 @@ class AdminGroup extends Common public function index() { // - $list = AppAdminGroup::select(); + $list = AppAdminGroup::order('id desc')->select(); View::assign('list',$list); return View::fetch(); @@ -30,7 +31,9 @@ class AdminGroup extends Common public function create() { // + $premission_list = AdminPermission::order('app,controller,action')->select(); + View::assign('permission_list',$premission_list); return View::fetch(); } @@ -43,6 +46,22 @@ class AdminGroup extends Common public function save(Request $request) { // + $post_data = $request->post(); + + $model_admin_group = AppAdminGroup::where('name',$post_data['name'])->find(); + + if(!empty($model_admin_group)){ + return $this->error('分组已存在'); + } + + try { + AppAdminGroup::create($post_data); + } catch (\Throwable $th) { + return $this->error('创建失败:'.$th->getMessage()); + } + + return $this->success('创建成功','index'); + } /** @@ -65,6 +84,14 @@ class AdminGroup extends Common public function edit($id) { // + + $model_admin_group = AppAdminGroup::find($id); + + $premission_list = AdminPermission::order('app,controller,action')->select(); + View::assign('permission_list',$premission_list); + View::assign('admin_group',$model_admin_group); + + return View::fetch(); } /** @@ -77,6 +104,16 @@ class AdminGroup extends Common public function update(Request $request, $id) { // + $model_admin_group = AppAdminGroup::find($id); + if(empty($model_admin_group)){ + return $this->error('分组不存在'); + } + + $post_data = $request->post(); + + $model_admin_group->save($post_data); + + return $this->success('修改成功','index'); } /** @@ -88,5 +125,7 @@ class AdminGroup extends Common public function delete($id) { // + AppAdminGroup::destroy($id); + $this->success('删除成功'); } } diff --git a/app/model/AdminGroup.php b/app/model/AdminGroup.php index 244190d..a09a194 100644 --- a/app/model/AdminGroup.php +++ b/app/model/AdminGroup.php @@ -13,4 +13,20 @@ class AdminGroup extends Model // use SoftDelete; protected $defaultSoftDelete = 0; + + public function getPermissionsAttr($value) + { + return \explode(',',$value); + } + + public function setPermissionsAttr($value) + { + + if(is_array($value)){ + return join(',',$value); + } + + return $value; + + } } diff --git a/app/model/AdminPermission.php b/app/model/AdminPermission.php index 95fb7a6..cf9ad53 100644 --- a/app/model/AdminPermission.php +++ b/app/model/AdminPermission.php @@ -21,4 +21,15 @@ class AdminPermission extends Model return $status[intval($value)]; } + + public function getNameAttr($value) + { + if(empty($value)){ + $value = $this->getData('app').'/'.$this->getData('controller').'/'.$this->getData('action'); + } + + return $value; + } + + } diff --git a/composer.lock b/composer.lock index 07561e2..4bc4d76 100644 --- a/composer.lock +++ b/composer.lock @@ -436,12 +436,12 @@ "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "7c7d4e0e4afb7156167a9714fdbd26b6f7aa8934" + "reference": "3f851f5d2105ea43843363093c3c945f0bdc2e3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/framework/zipball/7c7d4e0e4afb7156167a9714fdbd26b6f7aa8934", - "reference": "7c7d4e0e4afb7156167a9714fdbd26b6f7aa8934", + "url": "https://api.github.com/repos/top-think/framework/zipball/3f851f5d2105ea43843363093c3c945f0bdc2e3c", + "reference": "3f851f5d2105ea43843363093c3c945f0bdc2e3c", "shasum": "", "mirrors": [ { @@ -496,7 +496,7 @@ "orm", "thinkphp" ], - "time": "2019-09-01T11:17:14+00:00" + "time": "2019-09-16T03:49:50+00:00" }, { "name": "topthink/think-captcha", @@ -657,12 +657,12 @@ "source": { "type": "git", "url": "https://github.com/top-think/think-orm.git", - "reference": "49c18c9ba68403451031f6afac9c6091cb071115" + "reference": "759cc5848dbd3d5b9662040e135011198e882146" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-orm/zipball/49c18c9ba68403451031f6afac9c6091cb071115", - "reference": "49c18c9ba68403451031f6afac9c6091cb071115", + "url": "https://api.github.com/repos/top-think/think-orm/zipball/759cc5848dbd3d5b9662040e135011198e882146", + "reference": "759cc5848dbd3d5b9662040e135011198e882146", "shasum": "", "mirrors": [ { @@ -672,6 +672,7 @@ ] }, "require": { + "ext-json": "*", "php": ">=7.1.0", "psr/log": "~1.0", "psr/simple-cache": "^1.0", @@ -699,20 +700,20 @@ "database", "orm" ], - "time": "2019-09-02T06:01:06+00:00" + "time": "2019-09-16T01:27:31+00:00" }, { "name": "topthink/think-template", - "version": "v2.0.5", + "version": "v2.0.6", "source": { "type": "git", "url": "https://github.com/top-think/think-template.git", - "reference": "3fb2741d6921475d980d987130cf8780c99c994c" + "reference": "1db0078db13397e7271826f895f8d17279ad9e1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-template/zipball/3fb2741d6921475d980d987130cf8780c99c994c", - "reference": "3fb2741d6921475d980d987130cf8780c99c994c", + "url": "https://api.github.com/repos/top-think/think-template/zipball/1db0078db13397e7271826f895f8d17279ad9e1e", + "reference": "1db0078db13397e7271826f895f8d17279ad9e1e", "shasum": "", "mirrors": [ { @@ -742,20 +743,20 @@ } ], "description": "the php template engine", - "time": "2019-07-30T06:29:57+00:00" + "time": "2019-09-04T13:43:03+00:00" }, { "name": "topthink/think-view", - "version": "v1.0.9", + "version": "v1.0.11", "source": { "type": "git", "url": "https://github.com/top-think/think-view.git", - "reference": "3cc8afc7069d3610b5ed09faebdddcfb5c929e80" + "reference": "2110794aad592e007f2a8949c07ff50928028073" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-view/zipball/3cc8afc7069d3610b5ed09faebdddcfb5c929e80", - "reference": "3cc8afc7069d3610b5ed09faebdddcfb5c929e80", + "url": "https://api.github.com/repos/top-think/think-view/zipball/2110794aad592e007f2a8949c07ff50928028073", + "reference": "2110794aad592e007f2a8949c07ff50928028073", "shasum": "", "mirrors": [ { @@ -769,13 +770,6 @@ "topthink/think-template": "^2.0" }, "type": "library", - "extra": { - "think": { - "config": { - "template": "src/config/template.php" - } - } - }, "autoload": { "psr-4": { "think\\view\\driver\\": "src" @@ -792,7 +786,7 @@ } ], "description": "thinkphp template driver", - "time": "2019-07-30T04:10:50+00:00" + "time": "2019-09-10T14:58:31+00:00" } ], "packages-dev": [ diff --git a/view/admin/admin/admin_log.html b/view/admin/admin/admin_log.html index f7b4fdd..ec1a4f7 100644 --- a/view/admin/admin/admin_log.html +++ b/view/admin/admin/admin_log.html @@ -60,7 +60,7 @@

访问IP:{$vo.ip}

-
查看详情
+
查看详情

{$vo.param} diff --git a/view/admin/admin_group/create.html b/view/admin/admin_group/create.html index e69de29..9bb429c 100644 --- a/view/admin/admin_group/create.html +++ b/view/admin/admin_group/create.html @@ -0,0 +1,67 @@ + + + + + + + 应用管理 + {include file="common/_require"} + + + +
+ {include file="common/_header"} + + {include file="common/left_admin_manage"} + +
+ +
+
+ + 首页 + 添加分组 + +
+
+
+
+
+ 添加分组 +
+
+
+
分组名称
+
+ +
+
+
+
分组权限
+
+ {volist name='permission_list' id='vo'} + + {/volist} +
+
+
+ +
+
+
+ +
+
+
+
+
+
+ + + {include file="common/_footer"} +
+ + + \ No newline at end of file diff --git a/view/admin/admin_group/edit.html b/view/admin/admin_group/edit.html new file mode 100644 index 0000000..5de9c59 --- /dev/null +++ b/view/admin/admin_group/edit.html @@ -0,0 +1,67 @@ + + + + + + + 应用管理 + {include file="common/_require"} + + + +
+ {include file="common/_header"} + + {include file="common/left_admin_manage"} + +
+ +
+
+ + 首页 + 添加分组 + +
+
+
+
+
+ 添加分组 +
+
+
+
分组名称
+
+ +
+
+
+
分组权限
+
+ {volist name='permission_list' id='vo'} + + {/volist} +
+
+
+ +
+
+
+ +
+
+
+
+
+
+ + + {include file="common/_footer"} +
+ + + \ No newline at end of file diff --git a/view/admin/admin_group/index.html b/view/admin/admin_group/index.html index d04d249..08fe80f 100644 --- a/view/admin/admin_group/index.html +++ b/view/admin/admin_group/index.html @@ -39,7 +39,18 @@ - + {volist name='list' id='vo'} + + {$vo.id} + {$vo.name} + +
+ 编辑 +
删除
+
+ + + {/volist} {if condition="count($list) eq 0" } 暂无数据 @@ -54,6 +65,20 @@ {include file="common/_footer"} + + \ No newline at end of file