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

com.silentgo.orm.sqlparser.daoresolve.CommonDaoResolver Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
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) objects[0]); } case "queryByModelSelective": { return daoDialect.queryByModelSelective(tableInfo, (T) objects[0]); } case "insertByRow": { return daoDialect.insertByRow(tableInfo, (T) objects[0]); } case "insertByRows": { return daoDialect.insertByRows(tableInfo, (Collection) objects[0]); } case "updateByPrimaryKey": { return daoDialect.updateByPrimaryKey(tableInfo, (T) objects[0]); } case "updateByPrimaryKeyOptional": { return daoDialect.updateByPrimaryKeyOptional(tableInfo, (T) objects[0], (Collection) objects[1]); } case "updateByPrimaryKeySelective": { return daoDialect.updateByPrimaryKeySelective(tableInfo, (T) objects[0]); } case "deleteByPrimaryKey": { return daoDialect.deleteByPrimaryKey(tableInfo, objects[0]); } case "deleteByPrimaryKeys": { return daoDialect.deleteByPrimaryKeys(tableInfo, (Collection) objects[0]); } case "queryAll": { return daoDialect.queryAll(tableInfo); } case "deleteAll": { return daoDialect.deleteAll(tableInfo); } case "queryCustom": { return (SQLTool) objects[0]; } case "countCustom": { return (SQLTool) objects[0]; } } isHandled[0] = false; return sqlTool; } }