import httpRequest from "@/utils/httpRequest";
import { HOTEL_ORDER_PATH as prefix } from "../AppPath";

/**
 * 菜品规格管理API服务
 */
export default class HotelDishSpecService {
	/** 分页查询规格组列表 */
	groupPage(params) {
		return httpRequest({
			url: prefix + "/dishSpecGroup/page",
			method: "get",
			params,
		});
	}

	/** 根据菜品ID查询所有规格组（含选项） */
	findByDishId(dishId) {
		return httpRequest({
			url: prefix + "/dishSpecGroup/findByDishId",
			method: "get",
			params: { dishId },
		});
	}

	/** 查询规格组详情 */
	queryGroupById(id) {
		return httpRequest({
			url: prefix + "/dishSpecGroup/queryById",
			method: "get",
			params: { id },
		});
	}

	/** 新增/编辑规格组 */
	saveGroup(data) {
		return httpRequest({
			url: prefix + "/dishSpecGroup/save",
			method: "post",
			data,
		});
	}

	/** 删除规格组 */
	deleteGroup(id) {
		return httpRequest({
			url: prefix + "/dishSpecGroup/delete/" + id,
			method: "post",
		});
	}

	// ==================== 规格选项 ====================

	/** 根据规格组ID查询所有选项 */
	findOptionsByGroupId(groupId) {
		return httpRequest({
			url: prefix + "/dishSpecOption/findByGroupId",
			method: "get",
			params: { groupId },
		});
	}

	/** 查询规格选项详情 */
	queryOptionById(id) {
		return httpRequest({
			url: prefix + "/dishSpecOption/queryById",
			method: "get",
			params: { id },
		});
	}

	/** 新增/编辑规格选项 */
	saveOption(data) {
		return httpRequest({
			url: prefix + "/dishSpecOption/save",
			method: "post",
			data,
		});
	}

	/** 删除规格选项 */
	deleteOption(id) {
		return httpRequest({
			url: prefix + "/dishSpecOption/delete/" + id,
			method: "post",
		});
	}
}
