@@ -31,4 +31,6 @@ public class ModelCatalogTreeHelper extends TreeHelper<ModelCatalog> { | |||||
list.sort(comparator); | list.sort(comparator); | ||||
return list; | return list; | ||||
} | } | ||||
} | } |
@@ -67,14 +67,15 @@ public class CodeBuildHandler extends AbstractHandler { | |||||
String moduleName = ModelProjectCache.getInstance().getModule(form.getPrjId()); | String moduleName = ModelProjectCache.getInstance().getModule(form.getPrjId()); | ||||
if (StringUtils.isEmpty(moduleName)) throw new BizException("此项目未定义Module!"); | if (StringUtils.isEmpty(moduleName)) throw new BizException("此项目未定义Module!"); | ||||
codeJavaPath = ModelFormHelper.getEventPath(form); | |||||
final String eventPath = ModelFormHelper.getEventPath(form); | |||||
codeJavaPath = ModelFormHelper.getCodePath(form) + "/" + eventPath.replaceAll("\\.", "/"); | |||||
new File(codeJavaPath).mkdirs(); | new File(codeJavaPath).mkdirs(); | ||||
SwMap model = new SwMap(); | SwMap model = new SwMap(); | ||||
model.put("user", userName); | model.put("user", userName); | ||||
model.put("sysTime", DateUtil.nowDateTime()); | model.put("sysTime", DateUtil.nowDateTime()); | ||||
model.put("title", form.getTitle()); | model.put("title", form.getTitle()); | ||||
model.put("eventPath", ModelFormHelper.getEventPath(form)); | |||||
model.put("eventPath", eventPath + "." + form.getName()); | |||||
CodeGenerator.getInstance().generateJsEvent(model, codeJavaPath + "/" + form.getName() + ".js"); | CodeGenerator.getInstance().generateJsEvent(model, codeJavaPath + "/" + form.getName() + ".js"); | ||||
return R.success(); | return R.success(); | ||||
} | } | ||||
@@ -362,17 +362,31 @@ public class ModelFormHelper { | |||||
public static void buildOptsEx(ModelForm bean, SwMap opts) { | public static void buildOptsEx(ModelForm bean, SwMap opts) { | ||||
String eventPath = getEventPath(bean); | String eventPath = getEventPath(bean); | ||||
if (StringUtils.isNotEmpty(eventPath)) { | if (StringUtils.isNotEmpty(eventPath)) { | ||||
opts.put(KEY_EVENT_PATH, eventPath); | |||||
opts.put(KEY_EVENT_PATH, eventPath + "." + bean.getName()); | |||||
} | } | ||||
} | } | ||||
public static String getCodePath(ModelForm bean) { | |||||
String moduleName = ModelProjectCache.getInstance().getModule(bean.getPrjId()); | |||||
if (StringUtils.isEmpty(moduleName)) return null; | |||||
BpmConfigBean bpmConfigBean = SpringUtil.getBean(BpmConfigBean.class); | |||||
Map<String, String> mapIdeaModules = IdeaUtil.getModules(bpmConfigBean.getCodeJavaPath()); | |||||
if (mapIdeaModules.isEmpty()) throw new BizException("没有定义idea项目的路径(smtweb.bpm.codeJavaPath)!"); | |||||
String codeJavaPath = mapIdeaModules.get(moduleName); | |||||
if (StringUtils.isEmpty(codeJavaPath)) { | |||||
throw new BizException("没有找到对应项目在idea中Module的路径(" + moduleName + ")!"); | |||||
} | |||||
return codeJavaPath; | |||||
} | |||||
public static String getEventPath(ModelForm bean) { | public static String getEventPath(ModelForm bean) { | ||||
String moduleName = ModelProjectCache.getInstance().getModule(bean.getPrjId()); | String moduleName = ModelProjectCache.getInstance().getModule(bean.getPrjId()); | ||||
if (StringUtils.isNotEmpty(moduleName)) { | if (StringUtils.isNotEmpty(moduleName)) { | ||||
String ep = moduleName; | String ep = moduleName; | ||||
String cn = ModelCatalogCache.getInstance().getFullName(bean.getMcId()); | String cn = ModelCatalogCache.getInstance().getFullName(bean.getMcId()); | ||||
if (StringUtils.isNotEmpty(cn)) ep = ep + "." + cn; | if (StringUtils.isNotEmpty(cn)) ep = ep + "." + cn; | ||||
return ep + "." + bean.getName(); | |||||
return ep; | |||||
} | } | ||||
return ""; | return ""; | ||||
} | } | ||||
@@ -7,12 +7,16 @@ import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler; | import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler; | ||||
import cc.smtweb.framework.core.util.FileUtil; | import cc.smtweb.framework.core.util.FileUtil; | ||||
import cc.smtweb.framework.core.util.JsonUtil; | import cc.smtweb.framework.core.util.JsonUtil; | ||||
import cc.smtweb.framework.core.util.SpringUtil; | |||||
import cc.smtweb.system.bpm.spring.BpmConfigBean; | |||||
import cc.smtweb.system.bpm.util.IdeaUtil; | |||||
import cc.smtweb.system.bpm.web.design.db.ModelProjectCache; | import cc.smtweb.system.bpm.web.design.db.ModelProjectCache; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | |||||
/** | /** | ||||
* Created by Akmm at 2022/5/9 16:17 | * Created by Akmm at 2022/5/9 16:17 | ||||
@@ -73,13 +77,16 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> { | |||||
long pageId = params.readLong("pageId"); | long pageId = params.readLong("pageId"); | ||||
ModelForm form = ModelFormCache.getInstance().get(pageId); | ModelForm form = ModelFormCache.getInstance().get(pageId); | ||||
if (form == null) throw new BizException("未找到指定的页面定义(" + pageId + ")!"); | if (form == null) throw new BizException("未找到指定的页面定义(" + pageId + ")!"); | ||||
String moduleName = ModelProjectCache.getInstance().getModule(form.getPrjId()); | |||||
List<String> listRet = new ArrayList<>(); | List<String> listRet = new ArrayList<>(); | ||||
R r = R.success(listRet); | R r = R.success(listRet); | ||||
if (StringUtils.isEmpty(moduleName)) { | |||||
String codeJavaPath = ModelFormHelper.getCodePath(form); | |||||
if (StringUtils.isEmpty(codeJavaPath)) { | |||||
return r; | return r; | ||||
} | } | ||||
String path = ModelFormHelper.getEventPath(form) + "/" + form.getName() + ".js"; | |||||
String path = codeJavaPath + "/" + ModelFormHelper.getEventPath(form).replaceAll("\\.", "/") + "/" + form.getName() + ".js"; | |||||
String js = FileUtil.readFileStr(path); | String js = FileUtil.readFileStr(path); | ||||
if (StringUtils.isEmpty(js)) { | if (StringUtils.isEmpty(js)) { | ||||
return r; | return r; | ||||