package com.eactive.eai.rms.onl.manage.serviceinfo.stdmessage;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.eactive.eai.rms.common.datasource.RoutingDataSource;

@Repository("stdMessageDao")
public class RestoreSTDMessageDeleteRepository {

	// oracle db2
	String truncateOracle = "TRUNCATE TABLE $schemaId$.TSEAIHS02 IGNORE DELETE TRIGGERS DROP STORAGE IMMEDIATE";

	// mysql, postgresql
	String truncatePostgresql = "TRUNCATE TABLE $schemaId$.TSEAIHS02";

	@Autowired
	private RoutingDataSource dataSource;

	public int deleteTable(String schemaId) {
		String sql = StringUtils.replace(truncatePostgresql, "$schemaId$", schemaId);
		JdbcTemplate template = new JdbcTemplate(dataSource);
		return template.update(sql);
	}

}
