com.silentgo.orm.sqlparser.daoresolve.CommonDaoResolver Maven / Gradle / Ivy
package com.silentgo.orm.sqlparser.daoresolve;
import com.silentgo.orm.base.*;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* Project : parent
* Package : com.silentgo.orm.sqlparser.daoresolve
*
* @author teddyzhu
*
* Created by teddyzhu on 16/9/28.
*/
public class CommonDaoResolver implements DaoResolver {
private static final ArrayList methodNames = new ArrayList() {{
add("queryByPrimaryKey");
add("queryByPrimaryKeys");
add("queryByModelSelective");
add("insertByRow");
add("insertByRows");
add("updateByPrimaryKey");
add("updateByPrimaryKeyOptional");
add("updateByPrimaryKeySelective");
add("deleteByPrimaryKey");
add("deleteByPrimaryKeys");
add("queryAll");
add("deleteAll");
add("queryCustom");
add("countCustom");
}};
@Override
public boolean handle(String methodName, List parsedMethod, List annotations) {
return methodNames.contains(methodName);
}
@Override
public SQLTool processSQL(String methodName, Class> returnType, Object[] objects, Integer[] objectIndex, List parsedMethod, BaseTableInfo tableInfo, SQLTool sqlTool, List annotations, boolean[] isHandled, BaseDaoDialect daoDialect, Map nameObjects) {
isHandled[0] = true;
switch (methodName) {
case "queryByPrimaryKey": {
return daoDialect.queryByPrimaryKey(tableInfo, objects[0]);
}
case "queryByPrimaryKeys": {
return daoDialect.queryByPrimaryKeys(tableInfo, (Collection