
package com.jeelowcode.core.framework.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.annotation.Master;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeelowcode.framework.tenant.annotation.JeeLowCodeTenantIgnore;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;

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

/**
 * 低代码平台 sql执行类
 */

public interface JeeLowCodeSqlMapper {

    //运行ddl语句
    @DS(value = "#dataSourceType")
    @Update("${ddlSql}")
    void executeDDL(@Param("dataSourceType") String dataSourceType,@Param("ddlSql") String ddlSql);

    //获取数据 - 多个
    @DS(value = "#dataSourceType")
    @Select("${jeeLowCodeSelectSql}")
    @Options(statementType = StatementType.STATEMENT)
    List<Map<String, Object>> selectData(@Param("dataSourceType") String dataSourceType,@Param("jeeLowCodeSelectSql") String jeeLowCodeSelectSql,@Param("ew") Map<String,Object> ew);

    //分页
    @DS(value = "#dataSourceType")
    @Select("${jeeLowCodeSelectSql}")
    @Options(statementType = StatementType.STATEMENT)
    IPage<Map<String, Object>> selectPageData(@Param("dataSourceType") String dataSourceType,IPage page,@Param("jeeLowCodeSelectSql") String jeeLowCodeSelectSql,@Param("ew") Map<String,Object> ew);

    //新增数据
    @DS(value = "#dataSourceType")
    @Insert("${jeeLowCodeInsertSql}")
    void insertData(@Param("dataSourceType") String dataSourceType,@Param("jeeLowCodeInsertSql")  String jeeLowCodeInsertSql,@Param("ew") Map<String,Object> ew);

    //修改数据
    @DS(value = "#dataSourceType")
    @Update("${jeeLowCodeUpdateSql}")
    void updateData(@Param("dataSourceType") String dataSourceType,@Param("jeeLowCodeUpdateSql") String jeeLowCodeUpdateSql,@Param("ew") Map<String,Object> ew);

    //删除数据
    @DS(value = "#dataSourceType")
    @Delete("${jeeLowCodeDeleteSql}")
    void deleteData(@Param("dataSourceType") String dataSourceType,@Param("jeeLowCodeDeleteSql") String jeeLowCodeDeleteSql,@Param("ew") Map<String,Object> ew);

}
