Browse Source

系统:模型代码调整

4.0
郑根木 2 years ago
parent
commit
2ff242165d
8 changed files with 61 additions and 78 deletions
  1. +2
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelDelHandler.java
  2. +4
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelLoadHandler.java
  3. +3
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelSaveHandler.java
  4. +9
    -27
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java
  5. +15
    -15
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java
  6. +6
    -5
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java
  7. +21
    -24
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java
  8. +1
    -1
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java

+ 2
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelDelHandler.java View File

@@ -18,6 +18,7 @@ import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler;
* 删除操作 * 删除操作
*/ */
public class ModelDelHandler extends AbstractDynPageHandler { public class ModelDelHandler extends AbstractDynPageHandler {
protected String cardDsName = ModelHelper.DATASET_NAME_CARD;
/** /**
* 删除指定数据集,入参{pageId, dataset, id} * 删除指定数据集,入参{pageId, dataset, id}
* *
@@ -27,7 +28,7 @@ public class ModelDelHandler extends AbstractDynPageHandler {
long id = params.readLong("id"); long id = params.readLong("id");
if (id == 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); if (id == 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!");
//数据集 //数据集
PageDataset pageDataSet = findCardDataset(ModelHelper.DATASET_NAME_CARD);
PageDataset pageDataSet = findCardDataset(cardDsName);


checkBean(pageDataSet, id); checkBean(pageDataSet, id);




+ 4
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelLoadHandler.java View File

@@ -18,11 +18,12 @@ import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean;
*/ */
public class ModelLoadHandler<T extends DefaultEntity> extends AbstractDynPageHandler { public class ModelLoadHandler<T extends DefaultEntity> extends AbstractDynPageHandler {
protected T bean; protected T bean;
protected String cardDsName = ModelHelper.DATASET_NAME_CARD;


//新增卡片操作,初始化定义的数据集 //新增卡片操作,初始化定义的数据集
public R add() { public R add() {
SwMap ret = new SwMap(); SwMap ret = new SwMap();
bean = addBean(ret, ModelHelper.DATASET_NAME_CARD);
bean = addBean(ret, cardDsName);
afterAdd(ret); afterAdd(ret);
return R.success(ret); return R.success(ret);
} }
@@ -57,9 +58,9 @@ public class ModelLoadHandler<T extends DefaultEntity> extends AbstractDynPageHa


//从数据库加载bean,并设到返回值 //从数据库加载bean,并设到返回值
protected void load(SwMap ret, SwMap filter) { protected void load(SwMap ret, SwMap filter) {
PageDataset cardDataset = findCardDataset(ModelHelper.DATASET_NAME_CARD);
PageDataset cardDataset = findCardDataset(cardDsName);
bean = provider.loadBean(cardDataset, filter.readLong(SwConsts.NAME_ID)); bean = provider.loadBean(cardDataset, filter.readLong(SwConsts.NAME_ID));
ret.put(ModelHelper.DATASET_NAME_CARD, DynRetBean.createBean(bean));
ret.put(cardDsName, DynRetBean.createBean(bean));
} }


//给子类使用的工具方法:根据数据集配置,读取bean,并加到返回值 //给子类使用的工具方法:根据数据集配置,读取bean,并加到返回值


+ 3
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelSaveHandler.java View File

@@ -33,6 +33,7 @@ import java.util.Map;
public class ModelSaveHandler<T extends DefaultEntity> extends AbstractDynPageHandler { public class ModelSaveHandler<T extends DefaultEntity> extends AbstractDynPageHandler {
private Map<String, List<? extends DefaultEntity>> mapTreeBean = new HashMap<>(); private Map<String, List<? extends DefaultEntity>> mapTreeBean = new HashMap<>();
protected T bean; protected T bean;
protected String cardDsName = ModelHelper.DATASET_NAME_CARD;


/** /**
* 保存指定数据集操作,入参:{pageId,dataset:"", data:{form:{},list: {total:0,rows:[]}}, filter:{}} * 保存指定数据集操作,入参:{pageId,dataset:"", data:{form:{},list: {total:0,rows:[]}}, filter:{}}
@@ -62,7 +63,7 @@ public class ModelSaveHandler<T extends DefaultEntity> extends AbstractDynPageHa
} }
}); });
bean.removeStatus(); bean.removeStatus();
SwMap ret = ModelHelper.buildRetData(ModelHelper.DATASET_NAME_CARD, bean.getData());
SwMap ret = ModelHelper.buildRetData(cardDsName, bean.getData());
afterSave(ret); afterSave(ret);
return R.success(ret); return R.success(ret);
} }
@@ -79,7 +80,7 @@ public class ModelSaveHandler<T extends DefaultEntity> extends AbstractDynPageHa
*/ */
protected void readFromPage(SwMap pageData, SwMap filter) { protected void readFromPage(SwMap pageData, SwMap filter) {
//读取待保存的bean //读取待保存的bean
bean = readBeanFromPage(ModelHelper.DATASET_NAME_CARD, pageData, filter);
bean = readBeanFromPage(cardDsName, pageData, filter);
} }


//给子类使用的工具方法:从页面读取一个bean //给子类使用的工具方法:从页面读取一个bean


+ 9
- 27
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java View File

@@ -1,32 +1,24 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1;


import cc.smtweb.framework.core.common.R; import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsDelHandler; import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsDelHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelDelHandler;


/** /**
* @Author:lip * @Author:lip
* @Date : 2022/9/2 11:44 * @Date : 2022/9/2 11:44
*/ */
public class LCLC1DelHandler extends AbsDelHandler {
public class LCLC1DelHandler extends ModelDelHandler {


/** /**
* 左列表删除 * 左列表删除
* *
* @return * @return
*/ */
public R lLDel() {
doDel(LCLC1Define.dsLList);
return R.success();
}

/**
* 左卡片删除
*
* @return
*/
public R lCDel() {
doDel(LCLC1Define.dsLCard);
return R.success();
public R lDel() {
cardDsName = LCLC1Define.dsLCard;
return super.del();
} }


/** /**
@@ -34,18 +26,8 @@ public class LCLC1DelHandler extends AbsDelHandler {
* *
* @return * @return
*/ */
public R rLDel() {
doDel(LCLC1Define.dsRList);
return R.success();
}

/**
* 右卡片删除
*
* @return
*/
public R rCDel() {
doDel(LCLC1Define.dsRCard);
return R.success();
public R rDel() {
cardDsName = LCLC1Define.dsRCard;
return super.del();
} }
} }

+ 15
- 15
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java View File

@@ -2,23 +2,25 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1;


import cc.smtweb.framework.core.common.R; import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap; import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsLoadHandler; import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsLoadHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelHelper; import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelHelper;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelLoadHandler;


/** /**
* @Author:lip * @Author:lip
* @Date : 2022/9/2 11:44 * @Date : 2022/9/2 11:44
*/ */
public class LCLC1LoadHandler extends AbsLoadHandler {
public class LCLC1LoadHandler extends ModelLoadHandler<DefaultEntity> {
/** /**
* 左表新增 * 左表新增
* *
* @return * @return
*/ */
public R lAdd() { public R lAdd() {
SwMap data = doAdd(LCLC1Define.dsLCard);
return R.success(ModelHelper.buildRetData(LCLC1Define.dsLCard, data));
cardDsName = LCLC1Define.dsLCard;
return super.add();
} }


/** /**
@@ -27,8 +29,8 @@ public class LCLC1LoadHandler extends AbsLoadHandler {
* @return * @return
*/ */
public R rAdd() { public R rAdd() {
SwMap data = doAdd(LCLC1Define.dsRCard);
return R.success(ModelHelper.buildRetData(LCLC1Define.dsRCard, data));
cardDsName = LCLC1Define.dsRCard;
return super.add();
} }


/** /**
@@ -37,8 +39,8 @@ public class LCLC1LoadHandler extends AbsLoadHandler {
* @return * @return
*/ */
public R lLoad() { public R lLoad() {
SwMap bean = doLoadCard(LCLC1Define.dsLCard);
return R.success(ModelHelper.buildRetData(LCLC1Define.dsLCard, bean));
cardDsName = LCLC1Define.dsLCard;
return super.load();
} }


/** /**
@@ -47,8 +49,8 @@ public class LCLC1LoadHandler extends AbsLoadHandler {
* @return * @return
*/ */
public R rLoad() { public R rLoad() {
SwMap bean = doLoadCard(LCLC1Define.dsRCard);
return R.success(ModelHelper.buildRetData(LCLC1Define.dsRCard, bean));
cardDsName = LCLC1Define.dsRCard;
return super.load();
} }


/** /**
@@ -57,8 +59,7 @@ public class LCLC1LoadHandler extends AbsLoadHandler {
* @return * @return
*/ */
public R lList() { public R lList() {
DynRetBean list = doList(LCLC1Define.dsLList);
return R.success(list);
return super.list(LCLC1Define.dsLCard);
} }


/** /**
@@ -67,8 +68,7 @@ public class LCLC1LoadHandler extends AbsLoadHandler {
* @return * @return
*/ */
public R rList() { public R rList() {
DynRetBean list = doList(LCLC1Define.dsRList);
return R.success(list);
return super.list(LCLC1Define.dsRCard);
} }


/** /**
@@ -77,7 +77,7 @@ public class LCLC1LoadHandler extends AbsLoadHandler {
* @return * @return
*/ */
public R getLTotal() { public R getLTotal() {
return doTotal(LCLC1Define.dsLList);
return super.getTotal(LCLC1Define.dsLList);
} }


/** /**
@@ -86,6 +86,6 @@ public class LCLC1LoadHandler extends AbsLoadHandler {
* @return * @return
*/ */
public R getRTotal() { public R getRTotal() {
return doTotal(LCLC1Define.dsRList);
return super.getTotal(LCLC1Define.dsRList);
} }
} }

+ 6
- 5
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java View File

@@ -4,20 +4,21 @@ import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.db.impl.DefaultEntity; import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsSaveHandler; import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsSaveHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelHelper; import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelHelper;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler;


/** /**
* @Author:lip * @Author:lip
* @Date : 2022/9/2 11:44 * @Date : 2022/9/2 11:44
*/ */
public class LCLC1SaveHandler extends AbsSaveHandler {
public class LCLC1SaveHandler extends ModelSaveHandler<DefaultEntity> {
/** /**
* 左表保存 * 左表保存
* *
* @return * @return
*/ */
public R lSave() { public R lSave() {
DefaultEntity bean = doSave(LCLC1Define.dsLCard);
return R.success(ModelHelper.buildRetData(LCLC1Define.dsLCard, bean.getData()));
cardDsName = LCLC1Define.dsLCard;
return super.save();
} }


/** /**
@@ -26,7 +27,7 @@ public class LCLC1SaveHandler extends AbsSaveHandler {
* @return * @return
*/ */
public R rSave() { public R rSave() {
DefaultEntity bean = doSave(LCLC1Define.dsRCard);
return R.success(ModelHelper.buildRetData(LCLC1Define.dsRCard, bean.getData()));
cardDsName = LCLC1Define.dsRCard;
return super.save();
} }
} }

+ 21
- 24
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java View File

@@ -7,33 +7,30 @@ import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.mvc.service.AbstractHandler; import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession; import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelDelHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelLoadHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelService;


/** /**
* @Author:lip * @Author:lip
* @Date : 2022/9/2 11:34 * @Date : 2022/9/2 11:34
*/ */
@SwService @SwService
public class LCLC1Service extends DynPageService {
protected final static String TYPE_MODEL_LIST = "modelList";
protected final static String TYPE_MODEL_ADD = "modelAdd";
protected final static String TYPE_MODEL_LOAD = "modelLoad";
protected final static String TYPE_MODEL_SAVE = "modelSave";
protected final static String TYPE_MODEL_DEL = "modelDel";

//
public class LCLC1Service extends ModelService {
@Override @Override
protected AbstractHandler createHandler(String type) {
switch (type) {
case TYPE_MODEL_LIST:
case TYPE_MODEL_LOAD:
case TYPE_MODEL_ADD:
return new LCLC1LoadHandler();
case TYPE_MODEL_SAVE:
return new LCLC1SaveHandler();
case TYPE_MODEL_DEL:
return new LCLC1DelHandler();
}
return super.createHandler(type);
protected ModelSaveHandler getSaveHandler() {
return new LCLC1SaveHandler();
}

@Override
protected ModelLoadHandler getLoadHandler() {
return new LCLC1LoadHandler();
}
@Override
protected ModelDelHandler getDelHandler() {
return new LCLC1DelHandler();
} }


//保存 //保存
@@ -53,12 +50,12 @@ public class LCLC1Service extends DynPageService {


//删除 //删除
public R modelLLDel(@SwBody SwMap params, UserSession us) { public R modelLLDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).lLDel());
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).lDel());
} }


//删除 //删除
public R modelLCDel(@SwBody SwMap params, UserSession us) { public R modelLCDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).lCDel());
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).lDel());
} }


//列表数据 //列表数据
@@ -89,12 +86,12 @@ public class LCLC1Service extends DynPageService {


//删除 //删除
public R modelRLDel(@SwBody SwMap params, UserSession us) { public R modelRLDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).rLDel());
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).rDel());
} }


//删除 //删除
public R modelRCDel(@SwBody SwMap params, UserSession us) { public R modelRCDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).rCDel());
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).rDel());
} }


//列表数据 //列表数据


+ 1
- 1
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java View File

@@ -6,7 +6,7 @@ package cc.smtweb.framework.core.common;
public interface SwConsts { public interface SwConsts {
class SysParam { class SysParam {
//开发调试模式 //开发调试模式
public static boolean SYS_DEBUG = false;
public static boolean SYS_DEBUG = true;
//系统启动完成 //系统启动完成
public static boolean SYS_STARTED = false; public static boolean SYS_STARTED = false;
//运行的项目,多个用半角逗号分隔 //运行的项目,多个用半角逗号分隔


Loading…
Cancel
Save