Browse Source

设置权限接口

lizhen_gitee 1 year ago
parent
commit
793953f8ae
1 changed files with 14 additions and 5 deletions
  1. 14 5
      application/api/controller/User.php

+ 14 - 5
application/api/controller/User.php

@@ -436,11 +436,20 @@ class User extends Api
             $this->error('VIP才能设置隐私权限');
         }
 
-        $data = [
-            'yinsi'   => input('yinsi',0),
-            'yinshen' => input('yinshen',0),
-            'wuhen'   => input('wuhen',0),
-        ];
+        $field_array = ['yinsi','yinshen','wuhen'];
+
+        $data = [];
+        foreach($field_array as $key => $field){
+
+            if(!input('?'.$field)){
+                continue;
+            }
+
+            $newone = input($field);
+
+            $data[$field] = $newone;
+        }
+
 
         $update_rs = Db::name('user_power')->where('id',$this->auth->id)->update($data);