소스 검색

changePassword

AI 6 달 전
부모
커밋
9b7f50db59
2개의 변경된 파일35개의 추가작업 그리고 0개의 파일을 삭제
  1. 27 0
      app/JsonRpc/UserService.php
  2. 8 0
      app/JsonRpc/UserServiceInterface.php

+ 27 - 0
app/JsonRpc/UserService.php

@@ -374,4 +374,31 @@ class UserService implements UserServiceInterface
             return Result::error('添加失败');
         }
     }
+
+     /**
+     * 修改密码
+     * @param array $data
+     * @return array
+     */
+    public function changePassword(array $data) :array
+    {
+        Db::beginTransaction();
+        $userInfo = User::where(['id'=>$data['user_id']])->first(); 
+        // return Result::success($userInfo); 
+        try{
+            $dataUserReq = [
+                'password'=>md5(md5($data['new_password1']).$userInfo['salt']),
+            ];
+            if($userInfo['password'] != md5(md5($data['password']).$userInfo['salt'])){
+                return Result::error('您输入的密码错误');
+            }
+            $userRep =  User::where(['id'=>$data['user_id']])->update($dataUserReq);
+            Db::commit();
+        } catch(\Throwable $ex){
+            Db::rollBack();
+            var_dump($ex->getMessage());
+            return Result::error("创建失败",0);
+        }
+        return Result::success([]);  
+    }
 }

+ 8 - 0
app/JsonRpc/UserServiceInterface.php

@@ -105,4 +105,12 @@ interface UserServiceInterface
      */
     public function addWechatInfo(array $data) :array;
 
+
+    /**
+     * 修改密码
+     * @param array $data
+     * @return array
+     */
+    public function changePassword(array $data) :array;
+
 }