load->model('agent/admin/Market_sys_menu_model', 'mdSysMenu'); } /** * Notes菜单管理 * Created on: 2022/9/9 14:48 * Created by: dengbw */ public function index_get() { $title = $this->input_param('title'); $path = $this->input_param('path'); $authority = $this->input_param('authority'); $where['status>='] = 0; $sort_order = 'sortNumber asc,menuId desc'; $title && $where['title'] = $title; $path && $where['path'] = $path; $authority && $where['authority'] = $authority; $res = $this->mdSysMenu->select($where, $sort_order); foreach ($res as $k => $v) { $res[$k]['menuId'] = intval($v['menuId']); $res[$k]['parentId'] = intval($v['parentId']); $res[$k]['menuType'] = intval($v['menuType']); $res[$k]['openType'] = intval($v['openType']); $res[$k]['sortNumber'] = intval($v['sortNumber']); $res[$k]['hide'] = intval($v['hide']); $res[$k]['meta'] = json_decode($v['meta'], true); } $this->return_response_list($res); } /** * Notes:修改菜单 * Created on: 2022/9/9 17:58 * Created by: dengbw */ public function index_put() { $menuId = $this->input_param('menuId'); $parentId = intval($this->input_param('parentId')); $menuType = intval($this->input_param('menuType')); $title = $this->input_param('title'); $openType = intval($this->input_param('openType')); $icon = $this->input_param('icon'); $path = $this->input_param('path'); $component = $this->input_param('component'); $authority = $this->input_param('authority'); $sortNumber = intval($this->input_param('sortNumber')); $hide = intval($this->input_param('hide')); $meta = $this->input_param('meta'); if (!$menuId) { $this->return_json('参数错误'); } if (!$title) { $this->return_json('请输入菜单名称'); } !$icon && $icon = ''; !$path && $path = ''; !$component && $component = ''; !$authority && $authority = ''; $upDate = ['parentId' => $parentId, 'menuType' => $menuType, 'title' => $title, 'openType' => $openType, 'icon' => $icon, 'path' => $path, 'component' => $component, 'authority' => $authority, 'sortNumber' => $sortNumber, 'hide' => $hide]; $upDate['meta'] = $meta ? json_encode($meta, JSON_UNESCAPED_UNICODE) : null; $this->mdSysMenu->update($upDate, ['menuId' => $menuId]); $this->return_response(); } /** * Notes:添加菜单 * Created on: 2022/9/9 11:47 * Created by: dengbw */ public function index_post() { $parentId = intval($this->input_param('parentId')); $menuType = intval($this->input_param('menuType')); $title = $this->input_param('title'); $openType = intval($this->input_param('openType')); $icon = $this->input_param('icon'); $path = $this->input_param('path'); $component = $this->input_param('component'); $authority = $this->input_param('authority'); $sortNumber = intval($this->input_param('sortNumber')); $hide = intval($this->input_param('hide')); $meta = $this->input_param('meta'); if (!$title) { $this->return_json('请输入菜单名称'); } !$icon && $icon = ''; !$path && $path = ''; !$component && $component = ''; !$authority && $authority = ''; $addDate = ['parentId' => $parentId, 'menuType' => $menuType, 'title' => $title, 'openType' => $openType, 'icon' => $icon, 'path' => $path, 'component' => $component, 'authority' => $authority, 'sortNumber' => $sortNumber, 'hide' => $hide, 'createTime' => date('Y-m-d H:i:s')]; $meta && $addDate['meta'] = json_encode($meta, JSON_UNESCAPED_UNICODE); $id = $this->mdSysMenu->add($addDate); if (!$id) { $this->return_json('添加菜单失败'); } $this->return_response(); } /** * Notes:删除菜单 * Created on: 2022/9/9 16:10 * Created by: dengbw * @param null $menuId */ public function index_delete($menuId = null) { $menuId = intval($menuId); if (!$menuId) { $this->return_json('参数错误'); } $this->mdSysMenu->update(['status' => -1], ['menuId' => $menuId]); $this->return_response(); } /** * Notes:批量删除菜单 * Created on: 2022/10/21 17:11 * Created by: dengbw */ public function batch_delete() { $ids = $this->input_param('ids'); if (!$ids) { $this->return_json('参数错误'); } $str_ids = implode(',', $ids); if ($str_ids) { $this->mdSysMenu->update(['status' => -1], ["menuId in($str_ids)" => null]); } $this->return_response(); } }