
package com.lideeyunji.core.framework.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.*;

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

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

public interface LideeYunJiSqlMapper {

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

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

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

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

    @DS(value = "#dataSourceType")
    void insertDataList(@Param("dataSourceType") String dataSourceType,
                        @Param("tableName") String tableName,
                        @Param("fieldNameAndTypeList") Map<String,String> fieldNameAndTypeList,
                        @Param("dataMapList") List<Map<String, Object>> dataMapList);

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

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

}
