package com.bonus.canteen.core.common.utils;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.bonus.canteen.core.menu.vo.MenuEvaluateDishesVO;

import java.util.List;
import java.util.stream.Collectors;

public class DishesConverter implements Converter<List<MenuEvaluateDishesVO>> {
   public Class<?> supportJavaTypeKey() {
      return List.class;
   }

   public WriteCellData<?> convertToExcelData(List<MenuEvaluateDishesVO> value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
      if (ObjectUtil.isEmpty(value)) {
         return new WriteCellData();
      } else {
         String des = (String)value.stream().map((item) -> {
            String var10000 = item.getDishesName();
            return var10000 + " " + item.getStarLevel() + "分";
         }).collect(Collectors.joining(","));
         return new WriteCellData(des);
      }
   }
}
