package com.samsung.embo.formula.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.samsung.embo.formula.entity.Formula;

@Repository
public class FormulaDao {
	private static final String FORMULA_MAPPER = "formulaMapper.";
	private final SqlSession sqlSession;

	public FormulaDao(SqlSession sqlSession) {
		this.sqlSession = sqlSession;
	}

	public void insertFormula(Formula formula) {
		sqlSession.insert(FORMULA_MAPPER + "insertFormula", formula);

	}

	public List<Map<String, Object>> selectFormula(Map<String, Object> params) {
		return sqlSession.selectList(FORMULA_MAPPER + "selectFormula", params);
	}

	public int deleteFormula(Map<String, Object> params) {
		
		return sqlSession.delete(FORMULA_MAPPER+ "deleteFormula", params);
	}

	public Map<String, Object> getFormula(Map<String, Object> params) {
		
		return sqlSession.selectOne(FORMULA_MAPPER+ "selectFormula", params);
	}

	public void updateFormula(Formula formula) {
		sqlSession.update(FORMULA_MAPPER + "updateFormula", formula);
		
	}
}
