package com.bonus.canteen.core.menu.mapper;

import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.canteen.core.menu.domain.MenuMaterialCategory;
import com.bonus.canteen.core.menu.dto.CategoryTreeListDTO;
import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 原料类别Mapper接口
 *
 * @author xsheng
 * @date 2025-04-03
 */
public interface MenuMaterialCategoryMapper extends BaseMapper<MenuMaterialCategory> {
    /**
     * 查询原料类别
     *
     * @param id 原料类别主键
     * @return 原料类别
     */
    public MenuMaterialCategory selectMenuMaterialCategoryById(Long id);

    /**
     * 查询原料类别列表
     *
     * @param menuMaterialCategory 原料类别
     * @return 原料类别集合
     */
    public List<MenuMaterialCategory> selectMenuMaterialCategoryList(MenuMaterialCategory menuMaterialCategory);

    /**
     * 新增原料类别
     *
     * @param menuMaterialCategory 原料类别
     * @return 结果
     */
    public int insertMenuMaterialCategory(MenuMaterialCategory menuMaterialCategory);

    /**
     * 修改原料类别
     *
     * @param menuMaterialCategory 原料类别
     * @return 结果
     */
    public int updateMenuMaterialCategory(MenuMaterialCategory menuMaterialCategory);

    /**
     * 删除原料类别
     *
     * @param id 原料类别主键
     * @return 结果
     */
    public int deleteMenuMaterialCategoryById(Long id);

    /**
     * 批量删除原料类别
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteMenuMaterialCategoryByIds(String[] ids);

    List<String>getChildCategoryIds(String[] ids);

    List<MenuCategoryTreeVO> selectCategoryTrees(CategoryTreeListDTO content);
    @Select({"select category_id id, parent_id, category_name,category_type,area_id from menu_material_category ${ew.customSqlSegment}"})
    List<MenuCategoryTreeVO> selectCategoryTree(CategoryTreeListDTO content);

    @Select({"select MAX(category_num) from menu_material_category where parent_id = #{parentId} and category_type = #{categoryType} "})
    String getCategoryChildMaxNum(@Param("parentId") Long parentId, @Param("categoryType") Integer categoryType, @Param("delFlag") Integer delFlag);

    MenuMaterialCategory getOne(MenuMaterialCategory menuMaterialCategory);
}
