From 7fb9313dcd9c99d46b95fb8a7fdcccf2063600a1 Mon Sep 17 00:00:00 2001 From: xu_lw Date: Thu, 29 Aug 2019 11:24:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=AC=E5=85=B1?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mbu/web/interceptor/BUIInterceptor.java | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 ecp-mbu-web/src/main/java/com/murong/ecp/netpay/mbu/web/interceptor/BUIInterceptor.java diff --git a/ecp-mbu-web/src/main/java/com/murong/ecp/netpay/mbu/web/interceptor/BUIInterceptor.java b/ecp-mbu-web/src/main/java/com/murong/ecp/netpay/mbu/web/interceptor/BUIInterceptor.java new file mode 100644 index 00000000..02a66adb --- /dev/null +++ b/ecp-mbu-web/src/main/java/com/murong/ecp/netpay/mbu/web/interceptor/BUIInterceptor.java @@ -0,0 +1,114 @@ +package com.murong.ecp.netpay.mbu.web.interceptor; + +import com.murong.ecp.bp.common.annotation.ECPInterceptorMapping; +import com.murong.ecp.netpay.mbu.web.common.utils.CommonMessageCode; +import com.yuangou.ecp.biz.transengine.YGAbstractBizIntercetpor; +import com.yuangou.ecp.biz.transengine.sqlsession.YGSqlSession; +import com.yuangou.ecp.biz.transengine.util.GDAUtil; +import com.yuangou.ecp.bp.comp.expr.YGExpUtil; +import com.yuangou.ecp.bp.comp.pubatc.YGPUBATCUtil; +import com.yuangou.ecp.bp.core.common.exception.YGException; +import com.yuangou.ecp.bp.core.common.message.YGBizMessage; +import com.yuangou.ecp.bp.core.common.message.YGBizMessageContext; +import com.yuangou.ecp.bp.core.common.message.YGEDB; +import com.yuangou.ecp.bp.core.common.yglog4j.Logger; +import com.yuangou.ecp.bp.core.common.yglog4j.YGLogger; +import com.yuangou.ecp.bp.database.YGDatabaseUtil; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.exception.ExceptionUtils; + +/** + * 公共处理 + */ +@ECPInterceptorMapping({".*"}) +public class BUIInterceptor extends YGAbstractBizIntercetpor { + + @Override + public void onError(YGBizMessageContext bizCtx, Throwable t) throws YGException { + + YGBizMessage msg = bizCtx.getCurrentMsg(); + + Logger logger = YGLogger.getLogger(msg); + + if (logger.isInfoEnabled()) { + logger.info("执行异常处理:[" + this.getClass().getSimpleName() + ".onError]"); + logger.info("运行时异常,回滚数据库事务"); + } + + YGPUBATCUtil.rollbackWork(bizCtx); + GDAUtil.setMsg_cd(msg, CommonMessageCode.FAIL.getMsgCod()); + GDAUtil.setMsg_inf(msg, CommonMessageCode.FAIL.getMsgInf()); + + if (logger.isErrorEnabled()) { + logger.error(ExceptionUtils.getFullStackTrace(t)); + } + + if (logger.isInfoEnabled()) { + logger.info("异常处理结束:[" + this.getClass().getSimpleName() + ".onError]"); + } + } + + @Override + public boolean onRequest(YGBizMessageContext bizCtx) throws YGException { + + YGBizMessage msg = bizCtx.getCurrentMsg(); + Logger logger = YGLogger.getLogger(msg); + + if (logger.isInfoEnabled()) { + logger.info("执行前处理:[" + this.getClass().getSimpleName() + ".onRequest]"); + } + + YGPUBATCUtil.initGDS(bizCtx); + if (logger.isInfoEnabled()) { + logger.info("初始化GDA成功"); + logger.info("前处理结束:[" + this.getClass().getSimpleName() + ".onRequest]"); + } + + YGDatabaseUtil dbUtlil = bizCtx.getDataBaseUtil(); + dbUtlil.insert("insert t(a,b) values(?,?)", new String[]{"a", "b"}); + + return true; + } + + @Override + public void onResponse(YGBizMessageContext bizCtx) throws YGException { + // 公共后处理 + + YGBizMessage msg = bizCtx.getCurrentMsg(); + YGEDB edb = msg.getEDBBody(); + + Logger logger = YGLogger.getLogger(msg); + logger.info("执行后处理:[" + this.getClass().getSimpleName() + ".onResponse]"); + + String msg_cd = GDAUtil.getMsg_cd(msg); + + if (StringUtils.isBlank(msg_cd)) { + if (logger.isInfoEnabled()) { + logger.info("消息编码为空"); + } + + GDAUtil.setMsg_cd(msg, CommonMessageCode.FAIL.getMsgCod()); + GDAUtil.setMsg_inf(msg, CommonMessageCode.FAIL.getMsgInf()); + } + + edb.setData("msg_cd", msg_cd); + + if (YGExpUtil.is_succ(msg_cd)) { + if (logger.isInfoEnabled()) { + logger.info("业务处理成功,提交数据库事务"); + } + + edb.setData("gda.msg_typ", "N"); + YGPUBATCUtil.commitWork(bizCtx); + } else { + if (logger.isInfoEnabled()) { + logger.info("业务处理失败,回滚数据库事务"); + } + edb.setData("gda.msg_typ", "E"); + YGPUBATCUtil.rollbackWork(bizCtx); + } + + logger.info("后处理结束:[" + this.getClass().getSimpleName() + ".onResponse]"); + + } +} From 7b6b020e04a8a1135d9b67bab381ca1e187f8300 Mon Sep 17 00:00:00 2001 From: xu_lw Date: Thu, 29 Aug 2019 11:25:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1.=20dao=E9=85=8D=E7=BD=AE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=202.=20=E8=8F=9C=E5=8D=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/pub/action/buipubbpc1/BuiMenuDeleteAction.java | 3 ++- .../ecp/netpay/mbu/web/pub/dal/dao/BuiMenuMapper.java | 3 +++ .../src/main/resources/app/base/etc/bpltpar1_biz.xml | 10 +++++----- .../resources/app/mbu/etc/pub/mapper/BuiMenuMapper.xml | 3 +++ ecp-mbu-web/src/main/resources/application.properties | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ecp-mbu-web/src/main/java/com/murong/ecp/netpay/mbu/web/pub/action/buipubbpc1/BuiMenuDeleteAction.java b/ecp-mbu-web/src/main/java/com/murong/ecp/netpay/mbu/web/pub/action/buipubbpc1/BuiMenuDeleteAction.java index d7867f52..f0ce5b87 100644 --- a/ecp-mbu-web/src/main/java/com/murong/ecp/netpay/mbu/web/pub/action/buipubbpc1/BuiMenuDeleteAction.java +++ b/ecp-mbu-web/src/main/java/com/murong/ecp/netpay/mbu/web/pub/action/buipubbpc1/BuiMenuDeleteAction.java @@ -45,7 +45,8 @@ public class BuiMenuDeleteAction extends BaseAction { BuiMenuDO entity = new BuiMenuDO(); BeanUtils.copyProperties(reqBO, entity); - int retCod = buiMenuMapper.deleteByPrimaryKey(entity); + + int retCod = buiMenuMapper.deleteByIdCascade(entity.getMenuId()); ResultT resultT = new ResultT(); if (retCod > 0) { diff --git a/ecp-mbu-web/src/main/java/com/murong/ecp/netpay/mbu/web/pub/dal/dao/BuiMenuMapper.java b/ecp-mbu-web/src/main/java/com/murong/ecp/netpay/mbu/web/pub/dal/dao/BuiMenuMapper.java index 4e10131c..c87cadbd 100644 --- a/ecp-mbu-web/src/main/java/com/murong/ecp/netpay/mbu/web/pub/dal/dao/BuiMenuMapper.java +++ b/ecp-mbu-web/src/main/java/com/murong/ecp/netpay/mbu/web/pub/dal/dao/BuiMenuMapper.java @@ -37,4 +37,7 @@ public interface BuiMenuMapper { List selectByRoleId(Long roleId); + int deleteByIdCascade(Long menuId); + + } diff --git a/ecp-mbu-web/src/main/resources/app/base/etc/bpltpar1_biz.xml b/ecp-mbu-web/src/main/resources/app/base/etc/bpltpar1_biz.xml index f00c2abd..31343b9e 100644 --- a/ecp-mbu-web/src/main/resources/app/base/etc/bpltpar1_biz.xml +++ b/ecp-mbu-web/src/main/resources/app/base/etc/bpltpar1_biz.xml @@ -1,8 +1,8 @@ - - - - - + + + + + diff --git a/ecp-mbu-web/src/main/resources/app/mbu/etc/pub/mapper/BuiMenuMapper.xml b/ecp-mbu-web/src/main/resources/app/mbu/etc/pub/mapper/BuiMenuMapper.xml index 344642d6..0f968f2e 100644 --- a/ecp-mbu-web/src/main/resources/app/mbu/etc/pub/mapper/BuiMenuMapper.xml +++ b/ecp-mbu-web/src/main/resources/app/mbu/etc/pub/mapper/BuiMenuMapper.xml @@ -138,4 +138,7 @@ select b.* from t_bui_role_menu a, t_bui_menu b where a.role_id=#{roleId} and b.menu_id=a.menu_id order by b.menu_id + + delete from t_bui_menu where menu_id in (select menu_id from t_bui_menu start with menu_id=${menuId} connect by prior menu_id = parent_id) + diff --git a/ecp-mbu-web/src/main/resources/application.properties b/ecp-mbu-web/src/main/resources/application.properties index 88032176..9620c7d9 100644 --- a/ecp-mbu-web/src/main/resources/application.properties +++ b/ecp-mbu-web/src/main/resources/application.properties @@ -13,7 +13,7 @@ spring.mvc.view.prefix=/ spring.mvc.view.suffix=.jsp spring.application.name=mbu ecp.container.enable=true -ecp.datasource.mapper=com.murong.ecp.netpay.mbu.web.*.dao +ecp.datasource.mapper=com.murong.ecp.netpay.mbu.web.*.dal.dao ecp.datasource.url=jdbc:oracle:thin:@//10.116.77.178:1521/orcl #ecp.datasource.username=boss01 #ecp.datasource.password=boss01$123