From 9adbbca6d70de6f6a5095f1dad1c6dbb512b41f1 Mon Sep 17 00:00:00 2001
From: wuxw7 <wuxw7@asiainfo.com>
Date: 星期三, 04 七月 2018 01:13:24 +0800
Subject: [PATCH] 商户服务开发完成,待测试
---
UserService/src/main/java/com/java110/user/listener/SaveUserAddressListener.java | 115 +++++++++++++++++++++++----------------------------------
1 files changed, 47 insertions(+), 68 deletions(-)
diff --git a/UserService/src/main/java/com/java110/user/listener/SaveUserAddressListener.java b/UserService/src/main/java/com/java110/user/listener/SaveUserAddressListener.java
index 8950caa..96c7f87 100644
--- a/UserService/src/main/java/com/java110/user/listener/SaveUserAddressListener.java
+++ b/UserService/src/main/java/com/java110/user/listener/SaveUserAddressListener.java
@@ -13,6 +13,7 @@
import com.java110.core.factory.DataTransactionFactory;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.entity.center.Business;
+import com.java110.event.service.AbstractBusinessServiceDataFlowListener;
import com.java110.event.service.BusinessServiceDataFlowEvent;
import com.java110.event.service.BusinessServiceDataFlowListener;
import com.java110.user.dao.IUserServiceDao;
@@ -32,7 +33,7 @@
*/
@Java110Listener(name = "saveUserAddressListener")
@Transactional
-public class SaveUserAddressListener implements BusinessServiceDataFlowListener{
+public class SaveUserAddressListener extends AbstractBusinessServiceDataFlowListener {
private final static Logger logger = LoggerFactory.getLogger(SaveUserAddressListener.class);
@@ -49,58 +50,40 @@
return ServiceCodeConstant.SERVICE_CODE_SAVE_USER_ADDRESS;
}
+ /**
+ * 鐢ㄦ埛鍦板潃淇℃伅淇濆瓨鑷� business琛ㄤ腑
+ * @param dataFlowContext 鏁版嵁瀵硅薄
+ * @param business 褰撳墠涓氬姟瀵硅薄
+ */
@Override
- public void soService(BusinessServiceDataFlowEvent event) {
- //杩欓噷澶勭悊涓氬姟閫昏緫鏁版嵁
- DataFlowContext dataFlowContext = event.getDataFlowContext();
- doSaveUserAddress(dataFlowContext);
- }
+ protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+ JSONObject data = business.getDatas();
- private void doSaveUserAddress(DataFlowContext dataFlowContext){
- String businessType = dataFlowContext.getOrder().getBusinessType();
- Business business = dataFlowContext.getCurrentBusiness();
- //Assert.hasLength(business.getbId(),"bId 涓嶈兘涓虹┖");
- // Instance 杩囩▼
- if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(businessType)){
- //doComplateUserInfo(business);
- doSaveInstanceUserAddress(dataFlowContext,business);
- }else if(StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(businessType)){ // Business杩囩▼
- doSaveBusinessUserAddress(dataFlowContext,business);
- }else if(StatusConstant.REQUEST_BUSINESS_TYPE_DELETE.equals(businessType)){ //鎾ゅ崟杩囩▼
- doDeleteInstanceUserAddress(dataFlowContext,business);
+ Assert.notEmpty(data,"娌℃湁datas 鑺傜偣锛屾垨娌℃湁瀛愯妭鐐归渶瑕佸鐞�");
+
+ Assert.jsonObjectHaveKey(data,"businessUserAddress","datas 鑺傜偣涓嬫病鏈夊寘鍚� businessUser 鑺傜偣");
+
+ JSONObject businessUser = data.getJSONObject("businessUserAddress");
+
+ Assert.jsonObjectHaveKey(businessUser,"userId","businessUser 鑺傜偣涓嬫病鏈夊寘鍚� userId 鑺傜偣");
+
+ if(businessUser.getLong("userId") <= 0){
+ throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"鐢ㄦ埛鍦板潃锛坰aveUserAddress锛変繚瀛樺け璐ワ紝userId 涓嶆纭�"+businessUser.getInteger("userId"));
}
-
- dataFlowContext.setResJson(DataTransactionFactory.createBusinessResponseJson(dataFlowContext,ResponseConstant.RESULT_CODE_SUCCESS,"鎴愬姛",
- dataFlowContext.getParamOut()));
+ dataFlowContext.addParamOut("userId",businessUser.getString("userId"));
+ businessUser.put("bId",business.getbId());
+ businessUser.put("operate", StatusConstant.OPERATE_ADD);
+ //淇濆瓨鐢ㄦ埛淇℃伅
+ userServiceDaoImpl.saveBusinessUserAddress(businessUser);
}
/**
- * 鎾ゅ崟
- * @param business
+ * 淇濆瓨鍦板潃淇℃伅鑷砳nstance
+ * @param dataFlowContext 鏁版嵁瀵硅薄
+ * @param business 褰撳墠涓氬姟瀵硅薄
*/
- private void doDeleteInstanceUserAddress(DataFlowContext dataFlowContext, Business business) {
-
- String bId = business.getbId();
- //Assert.hasLength(bId,"璇锋眰鎶ユ枃涓病鏈夊寘鍚� bId");
- Map info = new HashMap();
- info.put("bId",bId);
- Map userAddress = userServiceDaoImpl.queryBusinessUserAddress(info);
- if(userAddress != null && !userAddress.isEmpty()){
- info.put("bId",bId);
- info.put("userId",userAddress.get("user_id").toString());
- info.put("addressId",userAddress.get("address_id").toString());
- info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
- userServiceDaoImpl.updateUserAddressInstance(userAddress);
- dataFlowContext.addParamOut("userId",userAddress.get("user_id"));
- }
- }
-
- /**
- * instance杩囩▼
- * @param business
- */
- private void doSaveInstanceUserAddress(DataFlowContext dataFlowContext, Business business) {
-
+ @Override
+ protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
JSONObject data = business.getDatas();
Map info = new HashMap();
@@ -114,33 +97,29 @@
}
throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR,"褰撳墠鏁版嵁鏈壘鍒癰usiness 鏁版嵁"+info);
+
}
/**
- * 澶勭悊鐢ㄦ埛鍦板潃淇℃伅
- * @param business 涓氬姟淇℃伅
+ * 浣滃簾鐢ㄦ埛鍦板潃淇℃伅锛坕nstance锛�
+ * @param dataFlowContext 鏁版嵁瀵硅薄
+ * @param business 褰撳墠涓氬姟瀵硅薄
*/
- private void doSaveBusinessUserAddress(DataFlowContext dataFlowContext, Business business) {
-
- JSONObject data = business.getDatas();
-
- Assert.notEmpty(data,"娌℃湁datas 鑺傜偣锛屾垨娌℃湁瀛愯妭鐐归渶瑕佸鐞�");
-
- Assert.jsonObjectHaveKey(data,"businessUserAddress","datas 鑺傜偣涓嬫病鏈夊寘鍚� businessUser 鑺傜偣");
-
- JSONObject businessUser = data.getJSONObject("businessUserAddress");
-
- Assert.jsonObjectHaveKey(businessUser,"userId","businessUser 鑺傜偣涓嬫病鏈夊寘鍚� userId 鑺傜偣");
-
- if(businessUser.getLong("userId") <= 0){
- throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"鐢ㄦ埛鍦板潃锛坰aveUserAddress锛変繚瀛樺け璐ワ紝userId 涓嶆纭�"+businessUser.getInteger("userId"));
+ @Override
+ protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+ String bId = business.getbId();
+ //Assert.hasLength(bId,"璇锋眰鎶ユ枃涓病鏈夊寘鍚� bId");
+ Map info = new HashMap();
+ info.put("bId",bId);
+ Map userAddress = userServiceDaoImpl.queryBusinessUserAddress(info);
+ if(userAddress != null && !userAddress.isEmpty()){
+ info.put("bId",bId);
+ info.put("userId",userAddress.get("user_id").toString());
+ info.put("addressId",userAddress.get("address_id").toString());
+ info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+ userServiceDaoImpl.updateUserAddressInstance(userAddress);
+ dataFlowContext.addParamOut("userId",userAddress.get("user_id"));
}
- dataFlowContext.addParamOut("userId",businessUser.getString("userId"));
- businessUser.put("bId",business.getbId());
- businessUser.put("operate", StatusConstant.OPERATE_ADD);
- //淇濆瓨鐢ㄦ埛淇℃伅
- userServiceDaoImpl.saveBusinessUserAddress(businessUser);
-
}
public IUserServiceDao getUserServiceDaoImpl() {
--
Gitblit v1.8.0