郑根木 před 2 roky
rodič
revize
f8f613b945
5 změnil soubory, kde provedl 31 přidání a 4 odebrání
  1. +1
    -1
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/cache/CacheManager.java
  2. +7
    -3
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java
  3. +14
    -0
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/TreeHelper.java
  4. +1
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/table/ModelTableSaveHanlder.java
  5. +8
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowService.java

+ 1
- 1
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/cache/CacheManager.java Zobrazit soubor

@@ -30,7 +30,7 @@ public class CacheManager {
private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(2);

public AbstractCache getCache(String ident) {
final AbstractCache cache = cacheMap.get(ident);
final AbstractCache cache = cacheMap.get(ident.toUpperCase());
if (cache != null && cache.isNotInited()) {
cache.init();
}


+ 7
- 3
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java Zobrazit soubor

@@ -70,6 +70,9 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan
if (field.isNotNull() && StringUtils.isEmpty(bean.getStr(field.getName()))) {
throw new SwException(field.getTitle() + "不能为空!");
}
if (field.getFieldType() == SwEnum.FieldType.PARENT_ID.value) {
TreeHelper.getTreeHelper(tableName).checkParent(bean);
}
}

EntityDao dao = DbEngine.getInstance().findDao(tableName);
@@ -144,16 +147,17 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan
} else {
bean = loadComp(id);
}
TreeHelper.getTreeHelper(tableName).checkParent(bean);
//不考虑没有级次码等情况,这个在表设计时校验
ModelField fieldParentCode = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value);
ModelField fieldParentId = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value);

bean.put(fieldParentCode.getName(), parentId);
bean.put(fieldParentId.getName(), parentId);
DbEngine.getInstance().doTrans(new AbsDbWorker() {
@Override
public void work() {
EntityDao dao = DbEngine.getInstance().findDao(tableName);
listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean);
dao.updateEntity(bean, fieldParentCode.getName());
dao.updateEntity(bean, fieldParentId.getName());
}

@Override


+ 14
- 0
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/TreeHelper.java Zobrazit soubor

@@ -88,6 +88,20 @@ public class TreeHelper<T extends DefaultEntity> {
return list;
}

public void checkParent(T bean) {
if (table.getType() != SwEnum.TableType.TYPE_TREE.value) return;
if (!table.isNeedCache()) throw new SwException("请定义为需要缓存!");
long pId = getParentId(bean);
if (bean.getEntityId() == pId) throw new SwException("上级节点不能为自己!");
if (pId <= 0) return;
T parent = cache.get(pId);
if (parent == null) return;
String plevelcode = SwConsts.SPLIT_CHAR + parent.getStr(fieldLevelCode) + SwConsts.SPLIT_CHAR;
if (plevelcode.contains(SwConsts.SPLIT_CHAR + bean.getEntityId() + SwConsts.SPLIT_CHAR)) {
throw new SwException("上级节点不能为自己的下级!");
}
}

public List<T> resetTreeLevel(T bean) {
List<T> list = new ArrayList<>();
if (table.getType() != SwEnum.TableType.TYPE_TREE.value) return list;


+ 1
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/table/ModelTableSaveHanlder.java Zobrazit soubor

@@ -15,5 +15,6 @@ public class ModelTableSaveHanlder extends DefaultSaveHandler<ModelTable> {
protected void readFromPage() {
super.readFromPage();
bean.setContent(bean.getContent());
bean.setName(bean.getName().toUpperCase());
}
}

+ 8
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowService.java Zobrazit soubor

@@ -0,0 +1,8 @@
package cc.smtweb.system.bpm.web.engine.flow;

/**
* Created by Akmm at 2022/5/24 14:21
* 工作流
*/
public class FlowService {
}

Načítá se…
Zrušit
Uložit