import { defHttp } from '/@/utils/http/axios';

enum Api {
    GetTools = '/xld-2And3/findAllTool',
    GetLayer2d = '/xld-2And3/findAllLayer2d',
    GetLayer3d = '/xld-2And3/findAllLayer3d',
    GetMenu = '/xld-2And3/findAllMenu',
    AddTools = '/xld-2And3/addTool',
    RemoveTool = '/xld-2And3/removeTool',
    ShowTool = '/xld-2And3/updateToolStatus',
}
const locationType = { mapToolsUrl: true };
/**
 * @description: 新增地图工具
 */
export const addTools = (params) => {
    return new Promise<void>((resolve) => {
        defHttp.post({
            ...locationType,
            url: Api.AddTools,
            data: {
                data: JSON.stringify(params)
            }
        }).then((res) => {
            resolve(res)
        })
    })
};
/**
 * @description: 删除地图工具
 */
export const delTools = (params) => {
    return new Promise<void>((resolve) => {
        defHttp.post({
            ...locationType,
            url: Api.RemoveTool,
            data: {
                id: `${params.id}`
            }
        },
        ).then((res) => {
            resolve(res)
        })
    })
};
/**
 * @description: 隐藏地图工具
 */
export const showTools = (params) => {
    return new Promise<void>((resolve) => {
        defHttp.post({
            ...locationType,
            url: Api.ShowTool,
            data: {
                id: `${params.id}`,
                show: !params.show
            }
        },
        ).then((res) => {
            resolve(res)
        })
    })
};
/**
 * @description: 获取所有地图工具
 */
export const getAllTools = () => {
    return new Promise<void>((resolve) => {
        defHttp.get({ ...locationType, url: Api.GetTools }).then((res) => {
            resolve(res)
        })
    })
};
/**
 * @description: 获取菜单
 */
export const getMenu = () => {
    return new Promise<void>((resolve) => {
        defHttp.get({ ...locationType, url: Api.GetMenu }).then((res) => {
            resolve(res)
        })
    })
};
/**
 * @description: 获取二维图层
 */
export const get2dLayers = () => {
    return new Promise<void>((resolve) => {
        defHttp.get({ ...locationType, url: Api.GetLayer2d }).then((res) => {
            resolve(res)
        })
    })
};
/**
 * @description: 获取三维图层
 */
export const get3dLayers = () => {
    return new Promise<void>((resolve) => {
        defHttp.get({ ...locationType, url: Api.GetLayer3d }).then((res) => {
            resolve(res)
        })
    })
};