<?php

namespace app\adminapi;

use support\Request;

abstract class BaseController
{
    protected $uid;
    
    public function __construct()
    {
        $request = request();
        if(!$request->uid){
            $this->uid = 0;
        }else{
            $this->uid = $request->uid;
        }
    }

    public function Success($data,$code=200,$message='請求成功'){
        $result = [
            'code' => $code,
            'message' => $message,
            'time'=>time(),
            'data'=>$data
        ];
        return json($result);
    }

    public function Error($data='',$code=500,$message='請求失敗'){
        $result = [
            'code' => $code,
            'message' => $message,
            'time'=>time(),
            'data'=>$data
        ];
        return json($result);
    }
}
