Explorar o código

验证删除囧色之前判断是否有用户存在

rkljw hai 1 semana
pai
achega
3f0632b4a1
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      app/JsonRpc/UserService.php

+ 5 - 0
app/JsonRpc/UserService.php

@@ -429,6 +429,11 @@ class UserService implements UserServiceInterface
     {
         Db::beginTransaction();
         try {
+            $count = RoleUser::where(['role_id' => $data['id']])->count();
+            if($count>0){
+                Db::rollBack();
+                return Result::error("请先删除该角色下的用户", 0);
+            }
             $roleInfo = Role::where(['id' => $data['id']])->first();
             $logData = [
                 'user_id' => $data['user_id'],