diff --git a/app/Request/v3/UserUpdateRequest.php b/app/Request/v3/UserUpdateRequest.php index 7acc1e9..da9f72f 100644 --- a/app/Request/v3/UserUpdateRequest.php +++ b/app/Request/v3/UserUpdateRequest.php @@ -15,9 +15,9 @@ class UserUpdateRequest extends BaseFormRequest public function rules(): array { return [ - 'user_id' => 'required|nonempty', + 'userId' => 'required|nonempty', 'iv' => 'required|nonempty', - 'encrypted_data' => 'required|nonempty' + 'encryptedData' => 'required|nonempty' ]; } @@ -35,4 +35,4 @@ class UserUpdateRequest extends BaseFormRequest { return parent::attributes(); } -} +} \ No newline at end of file diff --git a/app/Service/v3/Implementations/UserInfoService.php b/app/Service/v3/Implementations/UserInfoService.php index aa3129e..40688d1 100644 --- a/app/Service/v3/Implementations/UserInfoService.php +++ b/app/Service/v3/Implementations/UserInfoService.php @@ -16,24 +16,30 @@ use EasyWeChat\Kernel\Exceptions\DecryptException; use Hyperf\Guzzle\CoroutineHandler; use Hyperf\Utils\ApplicationContext; -class UserInfoService implements UserInfoServiceInterface +class UserInfoService { /** * 更新 - * @param $userId - * @param $iv - * @param $encryptedData + * @param $data * @return array * @throws DecryptException */ - public function do($userId, $iv, $encryptedData) + public function do($data) { try { + $userId = $data['userId']; + $iv = $data['iv']; + $encryptedData = $data['encryptedData']; + $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); $user = $ssdb->exec('hgetall', SsdbKeys::USER_INFO.$userId); - + + if(empty($user)) { + return ['找不到缓存的用户信息']; + } + // 微信登录 $config = config('applet'); $app = Factory::miniProgram($config); @@ -43,8 +49,8 @@ class UserInfoService implements UserInfoServiceInterface $data = [ 'nick_name' => $decryptedData['nickName'], 'avatar' => $decryptedData['avatarUrl'], - 'openid' => $decryptedData['openId'], - 'unionid' => $decryptedData['unionId'], + // 'openid' => $decryptedData['openId'], + // 'unionid' => $decryptedData['unionId'], 'country' => $decryptedData['country'], 'province' => $decryptedData['province'], 'city' => $decryptedData['city'], @@ -83,10 +89,15 @@ class UserInfoService implements UserInfoServiceInterface public function detail($userId) { - return User::query() + $result = User::query() ->select(['id', 'nick_name', 'avatar', 'openid', 'unionid', 'total_score', 'real_name']) ->where(['status' => 1, 'id' => $userId]) - ->first()->toArray(); + ->first(); + if(!$result) { + return []; + }else{ + return $result; + } } public function getStoreByUID($userId)