
top.hmtools.mapper.plus.mysql.select.SelectMapperPlusProvider Maven / Gradle / Ivy
package top.hmtools.mapper.plus.mysql.select;
import java.util.Set;
import org.apache.ibatis.mapping.MappedStatement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tk.mybatis.mapper.entity.EntityColumn;
import tk.mybatis.mapper.mapperhelper.EntityHelper;
import tk.mybatis.mapper.mapperhelper.MapperHelper;
import tk.mybatis.mapper.mapperhelper.SqlHelper;
import top.hmtools.mapper.plus.mysql.BaseMysql;
/**
* 通用mapper扩展方法具体实现
*
查
* @author HyboJ
*
*/
public class SelectMapperPlusProvider extends BaseMysql {
private final Logger logger = LoggerFactory.getLogger(SelectMapperPlusProvider.class);
public SelectMapperPlusProvider(Class> mapperClass, MapperHelper mapperHelper) {
super(mapperClass, mapperHelper);
}
/**
* 获取所有数据
* @param ms
* @return
*/
public String getAll(MappedStatement ms){
final Class> entityClass = getEntityClass(ms);
//修改返回值类型为实体类型
setResultType(ms, entityClass);
//组装查询mybatis sql 脚本模板
return this.mergeToSQLstr(entityClass, "select/getAll");
}
/**
* 指定主键名称(Java类字段名字符串),主键集合,获取指定记录集合
* @param ms
* @return
*/
public String getSomeByPk(MappedStatement ms){
final Class> entityClass = getEntityClass(ms);
//修改返回值类型为实体类型
setResultType(ms, entityClass);
return this.mergeToSQLstr(entityClass, "select/getSomeByPk");
}
/**
* 指定主键名称(Java类字段名字符串),主键集合,获取指定记录总数。入参为空,会返回所有数据
* @param ms
* @return
*/
public String getCountByPk (MappedStatement ms){
final Class> entityClass = getEntityClass(ms);
return this.mergeToSQLstr(entityClass, "select/getCountByPk");
}
/**
* 根据条件获取对应数据
*
为能够结合pagehelper分页插件使用,本方法输出的SQL语句不含“limit”
* @param ms
* @return
*/
public String getSomeByCondition (MappedStatement ms){
Class> entityClass = getEntityClass(ms);
//修改返回值类型为实体类型
setResultType(ms, entityClass);
return this.mergeToSQLstr(entityClass, "select/getSomeByCondition");
}
/**
* 根据条件获取对应数据总数
* @param ms
* @return
*/
public String getCountByCondition (MappedStatement ms){
Class> entityClass = getEntityClass(ms);
return this.mergeToSQLstr(entityClass, "select/getCountByCondition");
}
/**
* 根据指定的主键名称、主键集合,获取数据库中存在的主键集合数据
*
为能够结合pagehelper分页插件使用,本方法输出的SQL语句不含“limit”
* @param ms
* @return
*/
public String getExistPksByPk (MappedStatement ms){
Class> entityClass = getEntityClass(ms);
return this.mergeToSQLstr(entityClass, "select/getExistPksByPk");
}
/**
* 根据指定的主键名称、主键集合,获取数据库中存在的主键集合数据总数
* @param ms
* @return
*/
public String getExistPksCountByPk (MappedStatement ms){
Class> entityClass = getEntityClass(ms);
return this.mergeToSQLstr(entityClass, "select/getExistPksCountByPk");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy