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

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
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.constant.MenuSalesTypeEnum;

public class SalesModeConverter implements Converter<Integer> {
   @Override
   public Class supportJavaTypeKey() {
      return String.class;
   }

   @Override
   public CellDataTypeEnum supportExcelTypeKey() {
      return null;
   }

   @Override
   public WriteCellData<String> convertToExcelData(Integer salesMode, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
      String type = "";
      if (ObjectUtil.isNotNull(salesMode)) {
         type = MenuSalesTypeEnum.getValue(salesMode);
      }

      return new WriteCellData(type);
   }
}
