import request from '/@/utils/request';

// 获取租户列表
export function getTenantList(query: Object) {
	return request({
		url: '/admin-go/api/v1/system/tenant/list',
		method: 'get',
		params: query,
	});
}

// 获取租户详情
export function getTenant(id: number) {
	return request({
		url: '/admin-go/api/v1/system/tenant/get',
		method: 'get',
		params: { id },
	});
}

// 新增租户
export function addTenant(data: object) {
	// 如果是 FormData，需要让浏览器自动设置 Content-Type（包含 boundary）
	const isFormData = data instanceof FormData;
	return request({
		url: '/admin-go/api/v1/system/tenant/add',
		method: 'post',
		data: data,
		headers: isFormData ? { 'Content-Type': undefined } : undefined,
	});
}

// 修改租户
export function editTenant(data: object) {
	// 如果是 FormData，需要让浏览器自动设置 Content-Type（包含 boundary）
	const isFormData = data instanceof FormData;
	return request({
		url: '/admin-go/api/v1/system/tenant/edit',
		method: 'put',
		data: data,
		headers: isFormData ? { 'Content-Type': undefined } : undefined,
	});
}

// 删除租户
export function deleteTenant(ids: number[]) {
	return request({
		url: '/admin-go/api/v1/system/tenant/delete',
		method: 'delete',
		data: { ids },
	});
}
