request->post('menuid', 0); return ActionLogic::list($menuid); } //添加权限 public function add() { $param = $this->request->only(['menuid', 'action_code', 'status' => CommonModel::$status_normal], 'post'); $val = Validate::rule(Config::get('validate_rules.actionAdd')); if (!$val->check($param)) throw new ValidateException($val->getError()); return ActionLogic::add($param); } // //获取权限详情 // public function Read() // { // $id = $this->request->post('id/d', 0); // // return ActionLogic::read($id); // } //编辑权限 public function edit() { $param = $this->request->only(['id', 'action_code'], 'post'); $val = Validate::rule([ 'id' => 'require|number|gt:0', 'action_code|按钮编码' => 'require', ]); if (!$val->check($param)) throw new ValidateException($val->getError()); return ActionLogic::edit($param); } //删除权限 public function delete() { $id = $this->request->post('id/d', 0); return ActionLogic::delete($id); } //启禁用权限 public function status() { $param = $this->request->only(['id', 'status'], 'post'); $val = Validate::rule(Config::get('validate_rules.status')); if (!$val->check($param)) throw new ValidateException($val->getError()); return ActionLogic::status($param); } //获取所有菜单下的所有按钮 public function index() { $list = AdminMenuModel::field('id,menu_name,menu_type,menu_img,menu_route,menu_url,status,weight,addtime,is_private private') ->where(['pid' => 0, 'is_show' => AdminMenuModel::$show]) ->append(['child']) ->withAttr('child', function ($val, $data) { return AdminMenuModel::field('id,menu_name,menu_type,menu_img,menu_route,menu_url,status,weight,addtime,is_private private,pid') ->where(['pid' => $data['id'], 'is_show' => AdminMenuModel::$show]) ->append(['action']) ->withAttr('action', function ($v, $d) { return ActionModel::alias('a') ->leftJoin('action_list l', 'a.action_code=l.action_code') ->field('a.*,action_name') ->where(['a.menuid' => $d['id'], 'a.status' => CommonModel::$status_normal]) ->select() ->toArray(); }) ->order('weight', 'desc') ->select() ->toArray(); }) ->order('weight', 'desc') ->select() ->toArray(); return json_show(CommonModel::$success, '获取成功', $list); } }