import {requestGet, requestInstance, requestInstance_Get} from "@/service/index";

export function GetUserInfo(){//查询用户信息
    return requestGet({
        url:'/Authentication/GetUserInfo',
        params:{
        }
    })
}

export function GetRoleInfo(){//查询用户 角色信息
    return requestInstance_Get({
        url:'/Authentication/GetRoleInfo',
        params:{
        }
    })
}

export function GetUnitList(){//查询用户 单位信息
    return requestInstance_Get({
        url:'/Authentication/GetUnitList',
        params:{
        }
    })
}

//查询模块树
export function selectSystemMainByRoleUuid_V01(data){
    return requestInstance({
        url:'/ptjkInterface/selectSystemMainByRoleUuid_V01',
        data:{
            ...data
        }
    })
}
//查询模块列表
export function selectSystemMainByRoleUuid(data){
    return requestInstance({
        url:'/ptjkInterface/selectSystemMainByRoleUuid',
        data:{
            ...data
        }
    })
}

//查询按钮
export function selectConfigButtonByRoleUuid(data){
    return requestInstance({
        url:'/zyml-module-button/selectConfigButtonByRoleUuid',
        data:{
            ...data
        }
    })
}

//循环处理 模块信息
export function handleMoudleData(dataList){
    let modelData = {};
    for(let i=0;i<dataList.length;i++){
        modelData[dataList[i]["CODE"]] = dataList[i]["CODE"];
    }
    //存储缓存
    localStorage.setItem("bimBrowseModels",JSON.stringify(modelData));
}
//验证模块信息
export function verificationMoudle(code){
    if(localStorage.getItem("bimBrowseModels") == null){
        return false;
    }
    let modelData = JSON.parse(localStorage.getItem("bimBrowseModels"));
    for (let i = 0 ;i < modelData.length;i++){
        if(modelData[i] === code){
            return true;
        }
    }
    return false;
    // return false;
}
//缓存按钮信息
//循环处理 模块信息
export function handleMoudleButtonData(dataList){
    let buttonData = {};
    for(let i=0;i<dataList.length;i++){
        buttonData[dataList[i]["CODE"]] = dataList[i]["CODE"];
    }
    //存储缓存
    localStorage.setItem("bimBrowseButtons",JSON.stringify(buttonData));
}

export function getTokenInterior(ticket, id) {
    return requestInstance_Get({
        url: '/login/getTokenInterior',
        headers: {
            'auth-ticket': decodeURIComponent(ticket.toString()),
            'auth-sysId': id,
        },
        method: 'get',
    });
}

//查询单位信息
export function getUnitDataList(data){
    return requestInstance({
        url:'/unit/v1/getUnitDataList',
        data:{
            ...data
        }
    })
}

export function getPermissionSet(data){//查询用户 角色信息
    return requestInstance_Get({
        url:'/login/getTokenInterior',
        headers:{
            "auth-ticket":data
        }
    })
}