<?php

namespace App\Services\Gteam;

use App\Models\User\UserModel;
use App\Services\Service;

class UserService extends Service
{
    /**
     * 获取用户信息
     * @param  int  $uid
     * @return array
     */
    public function getUser(int $uid)
    {
        $user = UserModel::findOrFail($uid, ['uid', 'headimgurl', 'nickname', 'sex']);
        $guser = \App\Models\Gteam\UserModel::firstOrNew(['uid' => $uid]);
        $guser->cj_wx_rank = $guser->cj_wx_rank ?? -1;
        $guser->wz_wx_rank = $guser->wz_wx_rank ?? -1;
        $guser->headimgurl = $user->headimgurl;
        $guser->nickname = $user->nickname;
        $guser->sex = $user->sex;

        return $guser->toArray();
    }
}
