
package com.lideeyunji.core.framework.service;

import com.lideeyunji.tool.framework.sql.build.buildmodel.wrapper.SqlInfoDeleteWrapper;
import com.lideeyunji.tool.framework.sql.build.buildmodel.wrapper.SqlInfoQueryWrapper;
import com.lideeyunji.tool.framework.sql.build.buildmodel.wrapper.SqlInfoUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lideeyunji.tool.framework.yunji.enums.LideeYunJiFieldTypeEnum;

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

/**
 * 框架SQL相关
 */
public interface IFrameSqlService {

    //运行ddl语句
    void executeDDL(String ddlSql);

    //获取数据，不做租户等其他处理
    List<Map<String, Object>> getSimpleData(String sql);

    //查询数据相关
    //单个
    Map<String, Object> getDataOneByPlus(SqlInfoQueryWrapper.Wrapper wrapper);
    Map<String, Object> getDataOneByPlus(SqlInfoQueryWrapper.Wrapper wrapper,Map<String,Object> params);
    //多个
    List<Map<String, Object>> getDataListByPlus(SqlInfoQueryWrapper.Wrapper wrapper);
    List<Map<String, Object>> getDataListByPlus(SqlInfoQueryWrapper.Wrapper wrapper,Map<String,Object> params);
    List<Map<String, Object>> getDataListByPlus(String sql,Map<String,Object> params);
    //分页
    IPage<Map<String, Object>> getDataIPageByPlus(IPage page, SqlInfoQueryWrapper.Wrapper wrapper);
    IPage<Map<String, Object>> getDataIPageByPlus(IPage page, SqlInfoQueryWrapper.Wrapper wrapper,Map<String,Object> params);

    //修改数据
    void updateDataByPlus(SqlInfoUpdateWrapper.Wrapper wrapper);

    //新增数据
    void insertDataByPlus(String tableName, Map<String,Object> addDataMap);

    void insertDataListByPlus( String tableName,
                               Map<String,String> fieldNameTypeMap,
                           List<Map<String, Object>> dataMapList);

    void insertDataByPlus(String tableName, Map<String,Object> addDataMap,Map<String, LideeYunJiFieldTypeEnum> fieldTypeEnumMap);

    //真实-删除数据
    void delRealDataByPlus(SqlInfoDeleteWrapper.Wrapper wrapper);
    //逻辑-删除数据
    void delDataByPlus(SqlInfoUpdateWrapper.Wrapper wrapper);

    //--------------------------抽取快捷方法--------------------------------
    //获取表数据
    List<Map<String,Object>> getTableDataList(String tableName);
    List<Map<String,Object>> getTableDataList(String tableName,List<String> fieldList);

    //根据Id获取数据
    Map<String,Object> getTableDataById(String tableName,Long id);
    Map<String,Object> getTableDataById(String tableName,Long id,List<String> fieldList);

    //自定义根据某一个字段查询-返回单条
    Map<String, Object> getDataOneByField(String tableName, String whereFieldName, Object whereFieldValue);
    Map<String, Object> getDataOneByField(String tableName, String whereFieldName, Object whereFieldValue,List<String> fieldList);
    //自定义根据某一个字段查询-返回多条
    List<Map<String, Object>> getDataListByField(String tableName, String whereFieldName, Object whereFieldValue);
    List<Map<String, Object>> getDataListByField(String tableName, String whereFieldName, Object whereFieldValue,List<String> fieldList);

    //公共修改
    void baseUpdateDataById(String tableName,Map<String,Object> dataMap,Long id);
    void baseUpdateDataByField(String tableName,Map<String,Object> dataMap,String whereFieldName, Object whereFieldValue);

    //公共删除-逻辑
    void baseDelDataById(String tableName,Long id);
    void baseDelDataByField(String tableName,String whereFieldName, Object whereFieldValue);

    //公共删除-真实
    void baseDelRealData(String tableName,Long id);
    void baseDelRealData(String tableName,List<Long> idList);
    void baseDelRealDataByField(String tableName,String whereFieldName, Object whereFieldValue);
}
