You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
239 lines
7.9 KiB
239 lines
7.9 KiB
<?php
|
|
|
|
namespace app\base\controller\auth\admin;
|
|
|
|
|
|
use app\base\model\auth\AuthRule;
|
|
use app\BaseController;
|
|
use Godruoyi\Snowflake\Snowflake;
|
|
|
|
class Menu extends BaseController
|
|
{
|
|
|
|
/**
|
|
* 获取左侧菜单栏
|
|
* @param \think\Request $request
|
|
* @param \Closure $next
|
|
* @date 2020-09-10
|
|
*/
|
|
public function getMenu()
|
|
{
|
|
$module = input('param.module'); //每个模块的菜单不一样
|
|
|
|
$auth_rule_model = new AuthRule();
|
|
|
|
$where = [
|
|
['uid', '=', UID],
|
|
['module', '=', $module],
|
|
['type', 'in', [0, 1, 2, 3]]
|
|
];
|
|
$auth_rule_list = $auth_rule_model->getAllData($where, 'id,pid,type,menu_next,title,name,icon,sort,jump', 'sort desc')->toArray();
|
|
$auth_rule_list = listToTree($auth_rule_list, 'id', 'pid', 'list', 1);
|
|
|
|
return sendSuccessMessage($auth_rule_list);
|
|
}
|
|
|
|
/**
|
|
* 所有模块列表
|
|
* @param \think\Request $request
|
|
* @param \Closure $next
|
|
* @date 2020-09-10
|
|
*/
|
|
public function moduleList()
|
|
{
|
|
$limit = input('param.limit', 10);
|
|
$page = input('param.page', 1);
|
|
|
|
$auth_rule_model = new AuthRule();
|
|
|
|
$where = [
|
|
['uid', '=', UID],
|
|
['type', '=', 0]
|
|
];
|
|
$auth_rule_list = $auth_rule_model->getDataList($where, $page, '*', 'sort desc', $limit);
|
|
|
|
$rdata = [
|
|
'list' => $auth_rule_list
|
|
];
|
|
return sendSuccessMessage($rdata);
|
|
}
|
|
|
|
/**
|
|
* 单模块所有权限列表
|
|
* @param \think\Request $request
|
|
* @param \Closure $next
|
|
* @date 2020-09-15
|
|
*/
|
|
public function menuAdd()
|
|
{
|
|
$menu = $this->menuData();
|
|
|
|
$auth_rule_model = new AuthRule();
|
|
$snow_flake = new Snowflake();
|
|
|
|
$pid = 0;
|
|
|
|
foreach ($menu as $k => $v) { //模块循环
|
|
$data[] = [
|
|
'module' => $v['name'],
|
|
'title' => $v['title'],
|
|
'name' => $v['name'],
|
|
'pid' => $pid,
|
|
'type' => $v['type'],
|
|
'menu_next' => in_array($v['type'], [1, 2]) && in_array($v['type'] + 1, array_column($v['_child'], 'type')) ? 1 : 0,
|
|
'jump'=>'',
|
|
'icon'=>'',
|
|
'id' => $pid = $snow_flake->id(),
|
|
];
|
|
|
|
foreach($v['_child'] as $k1=>$v1){ //一级菜单循环
|
|
$data[] = [
|
|
'module' => $v['name'],
|
|
'title' => $v1['title'],
|
|
'name' => $v1['name'],
|
|
'pid' => $pid,
|
|
'type' => $v1['type'],
|
|
'menu_next' => in_array($v1['type'], [1, 2]) && in_array($v1['type'] + 1, array_column($v1['_child'], 'type')) ? 1 : 0,
|
|
'jump'=>'',
|
|
'icon'=>'',
|
|
'id' => $pid = $snow_flake->id(),
|
|
];
|
|
|
|
foreach($v1['_child'] as $k2=>$v2){ //二级菜单循环
|
|
$data[] = [
|
|
'module' => $v['name'],
|
|
'title' => $v1['title'],
|
|
'name' => $v1['name'],
|
|
'pid' => $pid,
|
|
'type' => $v1['type'],
|
|
'menu_next' => in_array($v1['type'], [1, 2]) && in_array($v1['type'] + 1, array_column($v1['_child'], 'type')) ? 1 : 0,
|
|
'jump'=>'',
|
|
'icon'=>'',
|
|
'id' => $pid = $snow_flake->id(),
|
|
];
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 单模块所有权限列表(废弃)
|
|
* @param \think\Request $request
|
|
* @param \Closure $next
|
|
* @date 2020-09-15
|
|
*/
|
|
public function moduleAuthList()
|
|
{
|
|
$module = input('param.module');
|
|
|
|
$auth_rule_model = new AuthRule();
|
|
|
|
$where = [
|
|
['uid', '=', UID],
|
|
['module', '=', $module],
|
|
['type', 'in', [0, 1, 2, 3, 4]]
|
|
];
|
|
$auth_rule_list = $auth_rule_model->getAllData($where, 'id,pid,type,menu_next,title,name,icon,sort,jump', 'sort desc')->toArray();
|
|
$auth_rule_list = listToTree($auth_rule_list, 'id', 'pid', 'list', 0);
|
|
|
|
$rdata = [
|
|
'auth_rule_list' => $auth_rule_list
|
|
];
|
|
return sendSuccessMessage($rdata);
|
|
}
|
|
|
|
|
|
public function menuData()
|
|
{
|
|
$menu = [
|
|
[
|
|
'title' => '基础设置',
|
|
'name' => 'base',
|
|
'type' => 0,
|
|
'_child' => [
|
|
[
|
|
'title' => '微信平台设置',
|
|
'name' => 'wechat',
|
|
'icon' => 'layui-icon-dialogue',
|
|
'type' => 1,
|
|
'_child' => [
|
|
[
|
|
'title' => '图文素材列表',
|
|
'name' => 'news',
|
|
'type' => 2,
|
|
'_child' => [
|
|
[
|
|
'title' => '添加',
|
|
'name' => 'add',
|
|
'type' => 4,
|
|
],
|
|
[
|
|
'title' => '修改',
|
|
'name' => 'edit',
|
|
'type' => 4,
|
|
],
|
|
[
|
|
'title' => '删除',
|
|
'name' => 'del',
|
|
'type' => 4,
|
|
],
|
|
]
|
|
],
|
|
[
|
|
'title' => '关键词列表',
|
|
'name' => 'keywords',
|
|
'type' => 2,
|
|
'_child' => [
|
|
[
|
|
'title' => '添加',
|
|
'name' => 'add',
|
|
'type' => 4,
|
|
],
|
|
[
|
|
'title' => '修改',
|
|
'name' => 'edit',
|
|
'type' => 4,
|
|
],
|
|
[
|
|
'title' => '删除',
|
|
'name' => 'del',
|
|
'type' => 4,
|
|
],
|
|
]
|
|
],
|
|
[
|
|
'title' => '自定义菜单列表',
|
|
'name' => 'classify',
|
|
'type' => 2,
|
|
'_child' => [
|
|
[
|
|
'title' => '修改',
|
|
'name' => 'edit',
|
|
'type' => 4,
|
|
],
|
|
[
|
|
'title' => '删除',
|
|
'name' => 'del',
|
|
'type' => 4,
|
|
],
|
|
[
|
|
'title' => '发布',
|
|
'name' => 'publish',
|
|
'type' => 4,
|
|
],
|
|
]
|
|
],
|
|
]
|
|
],
|
|
]
|
|
]
|
|
];
|
|
return $menu;
|
|
}
|
|
|
|
|
|
}
|