From 0fea532b07be89978343cb4aede3693af99f5656 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期二, 25 七月 2023 23:04:41 +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 | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 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..e4f8d34 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;
@@ -23,10 +24,9 @@
import com.java110.core.event.cmd.CmdEvent;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.intf.user.IRoleCommunityV1InnerServiceSMO;
-import com.java110.po.roleCommunity.RoleCommunityPo;
+import com.java110.po.privilege.RoleCommunityPo;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.slf4j.Logger;
@@ -55,20 +55,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