package com.retdata.yaoyibi.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.retdata.yaoyibi.domain.CsoSysDictItem;
import com.retdata.yaoyibi.mapper.CsoSysDictItemMapper;
import com.retdata.yaoyibi.service.CsoSysDictItemService;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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

@Service
@Transactional(readOnly = true)
@DataSource(DataSourceType.CSO)
public class CsoSysDictItemServiceImpl extends ServiceImpl<CsoSysDictItemMapper, CsoSysDictItem>
        implements CsoSysDictItemService {
    @Override
    public Map<String, String> getDictMap(String dictType) {
        List<CsoSysDictItem> items = query().eq(CsoSysDictItem.TYPE, dictType)
                .eq(CsoSysDictItem.DEL_FLAG, "0")
                .orderByAsc(CsoSysDictItem.SORT)
                .list();
        return items.stream().collect(Collectors.toMap(CsoSysDictItem::getValue, CsoSysDictItem::getLabel));
    }
    
}
