package com.codvision.auth.support.excel;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.codvision.base.config.excel.select.ExcelDynamicSelect;
import com.codvision.base.entity.SysDictItem;
import com.codvision.base.service.ISysDictItemService;

import java.util.ArrayList;
import java.util.List;

/**
 * @author KX
 * @date 2023/5/17 16:11
 */
public class NationDynamicSelect implements ExcelDynamicSelect {

    @Override
    public String[] getSource() {
        ISysDictItemService itemService = SpringUtil.getBean(ISysDictItemService.class);
        List<String> sourceList = new ArrayList<>();

        SysDictItem queryBean = new SysDictItem();
        queryBean.setDictType("NATION");

        List<SysDictItem> itemList = itemService.getItemList(queryBean);

        for (SysDictItem sysDictItem : itemList) {
            sourceList.add(sysDictItem.getLabel());
        }
        return ArrayUtil.toArray(sourceList, String.class);
    }
}
