Commit 0c36017d authored by yanzg's avatar yanzg

接口文档的支持

parent 3ea8716c
...@@ -22,13 +22,17 @@ import java.util.*; ...@@ -22,13 +22,17 @@ import java.util.*;
*/ */
public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao { public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
@Override
protected void initExecute(){
}
/** /**
* 获取当前主键 * 获取当前主键
* *
* @return * @return
*/ */
private String getIdentity() { private String getIdentity() {
return StringHelper.toString(this.db.queryCell(this.getClass(), "GET_KEY", "SELECT @@IDENTITY")); return StringHelper.toString(this.getDb().queryCell(this.getClass(), "GET_KEY", "SELECT @@IDENTITY"));
} }
/** /**
......
...@@ -35,7 +35,10 @@ public abstract class BaseDaoSql { ...@@ -35,7 +35,10 @@ public abstract class BaseDaoSql {
* 数据库执行类 * 数据库执行类
*/ */
@Resource @Resource
protected DbExecute db; private DbExecute db;
private boolean initSql = false;
/** /**
* 当前Dao的表结构SQL语句信息 * 当前Dao的表结构SQL语句信息
...@@ -53,6 +56,10 @@ public abstract class BaseDaoSql { ...@@ -53,6 +56,10 @@ public abstract class BaseDaoSql {
* @return * @return
*/ */
protected DbExecute getDb() { protected DbExecute getDb() {
if (this.db != null && !this.initSql) {
this.initExecute();
this.initSql = true;
}
return db; return db;
} }
...@@ -78,6 +85,11 @@ public abstract class BaseDaoSql { ...@@ -78,6 +85,11 @@ public abstract class BaseDaoSql {
} }
} }
/**
* 初始化执行
*/
protected abstract void initExecute();
/** /**
* 注册SQL语句 * 注册SQL语句
*/ */
...@@ -159,7 +171,7 @@ public abstract class BaseDaoSql { ...@@ -159,7 +171,7 @@ public abstract class BaseDaoSql {
protected int updateSql(SqlData sqlData, Object model) { protected int updateSql(SqlData sqlData, Object model) {
List<Object> paras = new ArrayList<Object>(); List<Object> paras = new ArrayList<Object>();
String sql = this.getQueryPara(paras, sqlData, model); String sql = this.getQueryPara(paras, sqlData, model);
int ret = db.update(this.getClass(), sqlData.getName(), sql, paras.toArray()); int ret = this.getDb().update(this.getClass(), sqlData.getName(), sql, paras.toArray());
this.onUpdateSql(model); this.onUpdateSql(model);
return ret; return ret;
} }
...@@ -231,7 +243,7 @@ public abstract class BaseDaoSql { ...@@ -231,7 +243,7 @@ public abstract class BaseDaoSql {
List<Object> paras = new ArrayList<>(); List<Object> paras = new ArrayList<>();
String sql = this.getQueryPara(paras, sqlData, model); String sql = this.getQueryPara(paras, sqlData, model);
// 查询数据 // 查询数据
db.query(this.getClass(), cls, handle, sqlData.getName(), sql, paras.toArray()); this.getDb().query(this.getClass(), cls, handle, sqlData.getName(), sql, paras.toArray());
} }
/** /**
...@@ -740,7 +752,7 @@ public abstract class BaseDaoSql { ...@@ -740,7 +752,7 @@ public abstract class BaseDaoSql {
} }
// 查询数据 // 查询数据
Object ret = db.queryCell(this.getClass(), sqlName, sql, paras); Object ret = this.getDb().queryCell(this.getClass(), sqlName, sql, paras);
// 写入缓存 // 写入缓存
this.cacheList.put(cacheKey, ret); this.cacheList.put(cacheKey, ret);
...@@ -770,7 +782,7 @@ public abstract class BaseDaoSql { ...@@ -770,7 +782,7 @@ public abstract class BaseDaoSql {
} }
// 查询数据 // 查询数据
List<T> ret = db.query(this.getClass(), cls, sqlName, sql, paras); List<T> ret = this.getDb().query(this.getClass(), cls, sqlName, sql, paras);
// 写入缓存 // 写入缓存
this.cacheList.put(cacheKey, ret); this.cacheList.put(cacheKey, ret);
......
...@@ -47,10 +47,13 @@ public class MessageDaoImpl extends BaseDaoImpl implements MessageDao { ...@@ -47,10 +47,13 @@ public class MessageDaoImpl extends BaseDaoImpl implements MessageDao {
"INNER JOIN ( SELECT * FROM Queue_Message WHERE (HandleTime IS NULL OR HandleTime < NOW()) " + "INNER JOIN ( SELECT * FROM Queue_Message WHERE (HandleTime IS NULL OR HandleTime < NOW()) " +
"ORDER BY HandleTime ASC,MessageId ASC {LIMIT} ) AS b ON a.MessageId = b.MessageId " + "ORDER BY HandleTime ASC,MessageId ASC {LIMIT} ) AS b ON a.MessageId = b.MessageId " +
"SET a.BatchId = ?,a.HandleTime=DATE_ADD(NOW(),INTERVAL 5 MINUTE) ", "batchId"); "SET a.BatchId = ?,a.HandleTime=DATE_ADD(NOW(),INTERVAL 5 MINUTE) ", "batchId");
}
List<MapRow> tables = this.db.query(MessageDaoImpl.class, "QUERY_TABLE_SQL", QUERY_TABLE_SQL); @Override
protected void initExecute() {
List<MapRow> tables = this.getDb().query(MessageDaoImpl.class, "QUERY_TABLE_SQL", QUERY_TABLE_SQL);
if (tables.isEmpty()) { if (tables.isEmpty()) {
this.db.update(MessageDaoImpl.class, "CREATE_TABLE_SQL", CREATE_TABLE_SQL); this.getDb().update(MessageDaoImpl.class, "CREATE_TABLE_SQL", CREATE_TABLE_SQL);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment