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.Formula;
import com.ruoyi.ucp.mapper.FormulaMapper;
import com.ruoyi.ucp.service.IFormulaService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author gfhd
 * @since 2024-03-05
 */
@Service
public class FormulaServiceImpl extends ServiceImpl<FormulaMapper, Formula> implements IFormulaService {

    @Override
    @Cacheable("FormulaNEMap")
    public Map<String, String> getNEMap() {
        List<Formula> formulas = baseMapper.selectList(Wrappers.emptyWrapper());
        return formulas.stream().collect(Collectors.toMap(Formula::getFormulaName, Formula::getFormulaExpression));
    }
}
