Przeglądaj źródła

增加SWConsts.debug,是否调试模式,调试模式缓存从数据库加载

4.0
郑根木 2 lat temu
rodzic
commit
5ad0bfb6c6
4 zmienionych plików z 22 dodań i 11 usunięć
  1. +5
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/BpmStartedListener.java
  2. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHandler.java
  3. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHelper.java
  4. +15
    -9
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/TreeHelper.java

+ 5
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/BpmStartedListener.java Wyświetl plik

@@ -5,8 +5,11 @@ import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.impl.DatabaseUtil;
import cc.smtweb.framework.core.db.vo.ModelCatalog;
import cc.smtweb.framework.core.mvc.service.TreeHelper;
import cc.smtweb.framework.core.systask.TaskStartEvent;
import cc.smtweb.framework.core.systask.WebStartedEvent;
import cc.smtweb.system.bpm.web.design.db.ModelCatalogTreeHelper;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.EventListener;
@@ -26,5 +29,7 @@ public class BpmStartedListener implements ApplicationListener<ApplicationStarte
new DatabaseUtil(true, false).checkDb();
//初始化缓存
CacheManager.getIntance().init();
TreeHelper.regTreeHelper(ModelCatalog.ENTITY_NAME, ModelCatalogTreeHelper.class);
}
}

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHandler.java Wyświetl plik

@@ -48,7 +48,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>
prj_id = params.readLong("prj_id");
exc_empty = params.readBool("exc_empty");
exc_depend = params.readBool("exc_depend");
mcTreeHelper = (ModelCatalogTreeHelper) TreeHelper.getTreeHelper(ModelCatalog.ENTITY_NAME, ModelCatalogTreeHelper.class);
mcTreeHelper = (ModelCatalogTreeHelper) TreeHelper.getTreeHelper(ModelCatalog.ENTITY_NAME);
}

@Override


+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHelper.java Wyświetl plik

@@ -18,7 +18,7 @@ public class ModelCatalogTreeHelper extends TreeHelper<ModelCatalog> {
}

public List<ModelCatalog> getChildren(long id, long prj_id,boolean exc_depend, Comparator<ModelCatalog> comparator) {
if (id > 0) {
if (id > 0L) {
return getChildren(id, comparator);
}
Set<Long> setId = exc_depend ? new HashSet<>(Arrays.asList(prj_id)) : ModelProjectCache.getInstance().getDependsPrjIds(prj_id);


+ 15
- 9
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/TreeHelper.java Wyświetl plik

@@ -20,8 +20,10 @@ import java.util.concurrent.ConcurrentHashMap;
* Created by Akmm at 2022/3/17 19:56
*/
public class TreeHelper<T extends DefaultEntity> {
private static Map<String, Class<? extends TreeHelper>> mapDef;
private static Map<String, TreeHelper> mapInstance;
static {
mapDef = new HashMap<>();
mapInstance = new ConcurrentHashMap<>();
}
private String tableName;
@@ -36,20 +38,24 @@ public class TreeHelper<T extends DefaultEntity> {


public static TreeHelper getTreeHelper(String 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) {
TreeHelper bean = mapInstance.get(tableName);
if (bean != null) return bean;
Class<? extends TreeHelper> clazz = mapDef.get(tableName);
if (clazz == null) {
bean = new TreeHelper(tableName);
} else {
try {
helper = clazz.newInstance();
mapInstance.put(tableName, helper);
bean = clazz.newInstance();
} catch (Exception e) {
throw new SwException(e);
}
}
return helper;
mapInstance.put(tableName, bean);
return bean;
}

public static void regTreeHelper(String tableName, Class<? extends TreeHelper> clazz) {
mapDef.put(tableName, clazz);
}

//先禁止外部创建


Ładowanie…
Anuluj
Zapisz