From d6f7f1cbf0c903dca52516d472130df882df4a0c Mon Sep 17 00:00:00 2001 From: zhang zhuo Date: Mon, 23 Jun 2025 18:06:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=92=E8=89=B2=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/Admin/System.php | 16 ++++++++-------- app/Model/Role.php | 11 ++++------- app/Model/RoleMenu.php | 2 +- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/Controller/Admin/System.php b/app/Controller/Admin/System.php index c785896..d617266 100644 --- a/app/Controller/Admin/System.php +++ b/app/Controller/Admin/System.php @@ -67,9 +67,9 @@ class System extends Base #[Auth(needAuth: false, auth: "menu:del")] public function menuDel() { - $menu_id = $this->request->input("menu_id", ""); - if (!$menu_id) return $this->error("请选择要删除的菜单"); - $res = mModel::del($menu_id); + $ids = $this->request->input("ids", ""); + if (!$ids) return $this->error("请选择要删除的菜单"); + $res = mModel::del($ids); return $res ? $this->success("操作成功") : $this->error("操作失败"); } @@ -132,9 +132,9 @@ class System extends Base #[Auth(auth: "dept:del")] public function deptDel() { - $dept_id = $this->request->input("dept_id", ""); - if (!$dept_id) return $this->error("请选择要删除的菜单"); - $res = dModel::del($dept_id); + $ids = $this->request->input("ids", ""); + if (!$ids) return $this->error("请选择要删除的菜单"); + $res = dModel::del($ids); return $res ? $this->success("操作成功") : $this->error("操作失败"); } @@ -162,7 +162,7 @@ class System extends Base { $request = $this->container->get(rRequest::class); $request->scene('add')->validateResolved(); - $data = Param::only(['role_name' => '', 'menus' => [], 'remark', 'status' => 1, 'rank', "checked_menus"]); + $data = Param::only(['role_name' => '', 'menus' => [], 'status' => 1, 'rank', "checked_menus"]); $data['belong_id'] = $this->account['belong_id']; $data['account_type'] = $this->account['account_type']; $res = rModel::add($data); @@ -176,7 +176,7 @@ class System extends Base { $request = $this->container->get(rRequest::class); $request->scene('edit')->validateResolved(); - $data = Param::only(['role_id' => '', 'role_name' => '', 'menus' => [], 'remark', 'status' => 1, 'rank', "checked_menus"]); + $data = Param::only(['role_id' => '', 'role_name' => '', 'menus' => [], 'status' => 1, 'rank', "checked_menus"]); $res = rModel::edit($data); return $res ? $this->success("操作成功") : $this->error("操作失败"); } diff --git a/app/Model/Role.php b/app/Model/Role.php index e959b0b..ae5f587 100644 --- a/app/Model/Role.php +++ b/app/Model/Role.php @@ -39,13 +39,12 @@ class Role extends Model public static function list(int $belong_id, int $account_type, string $role_name) { - $model = self::where('del_flag', 0) - ->where('belong_id', $belong_id) + $model = self::where('belong_id', $belong_id) ->where('account_type', $account_type); if ($role_name != '') { $model = $model->where("role_name","like", "%$role_name%"); } - return $model->select(["role_id","role_name","status","remark","create_time","rank","checked_menus"]) + return $model->select(["role_id","role_name","status","create_time","rank","checked_menus"]) ->get()->each(function ($item){ $item['menus'] = RoleMenu::getMenu($item['role_id']); })->toArray(); @@ -53,8 +52,7 @@ class Role extends Model public static function options(int $belong_id, int $account_type) { - return self::where('del_flag', 0) - ->where('belong_id', $belong_id) + return self::where('belong_id', $belong_id) ->where('account_type', $account_type) ->orderByDesc("rank") ->select(["role_id","role_name"]) @@ -69,7 +67,6 @@ class Role extends Model public static function add(array $data) { $data['create_time'] = date("Y-m-d H:i:s"); - $data['del_flag'] = 0; $menus = $data['menus']; unset($data['menus']); Db::beginTransaction(); @@ -104,7 +101,7 @@ class Role extends Model $menus = $data['menus']; unset($data['menus']); Db::beginTransaction(); - $res = self::where("role_id", $data['role_id'])->where('del_flag', 0)->update($data); + $res = self::where("role_id", $data['role_id'])->update($data); if (!$res) { Db::rollBack(); return false; diff --git a/app/Model/RoleMenu.php b/app/Model/RoleMenu.php index 507e801..9a10147 100644 --- a/app/Model/RoleMenu.php +++ b/app/Model/RoleMenu.php @@ -10,7 +10,7 @@ use Hyperf\DbConnection\Db; * @property int $role_id * @property int $menu_id */ -class RoleMenu extends Model +class RoleMenu extends \Hyperf\Database\Model\Model { /** * The table associated with the model.