/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.cqcis.com</a>
 */
package com.crunii.micro.service.sysmgr.jdbc;

import com.crunii.micro.domain.common.jdbc.BaseJdbcTemplate;
import com.crunii.micro.domain.common.jdbc.BaseNPJdbcTemplate;
import com.crunii.micro.domain.entity.main.TsmEncryptTest;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 田平 create 2017年8月11日下午12:44:04
 */
@Repository
public class EncryptTestJdbcDao {
	@Resource(name = "mainJT")
	protected BaseJdbcTemplate JT;

	@Resource(name = "mainNPJT")
	protected BaseNPJdbcTemplate NPJT;

	private static final String getAllEncryptsSql = "select * from tsm_encrypt_test ";
	private static final String getEncryptSql = "select * from tsm_encrypt_test where id=? ";
	private static final String getEncryptNPSql = "select * from tsm_encrypt_test where id=:id ";
	private static final String getEncryptNameSql = "select encrypt_name from tsm_encrypt_test where id=? ";
	private static final String getEncryptNameNPSql = "select encrypt_name from tsm_encrypt_test where id=:id ";

	public List<TsmEncryptTest> getAllEncrypts() {
		return JT.queryForBeans(TsmEncryptTest.class, getAllEncryptsSql);
	}

	public TsmEncryptTest getEncrypt() {
		return JT.queryForBean(TsmEncryptTest.class, getEncryptSql, 1);
	}

	public String getEncryptName() {
		return JT.queryForRawObject(String.class, getEncryptNameSql, 1);
	}

	public List<TsmEncryptTest> getAllEncryptsNP() {
		Map<String, Object> params = new HashMap<String, Object>();
		return NPJT.queryForBeans(TsmEncryptTest.class, getAllEncryptsSql, params);
	}

	public TsmEncryptTest getEncryptNP() {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", 1);
		return NPJT.queryForBean(TsmEncryptTest.class, getEncryptNPSql, params);
	}

	public String getEncryptNameNP() {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", 1);
		return NPJT.queryForRawObject(String.class, getEncryptNameNPSql, params);
	}

}
