<?php
/**
 * Created by PhpStorm.
 * User: Kevin
 * Date: 2022/03/16 1500
 * Time: 15:00
 */

namespace app\api\controller\getui;

use think\Db;
use think\Request;

/**
 * 用户(unipush)
 * @package app\api\controller\core
 */
class User extends Base
{

    /**
     * 1. 用户API_查询用户状态
     */
    public function queryUserStatus()
    {
        $cid = $this->request->param("cid");
        if(empty($cid)){
            $this->error("用户id不能为空");
        }

        $cid_arr = [];//查询一个或者多个用户都要用数组
        $cid_arr[] = $cid;
        $result = $this->api->userApi()->queryUserStatus($cid_arr);

        if (!empty($result)) {
            if ($result['code'] == 0) {
                $this->success("请求成功", $result['data'][$cid]);//状态,online在线 offline离线
            } else {
                $this->error("请求异常[" . $result['code'] . $result['msg'] . "]");
            }
        } else {
            $this->error("unipush服务器请求异常");
        }
    }

}