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

export default class HotelDishService {
    // ============ 菜品管理 ============

    /** 管理后台-菜品分页查询 */
    page(params) {
        return httpRequest({
            url: prefix + "/dish/page",
            method: "get",
            params,
        });
    }

    /** 客户端-菜品分页查询 */
    clientPage(params) {
        return httpRequest({
            url: prefix + "/dish/clientPage",
            method: "get",
            params,
        });
    }

    /** 查询菜品详情 */
    queryById(id) {
        return httpRequest({
            url: prefix + "/dish/detail/" + id,
            method: "get",
        });
    }

    /** 新增/编辑菜品 */
    save(data) {
        return httpRequest({
            url: prefix + "/dish/save",
            method: "post",
            data,
        });
    }

    /** 删除菜品 */
    delete(id) {
        return httpRequest({
            url: prefix + "/dish/delete/" + id,
            method: "post",
        });
    }

    /** 更新菜品状态 */
    updateStatus(id, status) {
        return httpRequest({
            url: prefix + "/dish/updateStatus",
            method: "post",
            data: { id: id, status: status },
        });
    }

    /** 标记售罄 */
    markSoldOut(id) {
        return httpRequest({
            url: prefix + "/dish/soldOut/" + id,
            method: "post",
        });
    }

    /** 恢复上架 */
    restore(id) {
        return httpRequest({
            url: prefix + "/dish/restore/" + id,
            method: "post",
        });
    }

    /** 批量操作 */
    batch(data) {
        return httpRequest({
            url: prefix + "/dish/batch",
            method: "post",
            data,
        });
    }

    /** 销量排行 */
    ranking(limit) {
        return httpRequest({
            url: prefix + "/dish/ranking",
            method: "get",
            params: { limit: limit || 10 },
        });
    }

    // ============ 菜品分类 ============

    /** 分页查询分类 */
    categoryPage(params) {
        return httpRequest({
            url: prefix + "/dishCategory/page",
            method: "get",
            params,
        });
    }

    /** 查询所有启用的分类 */
    categoryAll() {
        return httpRequest({
            url: prefix + "/dishCategory/all",
            method: "get",
        });
    }

    /** 新增/编辑分类 */
    categorySave(data) {
        return httpRequest({
            url: prefix + "/dishCategory/save",
            method: "post",
            data,
        });
    }

    /** 切换分类状态 */
    categoryToggleStatus(id) {
        return httpRequest({
            url: prefix + "/dishCategory/toggleStatus/" + id,
            method: "post",
        });
    }

    /** 删除分类 */
    categoryDelete(id) {
        return httpRequest({
            url: prefix + "/dishCategory/delete/" + id,
            method: "post",
        });
    }
}
