From 3f629504991dff37c7b9678cfd6435b4e378ebba Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期日, 31 五月 2020 19:52:22 +0800
Subject: [PATCH] 优化添加员工 报错entity

---
 Api/src/main/java/com/java110/api/bmo/user/impl/UserBMOImpl.java |   89 ++++++++++++++------------------------------
 1 files changed, 28 insertions(+), 61 deletions(-)

diff --git a/Api/src/main/java/com/java110/api/bmo/user/impl/UserBMOImpl.java b/Api/src/main/java/com/java110/api/bmo/user/impl/UserBMOImpl.java
index de937ef..5e99590 100644
--- a/Api/src/main/java/com/java110/api/bmo/user/impl/UserBMOImpl.java
+++ b/Api/src/main/java/com/java110/api/bmo/user/impl/UserBMOImpl.java
@@ -8,12 +8,16 @@
 import com.java110.core.factory.AuthenticationFactory;
 import com.java110.core.smo.user.IUserInnerServiceSMO;
 import com.java110.dto.user.UserDto;
+import com.java110.po.org.OrgStaffRelPo;
+import com.java110.po.store.StoreUserRelPo;
+import com.java110.po.user.UserPo;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.BusinessTypeConstant;
 import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.constant.MappingConstant;
 import com.java110.utils.constant.UserLevelConstant;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -34,23 +38,16 @@
     @Autowired
     private IUserInnerServiceSMO userInnerServiceSMOImpl;
 
-    public JSONObject addStaffOrg(JSONObject paramInJson) {
+    public void addStaffOrg(JSONObject paramInJson, DataFlowContext dataFlowContext) {
 
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_ORG_STAFF_REL);
-        business.put(CommonConstant.HTTP_SEQ, 1);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONArray businessOrgStaffRels = new JSONArray();
         JSONObject businessOrgStaffRel = new JSONObject();
         businessOrgStaffRel.put("relId", "-1");
         businessOrgStaffRel.put("storeId", paramInJson.getString("storeId"));
         businessOrgStaffRel.put("staffId", paramInJson.getString("userId"));
         businessOrgStaffRel.put("orgId", paramInJson.getString("orgId"));
         businessOrgStaffRel.put("relCd", paramInJson.getString("relCd"));
-        businessOrgStaffRels.add(businessOrgStaffRel);
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessOrgStaffRel", businessOrgStaffRels);
-
-        return business;
+        OrgStaffRelPo orgStaffRelPo = BeanConvertUtil.covertBean(businessOrgStaffRel, OrgStaffRelPo.class);
+        super.insert(dataFlowContext, orgStaffRelPo, BusinessTypeConstant.BUSINESS_TYPE_SAVE_ORG_STAFF_REL);
     }
 
     /**
@@ -59,22 +56,16 @@
      * @param paramInJson
      * @return
      */
-    public JSONObject addStaff(JSONObject paramInJson) {
+    public void addStaff(JSONObject paramInJson, DataFlowContext dataFlowContext) {
 
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_STORE_USER);
-        business.put(CommonConstant.HTTP_SEQ, 1);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONArray businessStoreUsers = new JSONArray();
         JSONObject businessStoreUser = new JSONObject();
         businessStoreUser.put("storeId", paramInJson.getString("storeId"));
         businessStoreUser.put("storeUserId", "-1");
         businessStoreUser.put("userId", paramInJson.getString("userId"));
         businessStoreUser.put("relCd", paramInJson.getString("relCd"));
-        businessStoreUsers.add(businessStoreUser);
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessStoreUser", businessStoreUsers);
 
-        return business;
+        StoreUserRelPo storeUserRelPo = BeanConvertUtil.covertBean(businessStoreUser, StoreUserRelPo.class);
+        super.insert(dataFlowContext, storeUserRelPo, BusinessTypeConstant.BUSINESS_TYPE_SAVE_STORE_USER);
     }
 
     /**
@@ -82,7 +73,7 @@
      *
      * @param paramObj
      */
-    public JSONObject addUser(JSONObject paramObj, DataFlowContext dataFlowContext) {
+    public void addUser(JSONObject paramObj, DataFlowContext dataFlowContext) {
 
         //鏍¢獙json 鏍煎紡涓槸鍚﹀寘鍚� name,email,levelCd,tel
         Assert.jsonObjectHaveKey(paramObj, "name", "璇锋眰鍙傛暟涓湭鍖呭惈name 鑺傜偣锛岃纭");
@@ -99,14 +90,8 @@
         }
 
 
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_USER_INFO);
-        business.put(CommonConstant.HTTP_SEQ, 1);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessUser", refreshParamIn(paramObj));
-
-        return business;
+        UserPo userPo = BeanConvertUtil.covertBean(refreshParamIn(paramObj), UserPo.class);
+        super.insert(dataFlowContext, userPo, BusinessTypeConstant.BUSINESS_TYPE_SAVE_USER_INFO);
     }
 
     /**
@@ -114,7 +99,7 @@
      *
      * @param paramObj
      */
