From 675ccd51874f9c005285eab3e4829e451848b4b6 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期三, 07 六月 2023 11:11:29 +0800
Subject: [PATCH] Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity

---
 service-user/src/main/java/com/java110/user/cmd/roleCommunity/SaveRoleCommunityCmd.java |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/service-user/src/main/java/com/java110/user/cmd/roleCommunity/SaveRoleCommunityCmd.java b/service-user/src/main/java/com/java110/user/cmd/roleCommunity/SaveRoleCommunityCmd.java
index b9f91fd..2e38e92 100644
--- a/service-user/src/main/java/com/java110/user/cmd/roleCommunity/SaveRoleCommunityCmd.java
+++ b/service-user/src/main/java/com/java110/user/cmd/roleCommunity/SaveRoleCommunityCmd.java
@@ -15,6 +15,7 @@
  */
 package com.java110.user.cmd.roleCommunity;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.annotation.Java110Transactional;
@@ -55,20 +56,30 @@
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "roleId", "璇锋眰鎶ユ枃涓湭鍖呭惈roleId");
-Assert.hasKeyAndValue(reqJson, "communityId", "璇锋眰鎶ユ枃涓湭鍖呭惈communityId");
-
+        if (!reqJson.containsKey("communitys") || reqJson.getJSONArray("communitys").size() < 1) {
+            throw new IllegalArgumentException("鏈寘鍚皬鍖轰俊鎭�");
+        }
     }
 
     @Override
     @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
+        String storeId = cmdDataFlowContext.getReqHeaders().get("store-id");
 
-       RoleCommunityPo roleCommunityPo = BeanConvertUtil.covertBean(reqJson, RoleCommunityPo.class);
-        roleCommunityPo.setRcId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
-        int flag = roleCommunityV1InnerServiceSMOImpl.saveRoleCommunity(roleCommunityPo);
+        RoleCommunityPo roleCommunityPo = null;
+        JSONArray communitys = reqJson.getJSONArray("communitys");
+        for (int communityIndex = 0; communityIndex < communitys.size(); communityIndex++) {
+            roleCommunityPo = new RoleCommunityPo();
+            roleCommunityPo.setCommunityId(communitys.getJSONObject(communityIndex).getString("communityId"));
+            roleCommunityPo.setCommunityName(communitys.getJSONObject(communityIndex).getString("communityName"));
+            roleCommunityPo.setRoleId(reqJson.getString("roleId"));
+            roleCommunityPo.setStoreId(storeId);
+            roleCommunityPo.setRcId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+            int flag = roleCommunityV1InnerServiceSMOImpl.saveRoleCommunity(roleCommunityPo);
 
-        if (flag < 1) {
-            throw new CmdException("淇濆瓨鏁版嵁澶辫触");
+            if (flag < 1) {
+                throw new CmdException("淇濆瓨鏁版嵁澶辫触");
+            }
         }
 
         cmdDataFlowContext.setResponseEntity(ResultVo.success());

--
Gitblit v1.8.0