SelectIgnoreLogicDeleteById.java
1.26 KB
package com.tianting.infoloop.inject;
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 org.apache.ibatis.scripting.defaults.RawSqlSource;
/**
* 查询满足条件一条数据,无论是否已逻辑删除
*
* @see com.baomidou.mybatisplus.core.enums.SqlMethod#SELECT_BY_ID
* @see com.baomidou.mybatisplus.core.injector.methods.SelectById
*/
public class SelectIgnoreLogicDeleteById extends AbstractMethod {
String sql = "SELECT %s FROM %s WHERE %s=#{%s}";
/**
* @param methodName 方法名
* @since 3.5.0
*/
protected SelectIgnoreLogicDeleteById(String methodName) {
super(methodName);
}
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
SqlSource sqlSource = new RawSqlSource(configuration, String.format(sql,
sqlSelectColumns(tableInfo, false),
tableInfo.getTableName(), tableInfo.getKeyColumn(), tableInfo.getKeyProperty()), Object.class);
return this.addSelectMappedStatementForTable(mapperClass, methodName, sqlSource, tableInfo);
}
}