package com.ruoyi.ucp.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.ucp.entity.EquipmentModel;
import com.ruoyi.ucp.mapper.EquipmentModelMapper;
import com.ruoyi.ucp.service.IEquipmentModelService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author gfhd
 * @since 2024-05-20
 */
@Service
public class EquipmentModelServiceImpl extends ServiceImpl<EquipmentModelMapper, EquipmentModel> implements IEquipmentModelService {

    @Cacheable("equipment_model_map")
    public Map<String, EquipmentModel> map() {
        List<EquipmentModel> models = baseMapper.selectList(Wrappers.emptyWrapper());
        return models.stream().collect(Collectors.toMap(EquipmentModel::getId, Function.identity()));
    }
}
