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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.canteen.core.supply.po.CategoryModel;
import com.bonus.canteen.core.supply.domain.DrpSupplierCategory;
import com.bonus.canteen.core.supply.vo.MenuMaterialCategoryIdNameVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DrpSupplierCategoryMapper extends BaseMapper<DrpSupplierCategory> {
   @Select({"select mmc.category_id, mmc.category_name from drp_supplier_category dsc left join menu_material_category mmc on dsc.category_id = mmc.category_id ${ew.customSqlSegment}"})
   List<CategoryModel> selectNameBySupplier(@Param("ew") QueryWrapper<DrpSupplierCategory> queryWrapper);

   @Select({"select mmc.category_id, mmc.category_name from drp_supplier_category dsc left join menu_material_category mmc on dsc.category_id = mmc.category_id WHERE mmc.category_id NOT IN (SELECT parent_id FROM menu_material_category) and dsc.supplier_id = #{supplierId}"})
   List<MenuMaterialCategoryIdNameVO> listCategoryBySupplier(Long supplierId);

   @Select({"select mmc.category_id, mmc.category_name from drp_supplier_category dsc             left join menu_material_category mmc on dsc.category_id = mmc.category_id             where  dsc.supplier_id = #{supplierId} and mmc.category_type=1"})
   List<MenuMaterialCategoryIdNameVO> listMaterialCategoryBySupplier(Long supplierId);
}
