|  | @@ -25,6 +25,7 @@ import java.math.BigDecimal;
 | 
	
		
			
				|  |  |  import java.sql.Connection;
 | 
	
		
			
				|  |  |  import java.sql.PreparedStatement;
 | 
	
		
			
				|  |  |  import java.sql.ResultSet;
 | 
	
		
			
				|  |  | +import java.sql.SQLException;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
	
		
			
				|  | @@ -34,244 +35,303 @@ import java.util.*;
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  public abstract class BaseServiceImpl<PK extends Serializable, T> implements BaseService<PK, T> {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Autowired
 | 
	
		
			
				|  |  | -	protected SqlSessionFactory sqlSessionFactory;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    protected SqlSessionFactory sqlSessionFactory;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	public abstract BaseDAO<PK, T> getDAO();
 | 
	
		
			
				|  |  | +    public abstract BaseDAO<PK, T> getDAO();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	/**
 | 
	
		
			
				|  |  | -	 * 通过主键id加载对象
 | 
	
		
			
				|  |  | -	 * @param id
 | 
	
		
			
				|  |  | -	 * @return
 | 
	
		
			
				|  |  | -	 */
 | 
	
		
			
				|  |  | -	public T get(final PK id) {
 | 
	
		
			
				|  |  | -		return this.getDAO().get(id);
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 通过主键id加载对象
 | 
	
		
			
				|  |  | +     * @param id
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public T get(final PK id) {
 | 
	
		
			
				|  |  | +        return this.getDAO().get(id);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	/**
 | 
	
		
			
				|  |  | -	 * 更新实体对象
 | 
	
		
			
				|  |  | -	 * @param bean
 | 
	
		
			
				|  |  | -	 * @return int
 | 
	
		
			
				|  |  | -	 */
 | 
	
		
			
				|  |  | -	public int update(T bean) {
 | 
	
		
			
				|  |  | -		return this.getDAO().update(bean);
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 更新实体对象
 | 
	
		
			
				|  |  | +     * @param bean
 | 
	
		
			
				|  |  | +     * @return int
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public int update(T bean) {
 | 
	
		
			
				|  |  | +        return this.getDAO().update(bean);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	/**
 | 
	
		
			
				|  |  | -	 * 通过主键id删除对象
 | 
	
		
			
				|  |  | -	 * @param id
 | 
	
		
			
				|  |  | -	 * @return int
 | 
	
		
			
				|  |  | -	 */
 | 
	
		
			
				|  |  | -	public int delete(final PK id) {
 | 
	
		
			
				|  |  | -		return this.getDAO().delete(id);
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 通过主键id删除对象
 | 
	
		
			
				|  |  | +     * @param id
 | 
	
		
			
				|  |  | +     * @return int
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public int delete(final PK id) {
 | 
	
		
			
				|  |  | +        return this.getDAO().delete(id);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	/**
 | 
	
		
			
				|  |  | -	 * 写入实体对象
 | 
	
		
			
				|  |  | -	 * @param bean
 | 
	
		
			
				|  |  | -	 * @return int
 | 
	
		
			
				|  |  | -	 */
 | 
	
		
			
				|  |  | -	public long insert(T bean) {
 | 
	
		
			
				|  |  | -		return this.getDAO().insert(bean);
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 写入实体对象
 | 
	
		
			
				|  |  | +     * @param bean
 | 
	
		
			
				|  |  | +     * @return int
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public long insert(T bean) {
 | 
	
		
			
				|  |  | +        return this.getDAO().insert(bean);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	/**
 | 
	
		
			
				|  |  | -	 * 通过参数查找所有结果集
 | 
	
		
			
				|  |  | -	 * @param params
 | 
	
		
			
				|  |  | -	 * @return
 | 
	
		
			
				|  |  | -	 */
 | 
	
		
			
				|  |  | -	public List<T> findAll(Map<String, Object> params) {
 | 
	
		
			
				|  |  | -		final String TENANT_ID = "tenantId";
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		if(!params.containsKey(TENANT_ID)){
 | 
	
		
			
				|  |  | -			params.put(TENANT_ID, TenantContextHolder.getTenantId());
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		return this.getDAO().findAll(params);
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 通过参数查找所有结果集
 | 
	
		
			
				|  |  | +     * @param params
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public List<T> findAll(Map<String, Object> params) {
 | 
	
		
			
				|  |  | +        final String TENANT_ID = "tenantId";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	/**
 | 
	
		
			
				|  |  | -	 * 通过参数查找结果集,适合分页场景
 | 
	
		
			
				|  |  | -	 * @param queryInfo
 | 
	
		
			
				|  |  | -	 * @return
 | 
	
		
			
				|  |  | -	 */
 | 
	
		
			
				|  |  | -	public PageInfo<T> queryPage(QueryInfo queryInfo) {
 | 
	
		
			
				|  |  | -		PageInfo<T> pageInfo = new PageInfo<T>(queryInfo.getPage(), queryInfo.getRows());
 | 
	
		
			
				|  |  | -		Map<String, Object> params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  | -		MapUtil.populateMap(params, queryInfo);
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		List<T> dataList = null;
 | 
	
		
			
				|  |  | -		int count = this.findCount(params);
 | 
	
		
			
				|  |  | -		if (count > 0) {
 | 
	
		
			
				|  |  | -			pageInfo.setTotal(count);
 | 
	
		
			
				|  |  | -			params.put("offset", pageInfo.getOffset());
 | 
	
		
			
				|  |  | -			dataList = this.getDAO().queryPage(params);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		if (count == 0) {
 | 
	
		
			
				|  |  | -			dataList = new ArrayList<T>();
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		pageInfo.setRows(dataList);
 | 
	
		
			
				|  |  | -		return pageInfo;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +        if(!params.containsKey(TENANT_ID)){
 | 
	
		
			
				|  |  | +            params.put(TENANT_ID, TenantContextHolder.getTenantId());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return this.getDAO().findAll(params);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	/**
 | 
	
		
			
				|  |  | -	 * 通过参数查找结果集数目
 | 
	
		
			
				|  |  | -	 * @author pengdc
 | 
	
		
			
				|  |  | -	 * @param params
 | 
	
		
			
				|  |  | -	 * @return
 | 
	
		
			
				|  |  | -	 */
 | 
	
		
			
				|  |  | -	public int findCount(Map<String, Object> params) {
 | 
	
		
			
				|  |  | -		return this.getDAO().queryCount(params);
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 通过参数查找结果集,适合分页场景
 | 
	
		
			
				|  |  | +     * @param queryInfo
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public PageInfo<T> queryPage(QueryInfo queryInfo) {
 | 
	
		
			
				|  |  | +        PageInfo<T> pageInfo = new PageInfo<T>(queryInfo.getPage(), queryInfo.getRows());
 | 
	
		
			
				|  |  | +        Map<String, Object> params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  | +        MapUtil.populateMap(params, queryInfo);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        List<T> dataList = null;
 | 
	
		
			
				|  |  | +        int count = this.findCount(params);
 | 
	
		
			
				|  |  | +        if (count > 0) {
 | 
	
		
			
				|  |  | +            pageInfo.setTotal(count);
 | 
	
		
			
				|  |  | +            params.put("offset", pageInfo.getOffset());
 | 
	
		
			
				|  |  | +            dataList = this.getDAO().queryPage(params);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (count == 0) {
 | 
	
		
			
				|  |  | +            dataList = new ArrayList<T>();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        pageInfo.setRows(dataList);
 | 
	
		
			
				|  |  | +        return pageInfo;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	public <K extends Collection, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue, K ids,Integer tenantId, Class<Y> keyType, Class<Z> valueType){
 | 
	
		
			
				|  |  | -		if(CollectionUtils.isEmpty(ids)){
 | 
	
		
			
				|  |  | -			return Collections.emptyMap();
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		StringBuffer sql=new StringBuffer();
 | 
	
		
			
				|  |  | -		Map<Y,Z> result=new HashMap();
 | 
	
		
			
				|  |  | -		try {
 | 
	
		
			
				|  |  | -			SqlSession sqlSession = sqlSessionFactory.openSession();
 | 
	
		
			
				|  |  | -			Connection connection = sqlSession.getConnection();
 | 
	
		
			
				|  |  | -			sql.append("SELECT ").append(columnKey).append(",").append(columnValue).append(" FROM ").append(tableName).append(" WHERE ").append(columnKey).append(" IN (").append(StringUtils.join(ids, ",")).append(")");
 | 
	
		
			
				|  |  | -			if(tenantId != null){
 | 
	
		
			
				|  |  | -				sql.append(" AND tenant_id_ = ").append(tenantId);
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			PreparedStatement ps = connection.prepareStatement(sql.toString());
 | 
	
		
			
				|  |  | -			ResultSet resultSet = ps.executeQuery();
 | 
	
		
			
				|  |  | -			while (resultSet.next()){
 | 
	
		
			
				|  |  | -				Y key;
 | 
	
		
			
				|  |  | -				Z value;
 | 
	
		
			
				|  |  | -				if(keyType.isAssignableFrom(BigDecimal.class)){
 | 
	
		
			
				|  |  | -					key = (Y) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(1));
 | 
	
		
			
				|  |  | -				}else if(keyType.isAssignableFrom(String.class)){
 | 
	
		
			
				|  |  | -					key = (Y) resultSet.getString(1);
 | 
	
		
			
				|  |  | -				}else{
 | 
	
		
			
				|  |  | -					key = (Y) keyType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(1));
 | 
	
		
			
				|  |  | -				}
 | 
	
		
			
				|  |  | -				if(valueType.isAssignableFrom(BigDecimal.class)){
 | 
	
		
			
				|  |  | -					value = (Z) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(2));
 | 
	
		
			
				|  |  | -				}else if(valueType.isAssignableFrom(String.class)){
 | 
	
		
			
				|  |  | -					value = (Z) resultSet.getString(2);
 | 
	
		
			
				|  |  | -				}else{
 | 
	
		
			
				|  |  | -					value = (Z) valueType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(2));
 | 
	
		
			
				|  |  | -				}
 | 
	
		
			
				|  |  | -				result.put(key, value);
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			if(resultSet!=null){
 | 
	
		
			
				|  |  | -				resultSet.close();
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			if(ps!=null){
 | 
	
		
			
				|  |  | -				ps.close();
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			if(sqlSession!=null){
 | 
	
		
			
				|  |  | -				sqlSession.close();
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -		} catch (Exception e) {
 | 
	
		
			
				|  |  | -			e.printStackTrace();
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 通过参数查找结果集数目
 | 
	
		
			
				|  |  | +     * @author pengdc
 | 
	
		
			
				|  |  | +     * @param params
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public int findCount(Map<String, Object> params) {
 | 
	
		
			
				|  |  | +        return this.getDAO().queryCount(params);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		return result;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	public <K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue, String ids, Class<Y> keyType, Class<Z> valueType){
 | 
	
		
			
				|  |  | -		if(StringUtils.isEmpty(ids)){
 | 
	
		
			
				|  |  | -			return Collections.emptyMap();
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		StringBuffer sql=new StringBuffer();
 | 
	
		
			
				|  |  | -		Map<Y,Z> result=new HashMap();
 | 
	
		
			
				|  |  | -		try {
 | 
	
		
			
				|  |  | -			SqlSession sqlSession = sqlSessionFactory.openSession();
 | 
	
		
			
				|  |  | -			Connection connection = sqlSession.getConnection();
 | 
	
		
			
				|  |  | -			sql.append("SELECT ").append(columnKey).append(",").append(columnValue).append(" FROM ").append(tableName).append(" WHERE ").append(columnKey).append(" IN (").append(ids).append(")");
 | 
	
		
			
				|  |  | -			PreparedStatement ps = connection.prepareStatement(sql.toString());
 | 
	
		
			
				|  |  | -			ResultSet resultSet = ps.executeQuery();
 | 
	
		
			
				|  |  | -			while (resultSet.next()){
 | 
	
		
			
				|  |  | -				Y key;
 | 
	
		
			
				|  |  | -				Z value;
 | 
	
		
			
				|  |  | -				if(keyType.isAssignableFrom(BigDecimal.class)){
 | 
	
		
			
				|  |  | -					key = (Y) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(1));
 | 
	
		
			
				|  |  | -				}else if(keyType.isAssignableFrom(String.class)){
 | 
	
		
			
				|  |  | -					key = (Y) resultSet.getString(1);
 | 
	
		
			
				|  |  | -				}else{
 | 
	
		
			
				|  |  | -					key = (Y) keyType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(1));
 | 
	
		
			
				|  |  | -				}
 | 
	
		
			
				|  |  | -				if(valueType.isAssignableFrom(BigDecimal.class)){
 | 
	
		
			
				|  |  | -					value = (Z) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(2));
 | 
	
		
			
				|  |  | -				}else if(valueType.isAssignableFrom(String.class)){
 | 
	
		
			
				|  |  | -					value = (Z) resultSet.getString(2);
 | 
	
		
			
				|  |  | -				}else{
 | 
	
		
			
				|  |  | -					value = (Z) valueType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(2));
 | 
	
		
			
				|  |  | -				}
 | 
	
		
			
				|  |  | -				result.put(key, value);
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			if(resultSet!=null){
 | 
	
		
			
				|  |  | -				resultSet.close();
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			if(ps!=null){
 | 
	
		
			
				|  |  | -				ps.close();
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			if(sqlSession!=null){
 | 
	
		
			
				|  |  | -				sqlSession.close();
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -		} catch (Exception e) {
 | 
	
		
			
				|  |  | -			e.printStackTrace();
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public <K extends Collection, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue, K ids,Integer tenantId, Class<Y> keyType, Class<Z> valueType){
 | 
	
		
			
				|  |  | +        if(CollectionUtils.isEmpty(ids)){
 | 
	
		
			
				|  |  | +            return Collections.emptyMap();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        StringBuffer sql=new StringBuffer();
 | 
	
		
			
				|  |  | +        Map<Y,Z> result=new HashMap();
 | 
	
		
			
				|  |  | +        SqlSession sqlSession = null;
 | 
	
		
			
				|  |  | +        Connection connection = null;
 | 
	
		
			
				|  |  | +        PreparedStatement ps = null;
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            sqlSession = sqlSessionFactory.openSession();
 | 
	
		
			
				|  |  | +            connection = sqlSession.getConnection();
 | 
	
		
			
				|  |  | +            sql.append("SELECT ").append(columnKey).append(",").append(columnValue).append(" FROM ").append(tableName).append(" WHERE ").append(columnKey).append(" IN (").append(StringUtils.join(ids, ",")).append(")");
 | 
	
		
			
				|  |  | +            if(tenantId != null){
 | 
	
		
			
				|  |  | +                sql.append(" AND tenant_id_ = ").append(tenantId);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            ps = connection.prepareStatement(sql.toString());
 | 
	
		
			
				|  |  | +            ResultSet resultSet = ps.executeQuery();
 | 
	
		
			
				|  |  | +            while (resultSet.next()){
 | 
	
		
			
				|  |  | +                Y key;
 | 
	
		
			
				|  |  | +                Z value;
 | 
	
		
			
				|  |  | +                if(keyType.isAssignableFrom(BigDecimal.class)){
 | 
	
		
			
				|  |  | +                    key = (Y) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(1));
 | 
	
		
			
				|  |  | +                }else if(keyType.isAssignableFrom(String.class)){
 | 
	
		
			
				|  |  | +                    key = (Y) resultSet.getString(1);
 | 
	
		
			
				|  |  | +                }else{
 | 
	
		
			
				|  |  | +                    key = (Y) keyType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(1));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(valueType.isAssignableFrom(BigDecimal.class)){
 | 
	
		
			
				|  |  | +                    value = (Z) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(2));
 | 
	
		
			
				|  |  | +                }else if(valueType.isAssignableFrom(String.class)){
 | 
	
		
			
				|  |  | +                    value = (Z) resultSet.getString(2);
 | 
	
		
			
				|  |  | +                }else{
 | 
	
		
			
				|  |  | +                    value = (Z) valueType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(2));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                result.put(key, value);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if(resultSet!=null){
 | 
	
		
			
				|  |  | +                resultSet.close();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if(ps!=null){
 | 
	
		
			
				|  |  | +                ps.close();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if(sqlSession!=null){
 | 
	
		
			
				|  |  | +                sqlSession.close();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            e.printStackTrace();
 | 
	
		
			
				|  |  | +        } finally {
 | 
	
		
			
				|  |  | +            if(ps!=null){
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    ps.close();
 | 
	
		
			
				|  |  | +                } catch (SQLException e) {
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if(sqlSession!=null){
 | 
	
		
			
				|  |  | +                sqlSession.close();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if(connection!=null){
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    connection.close();
 | 
	
		
			
				|  |  | +                } catch (SQLException e) {
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		return result;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +            return result;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        @Override
 | 
	
		
			
				|  |  | +        public <K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue, String ids, Class<Y> keyType, Class<Z> valueType){
 | 
	
		
			
				|  |  | +            if(StringUtils.isEmpty(ids)){
 | 
	
		
			
				|  |  | +                return Collections.emptyMap();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            StringBuffer sql=new StringBuffer();
 | 
	
		
			
				|  |  | +            Map<Y,Z> result=new HashMap();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	public <K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue,Boolean hasDelFlag,Integer tenantId, Class<Y> keyType, Class<Z> valueType){
 | 
	
		
			
				|  |  | -		StringBuffer sql=new StringBuffer();
 | 
	
		
			
				|  |  | -		Map<Y,Z> result=new HashMap();
 | 
	
		
			
				|  |  | -		try {
 | 
	
		
			
				|  |  | -			SqlSession sqlSession = sqlSessionFactory.openSession();
 | 
	
		
			
				|  |  | -			Connection connection = sqlSession.getConnection();
 | 
	
		
			
				|  |  | -			sql.append("SELECT ").append(columnKey).append(",").append(columnValue).append(" FROM ").append(tableName).append(" WHERE 1 = 1");
 | 
	
		
			
				|  |  | -			if(hasDelFlag){
 | 
	
		
			
				|  |  | -				sql.append(" AND del_flag_ = 0");
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			if(tenantId != null){
 | 
	
		
			
				|  |  | -				sql.append(" AND tenant_id_ = ").append(tenantId);
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			PreparedStatement ps = connection.prepareStatement(sql.toString());
 | 
	
		
			
				|  |  | -			ResultSet resultSet = ps.executeQuery();
 | 
	
		
			
				|  |  | -			while (resultSet.next()){
 | 
	
		
			
				|  |  | -				Y key;
 | 
	
		
			
				|  |  | -				Z value;
 | 
	
		
			
				|  |  | -				if(keyType.isAssignableFrom(BigDecimal.class)){
 | 
	
		
			
				|  |  | -					key = (Y) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(1));
 | 
	
		
			
				|  |  | -				}else if(keyType.isAssignableFrom(String.class)){
 | 
	
		
			
				|  |  | -					key = (Y) resultSet.getString(1);
 | 
	
		
			
				|  |  | -				}else{
 | 
	
		
			
				|  |  | -					key = (Y) keyType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(1));
 | 
	
		
			
				|  |  | -				}
 | 
	
		
			
				|  |  | -				if(valueType.isAssignableFrom(BigDecimal.class)){
 | 
	
		
			
				|  |  | -					value = (Z) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(2));
 | 
	
		
			
				|  |  | -				}else if(valueType.isAssignableFrom(String.class)){
 | 
	
		
			
				|  |  | -					value = (Z) resultSet.getString(2);
 | 
	
		
			
				|  |  | -				}else{
 | 
	
		
			
				|  |  | -					value = (Z) valueType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(2));
 | 
	
		
			
				|  |  | -				}
 | 
	
		
			
				|  |  | -				result.put(key, value);
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			if(resultSet!=null){
 | 
	
		
			
				|  |  | -				resultSet.close();
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			if(ps!=null){
 | 
	
		
			
				|  |  | -				ps.close();
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			if(sqlSession!=null){
 | 
	
		
			
				|  |  | -				sqlSession.close();
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -		} catch (Exception e) {
 | 
	
		
			
				|  |  | -			e.printStackTrace();
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +            SqlSession sqlSession = null;
 | 
	
		
			
				|  |  | +            Connection connection = null;
 | 
	
		
			
				|  |  | +            PreparedStatement ps = null;
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                sqlSession = sqlSessionFactory.openSession();
 | 
	
		
			
				|  |  | +                connection = sqlSession.getConnection();
 | 
	
		
			
				|  |  | +                sql.append("SELECT ").append(columnKey).append(",").append(columnValue).append(" FROM ").append(tableName).append(" WHERE ").append(columnKey).append(" IN (").append(ids).append(")");
 | 
	
		
			
				|  |  | +                ps = connection.prepareStatement(sql.toString());
 | 
	
		
			
				|  |  | +                ResultSet resultSet = ps.executeQuery();
 | 
	
		
			
				|  |  | +                while (resultSet.next()){
 | 
	
		
			
				|  |  | +                    Y key;
 | 
	
		
			
				|  |  | +                    Z value;
 | 
	
		
			
				|  |  | +                    if(keyType.isAssignableFrom(BigDecimal.class)){
 | 
	
		
			
				|  |  | +                        key = (Y) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(1));
 | 
	
		
			
				|  |  | +                    }else if(keyType.isAssignableFrom(String.class)){
 | 
	
		
			
				|  |  | +                        key = (Y) resultSet.getString(1);
 | 
	
		
			
				|  |  | +                    }else{
 | 
	
		
			
				|  |  | +                        key = (Y) keyType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(1));
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if(valueType.isAssignableFrom(BigDecimal.class)){
 | 
	
		
			
				|  |  | +                        value = (Z) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(2));
 | 
	
		
			
				|  |  | +                    }else if(valueType.isAssignableFrom(String.class)){
 | 
	
		
			
				|  |  | +                        value = (Z) resultSet.getString(2);
 | 
	
		
			
				|  |  | +                    }else{
 | 
	
		
			
				|  |  | +                        value = (Z) valueType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(2));
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    result.put(key, value);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(resultSet!=null){
 | 
	
		
			
				|  |  | +                    resultSet.close();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(ps!=null){
 | 
	
		
			
				|  |  | +                    ps.close();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(sqlSession!=null){
 | 
	
		
			
				|  |  | +                    sqlSession.close();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } catch (Exception e) {
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  | +            }finally {
 | 
	
		
			
				|  |  | +                if(ps!=null){
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        ps.close();
 | 
	
		
			
				|  |  | +                    } catch (SQLException e) {
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(sqlSession!=null){
 | 
	
		
			
				|  |  | +                    sqlSession.close();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(connection!=null){
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        connection.close();
 | 
	
		
			
				|  |  | +                    } catch (SQLException e) {
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		return result;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +            return result;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        @Override
 | 
	
		
			
				|  |  | +        public <K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue,Boolean hasDelFlag,Integer tenantId, Class<Y> keyType, Class<Z> valueType){
 | 
	
		
			
				|  |  | +            StringBuffer sql=new StringBuffer();
 | 
	
		
			
				|  |  | +            Map<Y,Z> result=new HashMap();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            SqlSession sqlSession = null;
 | 
	
		
			
				|  |  | +            Connection connection = null;
 | 
	
		
			
				|  |  | +            PreparedStatement ps = null;
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                sqlSession = sqlSessionFactory.openSession();
 | 
	
		
			
				|  |  | +                connection = sqlSession.getConnection();
 | 
	
		
			
				|  |  | +                sql.append("SELECT ").append(columnKey).append(",").append(columnValue).append(" FROM ").append(tableName).append(" WHERE 1 = 1");
 | 
	
		
			
				|  |  | +                if(hasDelFlag){
 | 
	
		
			
				|  |  | +                    sql.append(" AND del_flag_ = 0");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(tenantId != null){
 | 
	
		
			
				|  |  | +                    sql.append(" AND tenant_id_ = ").append(tenantId);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                ps = connection.prepareStatement(sql.toString());
 | 
	
		
			
				|  |  | +                ResultSet resultSet = ps.executeQuery();
 | 
	
		
			
				|  |  | +                while (resultSet.next()){
 | 
	
		
			
				|  |  | +                    Y key;
 | 
	
		
			
				|  |  | +                    Z value;
 | 
	
		
			
				|  |  | +                    if(keyType.isAssignableFrom(BigDecimal.class)){
 | 
	
		
			
				|  |  | +                        key = (Y) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(1));
 | 
	
		
			
				|  |  | +                    }else if(keyType.isAssignableFrom(String.class)){
 | 
	
		
			
				|  |  | +                        key = (Y) resultSet.getString(1);
 | 
	
		
			
				|  |  | +                    }else{
 | 
	
		
			
				|  |  | +                        key = (Y) keyType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(1));
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if(valueType.isAssignableFrom(BigDecimal.class)){
 | 
	
		
			
				|  |  | +                        value = (Z) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(2));
 | 
	
		
			
				|  |  | +                    }else if(valueType.isAssignableFrom(String.class)){
 | 
	
		
			
				|  |  | +                        value = (Z) resultSet.getString(2);
 | 
	
		
			
				|  |  | +                    }else{
 | 
	
		
			
				|  |  | +                        value = (Z) valueType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(2));
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    result.put(key, value);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(resultSet!=null){
 | 
	
		
			
				|  |  | +                    resultSet.close();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(ps!=null){
 | 
	
		
			
				|  |  | +                    ps.close();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(sqlSession!=null){
 | 
	
		
			
				|  |  | +                    sqlSession.close();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } catch (Exception e) {
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  | +            }finally {
 | 
	
		
			
				|  |  | +                if(ps!=null){
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        ps.close();
 | 
	
		
			
				|  |  | +                    } catch (SQLException e) {
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(sqlSession!=null){
 | 
	
		
			
				|  |  | +                    sqlSession.close();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(connection!=null){
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        connection.close();
 | 
	
		
			
				|  |  | +                    } catch (SQLException e) {
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return result;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  }
 |