package cn.iocoder.yudao.module.system.convert.excel;

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;

/**
 * @Author: jinyd
 * @CreateTime: 2025/3/14  14:18
 * @Description:
 * @Version: 4.0
 */


public class StatusConverter implements Converter<Integer> {

    @Override
    public Class<?> supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        if (value == null) {
            return new WriteCellData<>("未知");
        }
        switch (value) {
            case 0: return new WriteCellData<>("正常");
            case 1: return new WriteCellData<>("禁用");
            default: return new WriteCellData<>("未知");
        }
    }

}
