|
|
@@ -12,31 +12,46 @@ import cc.smtweb.framework.core.db.impl.DefaultEntity; |
|
|
|
import cc.smtweb.framework.core.db.vo.ModelField; |
|
|
|
import cc.smtweb.framework.core.db.vo.ModelTable; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
/** |
|
|
|
* Created by Akmm at 2022/3/17 19:56 |
|
|
|
*/ |
|
|
|
public class TreeHelper<T extends DefaultEntity> { |
|
|
|
private static Map<String, TreeHelper> mapInstance; |
|
|
|
static { |
|
|
|
mapInstance = new ConcurrentHashMap<>(); |
|
|
|
} |
|
|
|
private String tableName; |
|
|
|
|
|
|
|
private ModelTable table; |
|
|
|
private AbstractCache<T> cache; |
|
|
|
protected AbstractCache<T> cache; |
|
|
|
private EntityDao<T> dao; |
|
|
|
|
|
|
|
private String fieldParent; |
|
|
|
private String fieldLevelCode; |
|
|
|
|
|
|
|
//todo 待扩展,进缓存 |
|
|
|
|
|
|
|
public static TreeHelper getTreeHelper(String tableName) { |
|
|
|
return new TreeHelper(tableName); |
|
|
|
return mapInstance.computeIfAbsent(tableName, k-> new TreeHelper(tableName)); |
|
|
|
} |
|
|
|
|
|
|
|
public static TreeHelper getTreeHelper(String tableName, Class<? extends TreeHelper> clazz) { |
|
|
|
TreeHelper helper = mapInstance.get(tableName); |
|
|
|
if (helper == null) { |
|
|
|
try { |
|
|
|
helper = clazz.newInstance(); |
|
|
|
mapInstance.put(tableName, helper); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new SwException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
return helper; |
|
|
|
} |
|
|
|
|
|
|
|
//先禁止外部创建 |
|
|
|
private TreeHelper(String tableName) { |
|
|
|
protected TreeHelper(String tableName) { |
|
|
|
this.tableName = tableName; |
|
|
|
table = ModelTableCache.getInstance().getByName(tableName); |
|
|
|
cache = CacheManager.getIntance().getCache(tableName); |
|
|
|