<?php
namespace wechat\models;

use Yii;

class AdminApi extends BaseApi
{
    public $apiUrl = 'admin';

    /**
     * 登录
     * @param array $data
     * @return array
     */
    public function login($data)
    {
        $data['login_ip'] = (string) Yii::$app->request->getUserIP();
        $result = $this->post($this->apiUrl . '/login', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], $result['message']);
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }
    
    /**
     * 某个管理员
     * @param int $id
     * @return array
     */
    public function getAdminById($id)
    {
        $result = $this->post($this->apiUrl . '/get-admin-by-id', ['id' => $id]);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data']);
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }
}

