/**
 * 
 */
package org.springblade.etl.mapper;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;
import java.util.Map;

/**
 * @author wookvn
 *
 */
@InterceptorIgnore(tenantLine = "true")
public interface DynamicTableMapper {
	
	/**
	 * 执行SQL
	 * @param sql
	 * @return
	 */
	@Update("${value}")
	@Options(statementType = StatementType.STATEMENT)
	public int executeSql(String sql);
	
	@Select("<script><![CDATA[ ${sql} ]]></script>")
	public List<Map<String, Object>> selectList(@Param("sql") String sql);
	
	@Select("<script><![CDATA[ ${sql} ]]></script>")
	public List<Map<String, Object>> selectPageList(IPage<?> page, @Param("sql") String sql);
	
	@Select("<script><![CDATA[ ${sql} ]]></script>")
	public IPage<Map<String, Object>> selectPage(IPage<?> page, @Param("sql") String sql);
	
	@Select("<script><![CDATA[ ${sql} ]]></script>")
	public Map<String, Object> selectOne(@Param("sql") String sql);
	
/** ------------------------------------------------------------------------- **/	
	@Select("<script><![CDATA[ ${sql} ]]></script>")
	@Deprecated
	public List<JSONObject> selectListForJSONObject(@Param("sql") String sql);
	
	@Select("<script><![CDATA[ ${sql} ]]></script>")
	@Deprecated
	public IPage<JSONObject> selectPageForJSONObject(IPage<?> page, @Param("sql") String sql);
	
	@Select("<script><![CDATA[ ${sql} ]]></script>")
	@Deprecated
	public JSONObject selectOneForJSONObject(@Param("sql") String sql);
}
