package com.lideeyunji.service.system.api;

import com.lideeyunji.tool.framework.common.util.object.BeanUtils;
import com.lideeyunji.service.system.dto.DictDataRespDTO;
import com.lideeyunji.service.system.entity.DictDataDO;
import com.lideeyunji.service.system.service.IDictDataService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;

/**
 * 字典数据 API 实现类
 *
 * @author 金灯剑客
 */
@Service
public class ApiDictDataApiImpl implements IApiDictDataApi {

    @Resource
    private IDictDataService dictDataService;

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

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

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

}
