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

// 仓库查询参数
export interface WarehouseQueryParams {
	keyword?: string;
	status?: string;
	pageNum?: number;
	pageSize?: number;
}

// 仓库数据接口
export interface WarehouseData {
	id?: string;
	warehouseName: string;
	warehouseCode?: string;
	address?: string;
	contactPerson?: string;
	contactPhone?: string;
	status?: string;
	remark?: string;
}

// 获取仓库列表
export function listWarehouses(params?: WarehouseQueryParams) {
	return request({
		url: '/assets/warehouse/listWarehouses',
		method: 'get',
		params,
	});
}

// 获取仓库详情
export function getWarehouse(id: string) {
	return request({
		url: '/assets/warehouse/getWarehouse',
		method: 'get',
		params: { id },
	});
}

// 创建仓库
export function createWarehouse(data: WarehouseData) {
	return request({
		url: '/assets/warehouse/createWarehouse',
		method: 'post',
		data,
	});
}

// 更新仓库
export function updateWarehouse(data: WarehouseData) {
	return request({
		url: '/assets/warehouse/updateWarehouse',
		method: 'put',
		data,
	});
}

// 删除仓库
export function deleteWarehouse(id: string) {
	return request({
		url: '/assets/warehouse/deleteWarehouse',
		method: 'delete',
		params: { id },
	});
}

// 更新仓库状态
export function updateWarehouseStatus(data: { id: string; status: string }) {
	return request({
		url: '/assets/warehouse/updateWarehouseStatus',
		method: 'put',
		data,
	});
}
