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


// 获取分类树
export function getCategoryTree(query?: Object) {
	return request({
		url: '/assets/category/getCategoryTree',
		method: 'get',
		params: query,
	});
}

// 获取分类详情
export function getCategory(id: number | string) {
	return request({
		url: '/assets/category/getCategory',
		method: 'get',
		params: { id: id.toString() },
	});
}

// 获取属性类型选项
export function getCategoryAttrTypeOptions() {
	return request({
		url: '/assets/enum/getCategoryAttrType',
		method: 'get',
	});
}

// 新增分类
export function addCategory(data: object) {
	return request({
		url: '/assets/category/createCategory',
		method: 'post',
		data: data,
	});
}

// 查询获取列表
export function listCategories(keyword: string) {
	return request({
		url: '/assets/category/listCategories',
		method: 'get',
		params: {keyword},
	});
}

// 修改分类
export function updateCategory(data: object) {
	return request({
		url: '/assets/category/updateCategory',
		method: 'put',
		data: data,
	});
}

// 删除分类
export function deleteCategory(id: number | string) {
	return request({
		url: '/assets/category/deleteCategory',
		method: 'delete',
		params: { id: id.toString() },
	});
}

// 更新分类状态
export function updateCategoryStatus(id: number | string, status: number) {
	return request({
		url: '/assets/category/updateCategoryStatus',
		method: 'put',
		data: { id: id.toString(), status },
	});
}
