import request from '/@/utils/request';
//获取域名分组
export const pageListDomain = () => {
	return request({
		url: '/marketing/config/getDomainGroup',
		method: 'get',
	});
};
//获取ip分组
export const pageListIp = (params?: Object) => {
	return request({
		url: '/marketing/config/getIpGroup',
		method: 'get',
		params,
	});
};
//获取全局配置
export const getConfigDetail = (params?: Object) => {
	return request({
		url: '/marketing/config/getConfig',
		method: 'get',
		params,
	});
};
//获取配置ip集合
export const getConfigIpList = (params?: Object) => {
	return request({
		url: '/marketing/config/ipList',
		method: 'get',
		params,
	});
};
//获取配置域名集合
export const getConfigDomainList = (params?: Object) => {
	return request({
		url: '/marketing/config/domainList',
		method: 'get',
		params,
	});
};
//获取分组详细信息
export const getGroupDetail = (params?: Object) => {
	return request({
		url: '/marketing/config/group/detail',
		method: 'get',
		params,
	});
};
//添加配置ip集合
export const saveIpList = (data: Object) => {
	return request({
		url: '/marketing/config/addIp',
		method: 'post',
		data: data,
	});
};
//保存全局配置
export const saveConfigDetail = (data: Object) => {
	return request({
		url: '/marketing/config/setConfig',
		method: 'post',
		data: data,
	});
};
//删除配置ip集合
export const delIpList = (id?: string) => {
	return request({
		url: '/marketing/config/delIp/'+id,
		method: 'get',
	});
};
//删除配置域名集合
export const delDomainList = (id?: string) => {
	return request({
		url: '/marketing/config/delDomain/'+id,
		method: 'get',
	});
};
//添加配置域名集合
export const addDomains = (data: Object) => {
	return request({
		url: '/marketing/config/addDomain',
		method: 'post',
		data: data,
	});
};
//修改域名分组
export const saveDomains = (data: Object) => {
	return request({
		url: '/marketing/config/modDomainGroup',
		method: 'post',
		data: data,
	});
};
//修改IP分组
export const saveIps = (data: Object) => {
	return request({
		url: '/marketing/config/modIpGroup',
		method: 'post',
		data: data,
	});
};

//删除分组
export const delGroup = (data: object) => {
	return request({
		url: '/marketing/config/delGroup',
		method: 'post',
		data: data
	});
};
//添加分组
export const addGroup = (data: object) => {
	return request({
		url: '/marketing/config/addGroup',
		method: 'post',
		data: data
	});
};
//获取主动推送
export const getRule = (params?: Object) => {
	return request({
		url: '/marketing/config/getRule',
		method: 'get',
		params,
	});
};
//获取app列表
export const getAppList = () => {
	return request({
		url: '/marketing/app/list',
		method: 'get',
	});
};
//保存主动推送
export const saveRule = (data?: Object) => {
	return request({
		url: '/marketing/config/setRule',
		method: 'post',
		data,
	});
};



/**
 * 后端控制路由，isRequestRoutes 为 true，则开启后端控制路由
 * @method getAdminMenu 获取后端动态路由菜单(admin)
 */
export function useMenuApi() {
	return {
		getAdminMenu: (params?: object) => {
			return request({
				url: '/admin/menu',
				method: 'get',
				params,
			});
		},
	};
}
