From 2633f776bb8fdb0b1efe3a56293b6a1bb04616a7 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期日, 28 四月 2019 10:48:14 +0800
Subject: [PATCH] Merge branch 'master' of https://github.com/java110/MicroCommunity

---
 CommunityService/src/main/java/com/java110/community/listener/MemberJoinedCommunityListener.java |   72 ++++++++++++++++++++----------------
 1 files changed, 40 insertions(+), 32 deletions(-)

diff --git a/CommunityService/src/main/java/com/java110/community/listener/MemberJoinedCommunityListener.java b/CommunityService/src/main/java/com/java110/community/listener/MemberJoinedCommunityListener.java
index 2710f2f..7b9d4a8 100644
--- a/CommunityService/src/main/java/com/java110/community/listener/MemberJoinedCommunityListener.java
+++ b/CommunityService/src/main/java/com/java110/community/listener/MemberJoinedCommunityListener.java
@@ -21,22 +21,24 @@
 
 /**
  * 灏忓尯鎴愬憳鍔犲叆 渚﹀惉
- *
+ * <p>
  * businessCommunityMember
  * Created by wuxw on 2018/5/18.
  */
 @Java110Listener("memberJoinedCommunityListener")
 @Transactional
-public class MemberJoinedCommunityListener extends AbstractCommunityBusinessServiceDataFlowListener{
+public class MemberJoinedCommunityListener extends AbstractCommunityBusinessServiceDataFlowListener {
 
-    private final static Logger logger = LoggerFactory.getLogger(MemberJoinedCommunityListener.class);
+    private static final int CURRENT_ORDER = 5;
+
+    private static Logger logger = LoggerFactory.getLogger(MemberJoinedCommunityListener.class);
 
     @Autowired
     ICommunityServiceDao communityServiceDaoImpl;
 
     @Override
     public int getOrder() {
-        return 5;
+        return CURRENT_ORDER;
     }
 
     @Override
@@ -46,87 +48,91 @@
 
     /**
      * 淇濆瓨灏忓尯淇℃伅 business 琛ㄤ腑
+     *
      * @param dataFlowContext 鏁版嵁瀵硅薄
-     * @param business 褰撳墠涓氬姟瀵硅薄
+     * @param business        褰撳墠涓氬姟瀵硅薄
      */
     @Override
     protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
         JSONObject data = business.getDatas();
-        Assert.notEmpty(data,"娌℃湁datas 鑺傜偣锛屾垨娌℃湁瀛愯妭鐐归渶瑕佸鐞�");
+        Assert.notEmpty(data, "娌℃湁datas 鑺傜偣锛屾垨娌℃湁瀛愯妭鐐归渶瑕佸鐞�");
 
-        if(data.containsKey("businessCommunityMember")){
+        if (data.containsKey("businessCommunityMember")) {
             JSONObject businessCommunityMember = data.getJSONObject("businessCommunityMember");
-            doBusinessCommunityMember(business,businessCommunityMember);
+            doBusinessCommunityMember(business, businessCommunityMember);
         }
     }
 
     /**
      * business 鏁版嵁杞Щ鍒� instance
+     *
      * @param dataFlowContext 鏁版嵁瀵硅薄
-     * @param business 褰撳墠涓氬姟瀵硅薄
+     * @param business        褰撳墠涓氬姟瀵硅薄
      */
     @Override
     protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
         JSONObject data = business.getDatas();
 
         Map info = new HashMap();
-        info.put("bId",business.getbId());
-        info.put("operate",StatusConstant.OPERATE_ADD);
+        info.put("bId", business.getbId());
+        info.put("operate", StatusConstant.OPERATE_ADD);
 
         //灏忓尯淇℃伅
         Map businessCommunityMember = communityServiceDaoImpl.getBusinessCommunityMember(info);
-        if( businessCommunityMember != null && !businessCommunityMember.isEmpty()) {
+        if (businessCommunityMember != null && !businessCommunityMember.isEmpty()) {
             communityServiceDaoImpl.saveCommunityMemberInstance(info);
-            dataFlowContext.addParamOut("communityId",businessCommunityMember.get("community_id"));
-            dataFlowContext.addParamOut("memberId",businessCommunityMember.get("member_id"));
+            dataFlowContext.addParamOut("communityId", businessCommunityMember.get("community_id"));
+            dataFlowContext.addParamOut("memberId", businessCommunityMember.get("member_id"));
         }
     }
 
     /**
      * 鎾ゅ崟
+     *
      * @param dataFlowContext 鏁版嵁瀵硅薄
-     * @param business 褰撳墠涓氬姟瀵硅薄
+     * @param business        褰撳墠涓氬姟瀵硅薄
      */
     @Override
     protected void doRecover(DataFlowContext dataFlowContext, Business business) {
         String bId = business.getbId();
         //Assert.hasLength(bId,"璇锋眰鎶ユ枃涓病鏈夊寘鍚� bId");
         Map info = new HashMap();
-        info.put("bId",bId);
-        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        info.put("bId", bId);
+        info.put("statusCd", StatusConstant.STATUS_CD_VALID);
         Map paramIn = new HashMap();
-        paramIn.put("bId",bId);
-        paramIn.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+        paramIn.put("bId", bId);
+        paramIn.put("statusCd", StatusConstant.STATUS_CD_INVALID);
         //灏忓尯淇℃伅
         Map communityMember = communityServiceDaoImpl.getCommunityMember(info);
-        if(communityMember != null && !communityMember.isEmpty()){
-            paramIn.put("communityMemberId",communityMember.get("member_community_id").toString());
+        if (communityMember != null && !communityMember.isEmpty()) {
+            paramIn.put("communityMemberId", communityMember.get("member_community_id").toString());
             communityServiceDaoImpl.updateCommunityMemberInstance(paramIn);
-            dataFlowContext.addParamOut("communityMemberId",communityMember.get("member_community_id"));
+            dataFlowContext.addParamOut("communityMemberId", communityMember.get("member_community_id"));
         }
     }
 
     /**
      * 澶勭悊 businessCommunityMember 鑺傜偣
-     * @param business 鎬荤殑鏁版嵁鑺傜偣
+     *
+     * @param business                鎬荤殑鏁版嵁鑺傜偣
      * @param businessCommunityMember 灏忓尯鎴愬憳鑺傜偣
      */
-    private void doBusinessCommunityMember(Business business,JSONObject businessCommunityMember){
+    private void doBusinessCommunityMember(Business business, JSONObject businessCommunityMember) {
 
-        Assert.jsonObjectHaveKey(businessCommunityMember,"communityId","businessCommunityMember 鑺傜偣涓嬫病鏈夊寘鍚� communityId 鑺傜偣");
-        Assert.jsonObjectHaveKey(businessCommunityMember,"memberId","businessCommunityMember 鑺傜偣涓嬫病鏈夊寘鍚� memberId 鑺傜偣");
-        Assert.jsonObjectHaveKey(businessCommunityMember,"memberTypeCd","businessCommunityMember 鑺傜偣涓嬫病鏈夊寘鍚� memberTypeCd 鑺傜偣");
+        Assert.jsonObjectHaveKey(businessCommunityMember, "communityId", "businessCommunityMember 鑺傜偣涓嬫病鏈夊寘鍚� communityId 鑺傜偣");
+        Assert.jsonObjectHaveKey(businessCommunityMember, "memberId", "businessCommunityMember 鑺傜偣涓嬫病鏈夊寘鍚� memberId 鑺傜偣");
+        Assert.jsonObjectHaveKey(businessCommunityMember, "memberTypeCd", "businessCommunityMember 鑺傜偣涓嬫病鏈夊寘鍚� memberTypeCd 鑺傜偣");
 
-        if(businessCommunityMember.getString("communityId").startsWith("-") || businessCommunityMember.getString("memberId").startsWith("-")){
-            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"浼犲叆鍙傛暟 communityId 鎴� communityId 蹇呴』鏄凡鏈夊皬鍖篒D锛�"+businessCommunityMember);
+        if (businessCommunityMember.getString("communityId").startsWith("-") || businessCommunityMember.getString("memberId").startsWith("-")) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "浼犲叆鍙傛暟 communityId 鎴� communityId 蹇呴』鏄凡鏈夊皬鍖篒D锛�" + businessCommunityMember);
         }
 
-        if(businessCommunityMember.getString("communityMemberId").startsWith("-")){
+        if (businessCommunityMember.getString("communityMemberId").startsWith("-")) {
             //鍒锋柊缂撳瓨
             flushCommunityMemberId(business.getDatas());
         }
 
-        businessCommunityMember.put("bId",business.getbId());
+        businessCommunityMember.put("bId", business.getbId());
         businessCommunityMember.put("operate", StatusConstant.OPERATE_ADD);
         //淇濆瓨灏忓尯淇℃伅
         communityServiceDaoImpl.saveBusinessCommunityMember(businessCommunityMember);
@@ -136,15 +142,17 @@
 
     /**
      * 鍒锋柊 灏忓尯ID
+     *
      * @param data
      */
     private void flushCommunityMemberId(JSONObject data) {
 
         String communityMemberId = GenerateCodeFactory.getCommunityMemberId();
         JSONObject businessCommunityMember = data.getJSONObject("businessCommunityMember");
-        businessCommunityMember.put("communityMemberId",communityMemberId);
+        businessCommunityMember.put("communityMemberId", communityMemberId);
 
     }
+
     public ICommunityServiceDao getCommunityServiceDaoImpl() {
         return communityServiceDaoImpl;
     }

--
Gitblit v1.8.0