io.github.jinghui70.rainbow.dbaccess.ObjectSql Maven / Gradle / Ivy
package io.github.jinghui70.rainbow.dbaccess;
import cn.hutool.core.lang.Assert;
import io.github.jinghui70.rainbow.dbaccess.object.BeanMapper;
import io.github.jinghui70.rainbow.utils.tree.ITreeNode;
import io.github.jinghui70.rainbow.utils.tree.TreeNode;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public class ObjectSql extends GeneralSql> {
private final Class queryClass;
public ObjectSql(Dba dba, Class queryClass) {
super(dba);
this.queryClass = queryClass;
}
public T queryForObject() {
return queryForObject(queryClass);
}
public Optional queryForObjectOptional() {
return queryForObjectOptional(BeanMapper.of(queryClass));
}
public List queryForList() {
return queryForList(queryClass);
}
public PageData pageQuery(int pageNo, int pageSize) {
return pageQuery(queryClass, pageNo, pageSize);
}
@SuppressWarnings({"unchecked", "rawtypes"})
public List queryForTree() {
Assert.isAssignable(TreeNode.class, queryClass);
return queryForTree((Class extends ITreeNode>) queryClass);
}
public Map queryToMap(ResultSetFunction keyFunc) {
return queryToMap(keyFunc, queryClass);
}
public Map> queryToGroup(ResultSetFunction keyFunc) {
return queryToGroup(keyFunc, queryClass);
}
}