package com.cico.nest.lcdp.boot.core.system.api.dict;

import com.cico.nest.lcdp.boot.core.system.service.dict.DictDataService;
import com.cico.nest.lcdp.boot.core.system.dal.dataobject.dict.DictDataDO;
import com.cico.nest.lcdp.framework.api.dict.LcdpDictDataApi;
import com.cico.nest.lcdp.framework.api.dict.dto.LcdpDictDataDTO;
import com.cico.nest.lcdp.framework.common.util.object.BeanUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

/**
 * 字典数据 API 实现类
 *
 * @author zws
 */
@Service
public class LcdpDictDataApiImpl implements LcdpDictDataApi {

    @Resource
    private DictDataService dictDataService;

    @Override
    public void validateDictDataList(String dictType, Collection<String> values) {
        dictDataService.validateDictDataList(dictType, values);
    }

    @Override
    public LcdpDictDataDTO getDictData(String dictType, String value) {
        DictDataDO dictData = dictDataService.getDictData(dictType, value);
        return BeanUtils.toBean(dictData, LcdpDictDataDTO.class);
    }

    @Override
    public LcdpDictDataDTO parseDictData(String dictType, String label) {
        DictDataDO dictData = dictDataService.parseDictData(dictType, label);
        return BeanUtils.toBean(dictData, LcdpDictDataDTO.class);
    }

    @Override
    public List<LcdpDictDataDTO> getDictDataList(String dictType) {
        List<DictDataDO> list = dictDataService.getDictDataListByDictType(dictType);
        return BeanUtils.toBean(list, LcdpDictDataDTO.class);
    }

}
