作者 liyuhang

csdm

... ... @@ -4,6 +4,9 @@ namespace app\api\controller;
use app\admin\controller\Base;
use app\admin\model\Manager as ManagerModel;
use app\admin\model\Menu as MenuModel;
use app\admin\model\Role as RoleModel;
use think\Cache;
use think\Validate;
/**
... ... @@ -159,4 +162,23 @@ class Manager extends Base
$this->response('成功',200,[]);;
}
}
/**
* @name :获取当前用户菜单列表
* @return void
* @author :liyuhang
* @method : get
*/
public function get_menu(){
//获取当前用户角色
$roleModel = new RoleModel();
$role_info = $roleModel->read(['id'=>$this->user['role_id']]);
//根据当前角色获取当前菜单栏
$menuModel = new MenuModel();
$menu_lists = $menuModel->where(['pid'=>0,'status'=>1,'deleted'=>1])->where('id','in',$role_info['menu'])->select()->toArray();
foreach ($menu_lists as $k => $v){
$menu_lists[$k]['son'] = $menuModel->where(['pid'=>$v['id'],'status'=>1,'deleted'=>1])->where('id','in',$role_info['menu'])->select()->toArray();
}
$this->response('当前用户菜单列表',200,$menu_lists);
}
}
\ No newline at end of file
... ...
<?php
namespace app\api\controller;
use app\admin\controller\Base;
class Menu extends Base
{
/**
* @name 菜单列表
* @return void
* @author :liyuhang
* @method
*/
public function lists(){}
/**
* @name :新增菜单
* @return void
* @author :liyuhang
* @method
*/
public function add(){}
/**
* @name:编辑菜单
* @return void
* @author :liyuhang
* @method
*/
public function edit(){}
/**
* @name:禁用菜单
* @return void
* @author :liyuhang
* @method
*/
public function status(){}
/**
* @name:删除菜单
* @return void
* @author :liyuhang
* @method
*/
public function deleted(){
}
}
\ No newline at end of file
... ...
<?php
namespace app\api\controller;
use app\admin\controller\Base;
class Role extends Base
{
/**
* @name :角色列表
* @return void
* @author :liyuhang
* @method
*/
public function lists(){}
/**
* @name :添加角色
* @return void
* @author :liyuhang
* @method
*/
public function add(){}
/**
* @name:编辑角色
* @return void
* @author :liyuhang
* @method
*/
public function edit(){}
/**
* @name:修改当前角色状态
* @return void
* @author :liyuhang
* @method
*/
public function status(){}
/**
* @name :逻辑删除角色
* @return void
* @author :liyuhang
* @method
*/
public function deleted(){}
}
\ No newline at end of file
... ...
... ... @@ -36,7 +36,7 @@ abstract class Base extends Model
* @param $data
* @return $info
*/
protected function read($data)
public function read($data)
{
$info = $this->where($data)->find();
if (!empty($info)) {
... ...
<?php
namespace app\admin\model;
class Menu extends Base
{
protected $autoWriteTimestamp = 'datetime';
}
\ No newline at end of file
... ...
<?php
namespace app\admin\model;
class Role extends Base
{
protected $autoWriteTimestamp = 'datetime';
}
\ No newline at end of file
... ...