|
@@ -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([]);
|
|
|
+ }
|
|
|
}
|