All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gccloud.starter.common.mybatis.injector.methods.SelectMaps Maven / Gradle / Ivy

package com.gccloud.starter.common.mybatis.injector.methods;

/**
 * 查询满足条件所有数据
 *
 * @author liuchengbiao
 * @date 2021/7/9 9:44 上午
 */

import com.baomidou.mybatisplus.core.enums.SqlMethod;
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;

import java.util.Map;

public class SelectMaps extends AbstractMethod {

    @Override
    public MappedStatement injectMappedStatement(Class mapperClass, Class modelClass, TableInfo tableInfo) {
        SqlMethod sqlMethod = SqlMethod.SELECT_MAPS;
        String sql = String.format(sqlMethod.getSql(), sqlFirst(), sqlSelectColumns(tableInfo, true), tableInfo.getTableName(),
                sqlWhereEntityWrapper(true, tableInfo), sqlComment());
        String allColumn = tableInfo.getAllSqlSelect();
        // 修改select * 为 select 具体列名,保证符合上云规范
        sql = sql.replaceFirst("\\*", "" + allColumn + "");
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
        return this.addSelectMappedStatementForOther(mapperClass, getMethod(sqlMethod), sqlSource, Map.class);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy