Commit d34822f7 authored by yanzg's avatar yanzg

SQL层级处理的支持

parent cd127be2
...@@ -291,6 +291,15 @@ public interface BaseDao { ...@@ -291,6 +291,15 @@ public interface BaseDao {
*/ */
<T extends Object> String saveByLoad(Class<T> cls, Object request); <T extends Object> String saveByLoad(Class<T> cls, Object request);
/**
* 设置MD5主键
*
* @param cls
* @param model
* @param <T>
*/
<T extends Object> void setGroupId(Class<T> cls, T model);
/** /**
* 添加统计数据 * 添加统计数据
* *
......
...@@ -637,6 +637,30 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao { ...@@ -637,6 +637,30 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
return to; return to;
} }
/**
* 设置MD5主键
*
* @param cls
* @param model
* @param <T>
*/
public <T extends Object> void setGroupId(Class<T> cls, T model) {
// 判断前台实体
if (model == null) {
return;
}
// 获取前台分组的MD5标识
String md5 = this.getMd5(DaoConst.GROUP_QUERY, model);
if (!StringHelper.isEmpty(this.table.getTable().getMD5KeyName())) {
ObjectHelper.set(model, this.table.getTable().getMD5KeyName(), md5);
}
if (this.table.getTable().getKeyType() == String.class) {
this.setKeyString(model, md5);
}
}
/** /**
* 添加统计数据 * 添加统计数据
* *
...@@ -647,22 +671,16 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao { ...@@ -647,22 +671,16 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*/ */
@Override @Override
public <T extends Object> String addGroup(Class<T> cls, T model) { public <T extends Object> String addGroup(Class<T> cls, T model) {
this.setGroupId(cls, model);
// 判断前台实体 // 判断前台实体
if (model == null) { if (model == null) {
return ""; return "";
} }
// 获取前台分组的MD5标识
String md5 = this.getMd5(DaoConst.GROUP_QUERY, model);
if (!StringHelper.isEmpty(this.table.getTable().getMD5KeyName())) {
ObjectHelper.set(model, this.table.getTable().getMD5KeyName(), md5);
}
// 获取标识的实体 // 获取标识的实体
T from; T from;
if (this.table.getTable().getKeyType() == String.class) { if (this.table.getTable().getKeyType() == String.class) {
from = model; from = model;
this.setKeyString(model, md5);
} else if (!StringHelper.isEmpty(this.table.getTable().getMD5KeyName())) { } else if (!StringHelper.isEmpty(this.table.getTable().getMD5KeyName())) {
Map<String, Object> map = new HashMap<>(DaoConst.COLLECTION_INIT_SIZE); Map<String, Object> map = new HashMap<>(DaoConst.COLLECTION_INIT_SIZE);
map.put(this.table.getTable().getMD5KeyName(), md5); map.put(this.table.getTable().getMD5KeyName(), md5);
......
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