-    public JSONObject registerUser(JSONObject paramObj, DataFlowContext dataFlowContext) {
+    public void registerUser(JSONObject paramObj, DataFlowContext dataFlowContext) {
 
         //鏍¢獙json 鏍煎紡涓槸鍚﹀寘鍚� name,email,levelCd,tel
         Assert.jsonObjectHaveKey(paramObj, "name", "璇锋眰鍙傛暟涓湭鍖呭惈name 鑺傜偣锛岃纭");
@@ -140,7 +125,7 @@
         userPassword = AuthenticationFactory.passwdMd5(userPassword);
         paramObj.put("password", userPassword);
 
-        if(paramObj.containsKey("openId") && !"-1".equals(paramObj.getString("openId"))){
+        if (paramObj.containsKey("openId") && !"-1".equals(paramObj.getString("openId"))) {
             JSONArray userAttr = new JSONArray();
             JSONObject userAttrObj = new JSONObject();
             userAttrObj.put("attrId", "-1");
@@ -150,9 +135,8 @@
             paramObj.put("businessUserAttr", userAttr);
         }
 
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessUser", paramObj);
-
-        return business;
+        UserPo userPo = BeanConvertUtil.covertBean(paramObj, UserPo.class);
+        super.insert(dataFlowContext, userPo, BusinessTypeConstant.BUSINESS_TYPE_SAVE_USER_INFO);
     }
 
 
@@ -173,17 +157,10 @@
         return paramObj;
     }
 
-    public JSONObject modifyStaff(JSONObject paramObj, DataFlowContext dataFlowContext) {
+    public void modifyStaff(JSONObject paramObj, DataFlowContext dataFlowContext) {
         //鏍¢獙json 鏍煎紡涓槸鍚﹀寘鍚� name,email,levelCd,tel
-
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_MODIFY_USER_INFO);
-        business.put(CommonConstant.HTTP_SEQ, 1);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessUser", builderStaffInfo(paramObj, dataFlowContext));
-
-        return business;
+        UserPo userPo = BeanConvertUtil.covertBean(builderStaffInfo(paramObj, dataFlowContext), UserPo.class);
+        super.update(dataFlowContext, userPo, BusinessTypeConstant.BUSINESS_TYPE_MODIFY_USER_INFO);
     }
 
     /**
@@ -219,19 +196,15 @@
      * @param paramInJson
      * @return
      */
-    public JSONObject deleteStaff(JSONObject paramInJson) {
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_DELETE_STORE_USER);
-        business.put(CommonConstant.HTTP_SEQ, 1);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONArray businessStoreUsers = new JSONArray();
+    public void deleteStaff(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+
         JSONObject businessStoreUser = new JSONObject();
         businessStoreUser.put("storeId", paramInJson.getString("storeId"));
         businessStoreUser.put("userId", paramInJson.getString("userId"));
-        businessStoreUsers.add(businessStoreUser);
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessStoreUser", businessStoreUsers);
 
-        return business;
+
+        UserPo userPo = BeanConvertUtil.covertBean(businessStoreUser, UserPo.class);
+        super.delete(dataFlowContext, userPo, BusinessTypeConstant.BUSINESS_TYPE_DELETE_STORE_USER);
 
     }
 
@@ -241,19 +214,13 @@
      * @param paramInJson
      * @return
      */
-    public JSONObject deleteUser(JSONObject paramInJson) {
+    public void deleteUser(JSONObject paramInJson, DataFlowContext dataFlowContext) {
         //鏍¢獙json 鏍煎紡涓槸鍚﹀寘鍚� name,email,levelCd,tel
-
-
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_REMOVE_USER_INFO);
-        business.put(CommonConstant.HTTP_SEQ, 1);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
         JSONObject businessStoreUser = new JSONObject();
         businessStoreUser.put("userId", paramInJson.getString("userId"));
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessUser", businessStoreUser);
 
-        return business;
+        UserPo userPo = BeanConvertUtil.covertBean(businessStoreUser, UserPo.class);
+        super.delete(dataFlowContext, userPo, BusinessTypeConstant.BUSINESS_TYPE_REMOVE_USER_INFO);
 
     }
 

--
Gitblit v1.8.0