package cn.sikey.hmd.service.languagedictionary;

import cn.sikey.hmd.dal.dataobject.LanguageDictionaryDO;
import cn.sikey.hmd.dal.mysql.LanguageDictionaryMapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author: nelson
 * @Date: 2025/3/31
 * @Description: 语言字典
 */
@Service
@Slf4j
public class LanguageDictionaryServiceImpl implements LanguageDictionaryService {

    @Resource
    private LanguageDictionaryMapper languageDictionaryMapper;

    /**
     * 获取语言字典
     *
     * @param type 类型
     * @return
     */
    @Override
    public Map<String, String> getLanguageDictionary(String type) {
        List<LanguageDictionaryDO> languageDictionaryDOList = languageDictionaryMapper.selectLanguageDictionaryByType(type);
        return languageDictionaryDOList.stream().collect(Collectors.toMap(LanguageDictionaryDO::getLanguageDictionaryCode, LanguageDictionaryDO::getLanguageDictionaryName, (existingValue, newValue) -> existingValue));
    }
}
