mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-09 11:32:48 +08:00
完成日志管理和管理员分组管理
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
use app\model\AdminGroup as AppAdminGroup;
|
use app\model\AdminGroup as AppAdminGroup;
|
||||||
|
use app\model\AdminPermission;
|
||||||
use think\facade\View;
|
use think\facade\View;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ class AdminGroup extends Common
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
$list = AppAdminGroup::select();
|
$list = AppAdminGroup::order('id desc')->select();
|
||||||
View::assign('list',$list);
|
View::assign('list',$list);
|
||||||
|
|
||||||
return View::fetch();
|
return View::fetch();
|
||||||
@@ -30,7 +31,9 @@ class AdminGroup extends Common
|
|||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
$premission_list = AdminPermission::order('app,controller,action')->select();
|
||||||
|
|
||||||
|
View::assign('permission_list',$premission_list);
|
||||||
return View::fetch();
|
return View::fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +46,22 @@ class AdminGroup extends Common
|
|||||||
public function save(Request $request)
|
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)
|
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)
|
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)
|
public function delete($id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
AppAdminGroup::destroy($id);
|
||||||
|
$this->success('删除成功');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,20 @@ class AdminGroup extends Model
|
|||||||
//
|
//
|
||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
protected $defaultSoftDelete = 0;
|
protected $defaultSoftDelete = 0;
|
||||||
|
|
||||||
|
public function getPermissionsAttr($value)
|
||||||
|
{
|
||||||
|
return \explode(',',$value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPermissionsAttr($value)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(is_array($value)){
|
||||||
|
return join(',',$value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,4 +21,15 @@ class AdminPermission extends Model
|
|||||||
|
|
||||||
return $status[intval($value)];
|
return $status[intval($value)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getNameAttr($value)
|
||||||
|
{
|
||||||
|
if(empty($value)){
|
||||||
|
$value = $this->getData('app').'/'.$this->getData('controller').'/'.$this->getData('action');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
44
composer.lock
generated
44
composer.lock
generated
@@ -436,12 +436,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/top-think/framework.git",
|
"url": "https://github.com/top-think/framework.git",
|
||||||
"reference": "7c7d4e0e4afb7156167a9714fdbd26b6f7aa8934"
|
"reference": "3f851f5d2105ea43843363093c3c945f0bdc2e3c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/top-think/framework/zipball/7c7d4e0e4afb7156167a9714fdbd26b6f7aa8934",
|
"url": "https://api.github.com/repos/top-think/framework/zipball/3f851f5d2105ea43843363093c3c945f0bdc2e3c",
|
||||||
"reference": "7c7d4e0e4afb7156167a9714fdbd26b6f7aa8934",
|
"reference": "3f851f5d2105ea43843363093c3c945f0bdc2e3c",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@@ -496,7 +496,7 @@
|
|||||||
"orm",
|
"orm",
|
||||||
"thinkphp"
|
"thinkphp"
|
||||||
],
|
],
|
||||||
"time": "2019-09-01T11:17:14+00:00"
|
"time": "2019-09-16T03:49:50+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "topthink/think-captcha",
|
"name": "topthink/think-captcha",
|
||||||
@@ -657,12 +657,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/top-think/think-orm.git",
|
"url": "https://github.com/top-think/think-orm.git",
|
||||||
"reference": "49c18c9ba68403451031f6afac9c6091cb071115"
|
"reference": "759cc5848dbd3d5b9662040e135011198e882146"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/top-think/think-orm/zipball/49c18c9ba68403451031f6afac9c6091cb071115",
|
"url": "https://api.github.com/repos/top-think/think-orm/zipball/759cc5848dbd3d5b9662040e135011198e882146",
|
||||||
"reference": "49c18c9ba68403451031f6afac9c6091cb071115",
|
"reference": "759cc5848dbd3d5b9662040e135011198e882146",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@@ -672,6 +672,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
"ext-json": "*",
|
||||||
"php": ">=7.1.0",
|
"php": ">=7.1.0",
|
||||||
"psr/log": "~1.0",
|
"psr/log": "~1.0",
|
||||||
"psr/simple-cache": "^1.0",
|
"psr/simple-cache": "^1.0",
|
||||||
@@ -699,20 +700,20 @@
|
|||||||
"database",
|
"database",
|
||||||
"orm"
|
"orm"
|
||||||
],
|
],
|
||||||
"time": "2019-09-02T06:01:06+00:00"
|
"time": "2019-09-16T01:27:31+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "topthink/think-template",
|
"name": "topthink/think-template",
|
||||||
"version": "v2.0.5",
|
"version": "v2.0.6",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/top-think/think-template.git",
|
"url": "https://github.com/top-think/think-template.git",
|
||||||
"reference": "3fb2741d6921475d980d987130cf8780c99c994c"
|
"reference": "1db0078db13397e7271826f895f8d17279ad9e1e"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/top-think/think-template/zipball/3fb2741d6921475d980d987130cf8780c99c994c",
|
"url": "https://api.github.com/repos/top-think/think-template/zipball/1db0078db13397e7271826f895f8d17279ad9e1e",
|
||||||
"reference": "3fb2741d6921475d980d987130cf8780c99c994c",
|
"reference": "1db0078db13397e7271826f895f8d17279ad9e1e",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@@ -742,20 +743,20 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "the php template engine",
|
"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",
|
"name": "topthink/think-view",
|
||||||
"version": "v1.0.9",
|
"version": "v1.0.11",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/top-think/think-view.git",
|
"url": "https://github.com/top-think/think-view.git",
|
||||||
"reference": "3cc8afc7069d3610b5ed09faebdddcfb5c929e80"
|
"reference": "2110794aad592e007f2a8949c07ff50928028073"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/top-think/think-view/zipball/3cc8afc7069d3610b5ed09faebdddcfb5c929e80",
|
"url": "https://api.github.com/repos/top-think/think-view/zipball/2110794aad592e007f2a8949c07ff50928028073",
|
||||||
"reference": "3cc8afc7069d3610b5ed09faebdddcfb5c929e80",
|
"reference": "2110794aad592e007f2a8949c07ff50928028073",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@@ -769,13 +770,6 @@
|
|||||||
"topthink/think-template": "^2.0"
|
"topthink/think-template": "^2.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
|
||||||
"think": {
|
|
||||||
"config": {
|
|
||||||
"template": "src/config/template.php"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"think\\view\\driver\\": "src"
|
"think\\view\\driver\\": "src"
|
||||||
@@ -792,7 +786,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "thinkphp template driver",
|
"description": "thinkphp template driver",
|
||||||
"time": "2019-07-30T04:10:50+00:00"
|
"time": "2019-09-10T14:58:31+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
<p>访问IP:{$vo.ip}</p>
|
<p>访问IP:{$vo.ip}</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="layui-btn layui-btn-sm" onclick="layer.open({type:1,area:['400px','600px'],content:$(this).parents('tr').data('param')})">查看详情</div>
|
<div class="layui-btn layui-btn-sm" onclick="layer.open({type:1,area:['400px','600px'],content:JSON.stringify($(this).parents('tr').data('param'))})">查看详情</div>
|
||||||
<br>
|
<br>
|
||||||
{$vo.param}
|
{$vo.param}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>应用管理</title>
|
||||||
|
{include file="common/_require"}
|
||||||
|
</head>
|
||||||
|
<body class="layui-layout-body">
|
||||||
|
|
||||||
|
<div class="layui-layout layui-layout-admin">
|
||||||
|
{include file="common/_header"}
|
||||||
|
|
||||||
|
{include file="common/left_admin_manage"}
|
||||||
|
|
||||||
|
<div class="layui-body">
|
||||||
|
|
||||||
|
<div style="padding:15px">
|
||||||
|
<div class="main-header">
|
||||||
|
<span class="layui-breadcrumb">
|
||||||
|
<a>首页</a>
|
||||||
|
<a><cite>添加分组</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="main-container">
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<fieldset class="layui-elem-field">
|
||||||
|
<legend>添加分组</legend>
|
||||||
|
<div class="layui-field-box">
|
||||||
|
<form action="{:url('save')}" class="layui-form" method="POST" >
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">分组名称</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="name" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">分组权限</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
{volist name='permission_list' id='vo'}
|
||||||
|
<input type="checkbox" name="permissions[]" title="{$vo.name}" value="{$vo.id}" lay-skin="primary" checked>
|
||||||
|
{/volist}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<button class="layui-btn layui-btn-fluid" type="submit">创建分组</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</legend>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{include file="common/_footer"}
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
layui.use(['form'])
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
67
view/admin/admin_group/edit.html
Normal file
67
view/admin/admin_group/edit.html
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>应用管理</title>
|
||||||
|
{include file="common/_require"}
|
||||||
|
</head>
|
||||||
|
<body class="layui-layout-body">
|
||||||
|
|
||||||
|
<div class="layui-layout layui-layout-admin">
|
||||||
|
{include file="common/_header"}
|
||||||
|
|
||||||
|
{include file="common/left_admin_manage"}
|
||||||
|
|
||||||
|
<div class="layui-body">
|
||||||
|
|
||||||
|
<div style="padding:15px">
|
||||||
|
<div class="main-header">
|
||||||
|
<span class="layui-breadcrumb">
|
||||||
|
<a>首页</a>
|
||||||
|
<a><cite>添加分组</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="main-container">
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<fieldset class="layui-elem-field">
|
||||||
|
<legend>添加分组</legend>
|
||||||
|
<div class="layui-field-box">
|
||||||
|
<form action="{:url('update',['id'=>$admin_group.id])}" class="layui-form" method="POST" >
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">分组名称</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="name" class="layui-input" value="{$admin_group.name}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">分组权限</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
{volist name='permission_list' id='vo'}
|
||||||
|
<input type="checkbox" name="permissions[]" title="{$vo.name}" value="{$vo.id}" lay-skin="primary" {if condition="in_array($vo.id,$admin_group.permissions)"}checked{/if}>
|
||||||
|
{/volist}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<button class="layui-btn layui-btn-fluid" type="submit">创建分组</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</legend>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{include file="common/_footer"}
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
layui.use(['form'])
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -39,7 +39,18 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{volist name='list' id='vo'}
|
||||||
|
<tr>
|
||||||
|
<td>{$vo.id}</td>
|
||||||
|
<td>{$vo.name}</td>
|
||||||
|
<td>
|
||||||
|
<div class="layui-btn-container">
|
||||||
|
<a href="{:url('edit',['id'=>$vo.id])}" class="layui-btn layui-btn-sm">编辑</a>
|
||||||
|
<div data-href="{:url('delete',['id'=>$vo.id])}" class="layui-btn layui-btn-sm delete">删除</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/volist}
|
||||||
{if condition="count($list) eq 0" }
|
{if condition="count($list) eq 0" }
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">暂无数据</td>
|
<td colspan="3">暂无数据</td>
|
||||||
@@ -54,6 +65,20 @@
|
|||||||
|
|
||||||
|
|
||||||
{include file="common/_footer"}
|
{include file="common/_footer"}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('.delete').click(function(){
|
||||||
|
var item = this;
|
||||||
|
layer.confirm('确定要删除吗?',function(){
|
||||||
|
$.get($(item).data('href'),function(result){
|
||||||
|
if(result.code == 0){
|
||||||
|
$(item).parents('tr').remove();
|
||||||
|
}
|
||||||
|
layer.msg(result.msg);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user