123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <?php
- // +----------------------------------------------------------------------
- // | Niucloud-admin 企业快速开发的saas管理平台
- // +----------------------------------------------------------------------
- // | 官方网址:https://www.niucloud.com
- // +----------------------------------------------------------------------
- // | niucloud团队 版权所有 开源版本可自由商用
- // +----------------------------------------------------------------------
- // | Author: Niucloud Team
- // +----------------------------------------------------------------------
- namespace app\adminapi\controller\sys;
- use app\dict\sys\MenuDict;
- use app\dict\sys\MenuTypeDict;
- use app\dict\sys\MethodDict;
- use app\service\admin\install\InstallSystemService;
- use app\service\admin\sys\MenuService;
- use core\base\BaseAdminController;
- use think\db\exception\DbException;
- use think\Response;
- class Menu extends BaseAdminController
- {
- /**
- * 菜单列表(todo 限制只有平台端可以访问)
- * @return Response
- */
- public function lists($app_type)
- {
- return success((new MenuService())->getAllMenuList($app_type, 'all', 1));
- }
- /**
- * 菜单信息
- * @param $app_type
- * @param $menu_key
- * @return Response
- */
- public function info($app_type, $menu_key)
- {
- return success((new MenuService())->get($app_type, $menu_key));
- }
- /**
- * 新增菜单接口
- * @return Response
- */
- public function add()
- {
- $data = $this->request->params([
- ['app_type', ''],
- ['menu_name', ''],
- ['menu_type', 0],
- ['menu_key', ''],
- ['parent_key', ''],
- ['icon', ''],
- ['api_url', ''],
- ['view_path', ''],
- ['router_path', ''],
- ['methods', ''],
- ['sort', 0],
- ['status', MenuDict::ON],
- ['is_show', 0],
- ['addon', ''],
- ['menu_short_name','']
- ]);
- $this->validate($data, 'app\validate\sys\Menu.add');
- (new MenuService())->add($data);
- return success('ADD_SUCCESS');
- }
- /**
- * 菜单或接口更新
- */
- public function edit($app_type, $menu_key)
- {
- $data = $this->request->params([
- ['menu_name', ''],
- ['parent_key', ''],
- ['menu_type', 0],
- ['icon', ''],
- ['api_url', ''],
- ['router_path', ''],
- ['view_path', ''],
- ['methods', ''],
- ['sort', 0],
- ['status', MenuDict::ON],
- ['is_show', 0],
- ['addon', ''],
- ['menu_short_name','']
- ]);
- $this->validate($data, 'app\validate\sys\Menu.edit');
- (new MenuService())->edit($app_type, $menu_key, $data);
- return success('EDIT_SUCCESS');
- }
- /**
- * 获取菜单类型静态资源
- * @return Response
- */
- public function getMenuType()
- {
- return success(MenuTypeDict::getMenuType());
- }
- /**
- * 获取请求方式
- * @return Response
- */
- public function getMethodType()
- {
- return success(MethodDict::getMethodType());
- }
- /**
- * 删除菜单
- * @param $app_type
- * @param $menu_key
- * @return Response
- * @throws DbException
- */
- public function del($app_type, $menu_key)
- {
- (new MenuService())->del($app_type, $menu_key);
- return success('DELETE_SUCCESS');
- }
- public function refreshMenu()
- {
- (new InstallSystemService())->install();
- return success('SUCCESS');
- }
- /**
- * 查询菜单信息
- */
- public function getSystem()
- {
- return success( (new MenuService())->getSystemMenu('all', 1));
- }
- /**
- * 查询应用权限信息
- */
- public function getAddonMenu($app_key)
- {
- return success( (new MenuService())->getAddonMenu($app_key,'all', 1));
- }
- /**
- * 查询菜单类型为目录的菜单
- * @param $addon
- * @return Response
- */
- public function getMenuByTypeDir($addon = 'system') {
- return success( (new MenuService())->getMenuByTypeDir($addon));
- }
- }
|