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

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.SingleColumnRowMapper;

/**
 * @author 田平 create 2019年7月10日上午9:13:53
 */
public class RowMapperUtil {

	public static <T> RowMapper<T> getSingleRW(Class<T> requiredType, String sql, boolean enableEncrypt) {
		RowMapper<T> rm = null;
		if (enableEncrypt) {
			rm = SingleColumnEncryptRM.newInstance(requiredType, sql);
		} else {
			rm = SingleColumnRowMapper.newInstance(requiredType);
		}
		return rm;
	}

	public static <T> RowMapper<T> getBeanPropertyRW(Class<T> requiredType, String sql, boolean enableEncrypt) {
		RowMapper<T> rm = null;
		if (enableEncrypt) {
			rm = BeanPropertyEncryptRM.newInstance(requiredType, sql);
		} else {
			rm = BeanPropertyRowMapper.newInstance(requiredType);
		}
		return rm;
	}

}
