diff --git a/app/controller/admin/user/User.php b/app/controller/admin/user/User.php index fc934a7..cd31bdb 100644 --- a/app/controller/admin/user/User.php +++ b/app/controller/admin/user/User.php @@ -616,10 +616,19 @@ class User extends BaseController $id = (int)$this->request->param('uid', ''); if (!$this->repository->exists($id)) return app('json')->fail('数据不存在'); + $is_cf = false; foreach ($partner_id as $k => $value) { + $count = array_count_values($partner_id); // 统计每个元素的出现次数 + if (isset($count[$value]) && $count[$value] > 1) { + $is_cf = true; + } $partner_ids[$k] = (int)$value; - if (!$partnerRepository->exists((int)$value)) + if (!$partnerRepository->exists((int)$value)) { return app('json')->fail('所选合作人角色不存在'); + } + } + if($is_cf){ + return app('json')->fail('请勿给用户设置重复的角色'); } foreach ($user_role_id as $k => $value) { $user_role_ids[$k] = (int)$value;