package com.platform.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.platform.dao.GatherOracleDao;
import com.platform.entities.GatherOracleInfo;
import com.platform.service.IMySqlService;

@Service(value = "mySqlService")
public class MySqlServiceImpl implements IMySqlService{
	
	@Resource(name = "gatherOracleDao")
	private GatherOracleDao gatherOracleDao;

	@Override
	public List<GatherOracleInfo> findAllMySql() throws Exception {
		List<GatherOracleInfo> result = gatherOracleDao.selectAllOracle();
		return result;
	}

	@Override
	public int deleteMySql(int id) throws Exception {
		
		int result = 0;
		if (id > 0) {
//			result = gatherOracleDao.deleteOracleById(id);
			GatherOracleInfo oracle = new GatherOracleInfo();
			oracle.setId(id);
			oracle.setRemove("1");
			result = gatherOracleDao.updateOracleById(oracle );
		}
		return result;
	}
	
	public int insertOracle(GatherOracleInfo oracle) throws Exception {
		int result = gatherOracleDao.insertOracle(oracle);
		return result;
	}

	@Override
	public int updateOracle(GatherOracleInfo oracle) throws Exception {
		int result;
		if (oracle.getId() > 0) {
			result = gatherOracleDao.updateOracleById(oracle);
		}
		else {
			result = gatherOracleDao.insertOracle(oracle);
		}
		return result;
	}

}
