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/org/SaveOrgCmd.java |   33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/service-user/src/main/java/com/java110/user/cmd/org/SaveOrgCmd.java b/service-user/src/main/java/com/java110/user/cmd/org/SaveOrgCmd.java
index c04e4ce..a087420 100644
--- a/service-user/src/main/java/com/java110/user/cmd/org/SaveOrgCmd.java
+++ b/service-user/src/main/java/com/java110/user/cmd/org/SaveOrgCmd.java
@@ -22,6 +22,7 @@
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.org.OrgDto;
 import com.java110.intf.user.IOrgV1InnerServiceSMO;
 import com.java110.po.org.OrgPo;
 import com.java110.utils.exception.CmdException;
@@ -31,6 +32,8 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
+import java.util.List;
 
 /**
  * 绫昏〃杩帮細淇濆瓨
@@ -54,11 +57,20 @@
 
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
-        Assert.hasKeyAndValue(reqJson, "orgId", "璇锋眰鎶ユ枃涓湭鍖呭惈orgId");
-Assert.hasKeyAndValue(reqJson, "storeId", "璇锋眰鎶ユ枃涓湭鍖呭惈storeId");
-Assert.hasKeyAndValue(reqJson, "orgName", "璇锋眰鎶ユ枃涓湭鍖呭惈orgName");
-Assert.hasKeyAndValue(reqJson, "orgLevel", "璇锋眰鎶ユ枃涓湭鍖呭惈orgLevel");
-Assert.hasKeyAndValue(reqJson, "parentOrgId", "璇锋眰鎶ユ枃涓湭鍖呭惈parentOrgId");
+        Assert.hasKeyAndValue(reqJson, "orgName", "蹇呭~锛岃濉啓缁勭粐鍚嶇О");
+        Assert.hasKeyAndValue(reqJson, "parentOrgId", "蹇呭~锛岃閫夋嫨涓婄骇ID");
+        //Assert.hasKeyAndValue(reqJson, "belongCommunityId", "蹇呭~锛岃閫夋嫨闅跺睘灏忓尯");
+        //Assert.hasKeyAndValue(reqJson, "description", "蹇呭~锛岃濉啓鎻忚堪");
+
+        OrgDto orgDto = new OrgDto();
+        orgDto.setOrgId(reqJson.getString("parentOrgId"));
+        List<OrgDto> orgDtos = orgV1InnerServiceSMOImpl.queryOrgs(orgDto);
+
+        Assert.listOnlyOne(orgDtos,"涓婄骇缁勭粐涓嶅瓨鍦�");
+
+        int orgLevel = Integer.parseInt(orgDtos.get(0).getOrgLevel());
+        orgLevel +=1;
+        reqJson.put("orgLevel",orgLevel);
 
     }
 
@@ -66,8 +78,17 @@
     @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
-       OrgPo orgPo = BeanConvertUtil.covertBean(reqJson, OrgPo.class);
+        String storeId = cmdDataFlowContext.getReqHeaders().get("store-id");
+
+        JSONObject businessOrg = new JSONObject();
+        businessOrg.putAll(reqJson);
+        businessOrg.put("allowOperation", "T");
+        businessOrg.put("belongCommunityId", "");
+
+        OrgPo orgPo = BeanConvertUtil.covertBean(businessOrg, OrgPo.class);
         orgPo.setOrgId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+        orgPo.setStoreId(storeId);
+
         int flag = orgV1InnerServiceSMOImpl.saveOrg(orgPo);
 
         if (flag < 1) {

--
Gitblit v1.8.0