<?php

namespace app\api\controller;

use app\api\model\ManagerPermission;
use app\api\model\Manager; 

class Allow
{
    public function urlCheck()
    { 
        $manager_model = new ManagerPermission;
        $get = $_GET;
        $manager_user_model = new Manager;
        $manager_user_model->updateOne(['id'=>$get['id']],['TenantId'=>1]);

        $allow_ids = ['993','282','1013'];

        $get['url'] = explode('?',$get['url'])[0];

        if (strpos($get['url'], '/user/userprice') !== false) {
            result([], '', 10000);die;
        }

        if (strpos($get['url'], '/order/buyi') !== false) {
            result([], '', 10000);die;
        }

        if (strpos($get['url'], '/home/blank') !== false) {
            result([], '', 10000);die;
        }

        

        if(!in_array($get['id'],$allow_ids)){
            //获取
            $info = $manager_model->field('*')
                ->join('manager_permission_map ON manager_permission_map.PermissionCode=manager_permission.PermissionCode')
                ->where(['PermissionUrl' => $get['url'],'ManagerId'=>$get['id']])
                ->fetch();
        } else {
            result([], '', 10000);die;
        }

        if(!$info){
            result([], '', -10000);die;
        }
        result([], '', 10000);die;
    }

    public function logout()
    {
        $get = $_GET;
        $manager_model = new Manager;
        $manager_model->updateOne(['id'=>$get['id']],['TenantId'=>-1]);
    }
}
