浏览代码

子账户删除修改

Cherry 2 年之前
父节点
当前提交
79fc6b0e10
共有 2 个文件被更改,包括 277 次插入183 次删除
  1. 54 0
      application/api/controller/User.php
  2. 223 183
      public/api.html

+ 54 - 0
application/api/controller/User.php

@@ -7,6 +7,7 @@ use app\admin\model\User as ModelUser;
 use app\admin\model\UserAddress;
 use app\admin\model\UserSubscribeMessage;
 use app\common\controller\Api;
+use app\common\library\Auth;
 use app\common\library\Ems;
 use app\common\library\Sms;
 use fast\Http;
@@ -664,6 +665,59 @@ class User extends Api
         }
     }
 
+
+    /**
+     * 子账户删除
+     *
+     * @ApiMethod (POST)
+     * @param string $id 删除id
+     */
+    public function son_del()
+    {
+        $del_id = $this->request->post('id');
+
+        $del_user = ModelUser::where('id', $del_id)->where('pid', $this->auth->id)->find();
+        if(!$del_user){
+            $this->error("账户不存在");
+        }
+
+        if(Auth::instance()->delete($del_id)){
+            $this->success("删除成功");
+        }else{
+            $this->error("请稍后重试");
+        }
+    }
+
+    /**
+     * 子账户修改
+     *
+     * @ApiMethod (POST)
+     * @param id $id 删除id
+     * @param string $password 密码
+     * @param string $repassword 确认密码
+     */
+    public function son_edit()
+    {
+        $del_id = $this->request->post('id');
+        $password = $this->request->post('password');
+        $repassword = $this->request->post('repassword');
+
+        if (!$del_id || !$password || !$repassword) {
+            $this->error(__('Invalid parameters'));
+        }
+        if ($password != $repassword) {
+            $this->error('密码和确认密码不一致!');
+        }
+
+        $edit_user = ModelUser::where('id', $del_id)->where('pid', $this->auth->id)->find();
+        if(!$edit_user){
+            $this->error("账户不存在");
+        }
+        $edit_user->password = $password;
+        $edit_user->save();
+        $this->success("修改成功");
+    }
+
     /**
      * 子账户列表
      *

文件差异内容过多而无法显示
+ 223 - 183
public/api.html


部分文件因为文件数量过多而无法显示