package io.renren.modules.levelManage.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.modules.levelManage.entity.UniversalTableEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

@Mapper
public interface UniversalTableDao extends BaseMapper<UniversalTableEntity> {
    Map<String,Object> selectById(@Param("id") Long id,@Param("tableName") String tableName,@Param("tableCols") List<String> tableCols);

    List<Map<String,Object>> list(@Param("tableName") String tableName,@Param("tableCols") List<String> tableCols,@Param("page") Integer page,@Param("size") Integer size);

    List<Map<String,Object>> selectByName(@Param("tableName") String tableName,@Param("tableCols") List<String> tableCols,
                                          @Param("page") Integer page,@Param("size") Integer size,@Param("name") String name);

    Integer getCountByName(@Param("tableName") String tableName,@Param("name") String name);

    Long saveWithCols(@Param("tableName") String tableName,@Param("cols") List<Map<String,Object>> cols,@Param("universalTableEntity") UniversalTableEntity universalTableEntity);

    Integer updateWithCols(@Param("tableName") String tableName,@Param("cols") List<Map<String,Object>> cols,@Param("id") Long id);

    Integer removeByIdsFromTableName(@Param("ids") List<Long> ids, @Param("tableName") String tableName);

    List<Map<String,Object>> listAllItem(@Param("tableName")String tableName);

    List<Map<String,Object>> listNotLeafItem(@Param("tableName")String tableName);

    List<Map<String,Object>> listLeafItem(@Param("tableName")String tableName,@Param("tableCols") List<String> tableCols);

    List<Map<String, Object>> listBySonIds(@Param("tableName") String tableName,@Param("tableCols") List<String> tableCols,@Param("ids") List<Long> ids,
                                           @Param("page") Integer page,@Param("size") Integer size);

    boolean updateHbaseTableName(@Param("tableName") String tableName,@Param("id") Long id,@Param("hbaseTableName") String hbaseTableName);

    String selectNameById(@Param("tableName") String tableName,@Param("id") Long id);

    Integer getCount(@Param("tableName") String tableName);

    List<Map<String, Object>> selectByNameWithParent(@Param("tableName") String tableName,@Param("tableCols") List<String> tableCols,
                                                     @Param("page") Integer page,@Param("size") Integer size,@Param("name") String name,
                                                     @Param("parentRowId") Long parentRowId,@Param("tableId") Long tableId);

    Integer getCountByNameWithParent(@Param("tableName") String tableName,@Param("name") String name,@Param("parentRowId") Long parentRowId,@Param("tableId") Long tableId);

    List<Map<String, Object>> listItemWithLeafInfo(@Param("tableName")String tableName);

    List<Map<String,Object>> listNotLeafItemInfo(@Param("tableName")String tableName,@Param("tableCols") List<String> tableCols);

    List<Map<String,Object>> listAllItemInfo(@Param("tableName")String tableName,@Param("tableCols") List<String> tableCols);

    List<Map<String, Object>> listBySonIdsNotLimit(@Param("tableName") String tableName,@Param("tableCols") List<String> tableCols,@Param("ids") List<Long> ids);
}