Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.kukababy.plus.dao.JdbcPlus Maven / Gradle / Ivy
package com.kukababy.plus.dao;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.kukababy.plus.exception.PlusRuntimeException;
import com.kukababy.plus.pager.CustPager;
import com.kukababy.plus.pager.Page;
import com.kukababy.plus.pager.Pager;
import com.kukababy.plus.pager.SqlFilter;
import com.kukababy.plus.pager.SqlInfo;
import com.kukababy.plus.pager.SqlWhere;
import com.kukababy.plus.pojo.P;
import com.kukababy.plus.pojo.SqlCfg;
import com.kukababy.plus.utils.Constant;
import com.kukababy.plus.utils.HoldUtil;
import com.kukababy.plus.utils.JsUtil;
/**
*
* 描述:
*
*
* @author [email protected]
* @date 2019年3月5日 下午10:52:30
*/
public class JdbcPlus implements InsertFace, DeleteFace, UpdateFace, SelectFace {
private static final Logger log = LoggerFactory.getLogger(JdbcPlus.class);
private InsertFace insertFace;
private DeleteFace deleteFace;
private UpdateFace updateFace;
private SelectFace selectFace;
public void setSqlCfg(SqlCfg sqlCfg) {
ScriptEngine engin = getScriptEngine(sqlCfg);
this.init(sqlCfg, engin);
}
// @PostConstruct
private void init(SqlCfg sqlCfg, ScriptEngine engin) {
insertFace = new InsertImpl(sqlCfg, engin);
deleteFace = new DeleteImpl(sqlCfg, engin);
updateFace = new UpdateImpl(sqlCfg, engin);
selectFace = new SelectImpl(sqlCfg, engin);
}
private ScriptEngine getScriptEngine(SqlCfg sqlCfg) {
String mergeJs = JsUtil.mergeJs(sqlCfg.getJsClassPath(), this.getClass());
if (log.isDebugEnabled()) {
//log.debug(Constant.LogPre + System.getProperty("line.separator") + mergeJs);
}
ScriptEngine engine = JsUtil.getScriptEngine(mergeJs);
return engine;
}
@Override
public void insert(Object entity) {
insertFace.insert(entity);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.InsertFace#insertBatch(java.util.List)
*/
@Override
public int insertBatch(List entitys) {
return insertFace.insertBatch(entitys);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.DeleteFace#delete(java.lang.Class,
* java.io.Serializable)
*/
@Override
public int deleteId(Class> entityClass, Serializable id) {
return deleteFace.deleteId(entityClass, id);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.DeleteFace#deleteBy(java.lang.Class,
* com.kukababy.plus.pojo.Param[])
*/
@Override
public int deleteBy(Class> entityClass, P... whereColVals) {
return deleteFace.deleteBy(entityClass, whereColVals);
}
/*
* (non-Javadoc)
*
* @see
* com.kukababy.plus.dao.UpdateFace#update(com.kukababy.plus.pojo.PlusPO)
*/
@Override
public int update(Object entity) {
return updateFace.update(entity);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.UpdateFace#update(java.lang.Class,
* com.kukababy.plus.pojo.PlusMap)
*/
@Override
public int update(Class> entityClass, Map plusMap) {
return updateFace.update(entityClass, plusMap);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.UpdateFace#updateBatch(java.util.List)
*/
@Override
public int updateBatch(List entitys) {
return updateFace.updateBatch(entitys);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#get(java.lang.Class,
* java.io.Serializable)
*/
@Override
public T get(Class entityClass, Serializable id) {
return selectFace.get(entityClass, id);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#getAll(java.lang.Class)
*/
@Override
public List getAll(Class entityClass) {
return selectFace.getAll(entityClass);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#select(java.lang.Class,
* com.kukababy.plus.pojo.Param[])
*/
@Override
public List selectList(Class entityClass, P... whereColVals) {
return selectFace.selectList(entityClass, whereColVals);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#selectOne(java.lang.Class,
* com.kukababy.plus.pojo.Param[])
*/
@Override
public T selectOne(Class entityClass, P... whereColVals) {
return selectFace.selectOne(entityClass, whereColVals);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#getTotal(java.lang.Class,
* com.kukababy.plus.pojo.Param[])
*/
@Override
public int getTotal(Class> entityClass, P... whereColVals) {
return selectFace.getTotal(entityClass, whereColVals);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.DeleteFace#deleteBy(java.lang.Class,
* com.kukababy.plus.pager.SqlFilter)
*/
@Override
public int deleteBy(Class> entityClass, SqlFilter sqlFilter) {
return deleteFace.deleteBy(entityClass, sqlFilter);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#select(java.lang.Class,
* com.kukababy.plus.pager.SqlFilter)
*/
@Override
public List selectList(Class entityClass, SqlFilter sqlFilter) {
return selectFace.selectList(entityClass, sqlFilter);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#selectOne(java.lang.Class,
* com.kukababy.plus.pager.SqlFilter)
*/
@Override
public T selectOne(Class entityClass, SqlFilter sqlFilter) {
return selectFace.selectOne(entityClass, sqlFilter);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#getTotal(java.lang.Class,
* com.kukababy.plus.pager.SqlFilter)
*/
@Override
public int getTotal(Class> entityClass, SqlFilter sqlFilter) {
return selectFace.getTotal(entityClass, sqlFilter);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#select(java.lang.Class,
* com.kukababy.plus.pager.Pager)
*/
@Override
public Page selectPage(Class entityClass, Pager pager) {
return selectFace.selectPage(entityClass, pager);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#select(java.lang.String,
* com.kukababy.plus.pojo.P[])
*/
@Override
public List> selectList(String functionName, P... params) {
// TODO Auto-generated method stub
return selectFace.selectList(functionName, params);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#select(java.lang.String,
* java.util.Map)
*/
@Override
public List> selectList(String functionName, Map params) {
// TODO Auto-generated method stub
return selectFace.selectList(functionName, params);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#select(java.lang.Class,
* java.lang.String, com.kukababy.plus.pojo.P[])
*/
@Override
public List selectList(Class entityClass, String functionName, P... params) {
// TODO Auto-generated method stub
return selectFace.selectList(entityClass, functionName, params);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#selectOne(java.lang.String,
* com.kukababy.plus.pojo.P[])
*/
@Override
public Map selectOne(String functionName, P... params) {
return selectFace.selectOne(functionName, params);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#selectOne(java.lang.Class,
* java.lang.String, com.kukababy.plus.pojo.P[])
*/
@Override
public T selectOne(Class entityClass, String functionName, P... params) {
return selectFace.selectOne(entityClass, functionName, params);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#getTotal(java.lang.String,
* com.kukababy.plus.pojo.P[])
*/
@Override
public int getTotal(String functionName, P... params) {
return selectFace.getTotal(functionName, params);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#select(java.lang.Class,
* java.lang.String, java.util.Map)
*/
@Override
public List selectList(Class entityClass, String functionName, Map params) {
return selectFace.selectList(entityClass, functionName, params);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#getTotal(java.lang.String,
* java.util.Map)
*/
@Override
public int getTotal(String functionName, Map params) {
return selectFace.getTotal(functionName, params);
}
/*
* (non-Javadoc)
*
* @see com.kukababy.plus.dao.SelectFace#select(java.lang.String,
* com.kukababy.plus.pager.CustPager)
*/
@Override
public Page selectPage(Class entityClass, String functionName, CustPager pager) {
return selectFace.selectPage(entityClass,functionName, pager);
}
/* (non-Javadoc)
* @see com.kukababy.plus.dao.SelectFace#selectPage(java.lang.String, com.kukababy.plus.pager.CustPager)
*/
@Override
public Page> selectPage(String functionName, CustPager pager) {
return selectFace.selectPage(functionName, pager);
}
}