Sfoglia il codice sorgente

修复修改员工时的bug

wuxw 7 anni fa
parent
commit
ec1329e655

+ 0 - 98
Api/src/main/java/com/java110/api/listener/users/ModifyStaffServiceListener.java

@@ -81,60 +81,9 @@ public class ModifyStaffServiceListener extends AbstractServiceApiDataFlowListen
         super.doRequest(dataFlowContext, service, httpEntity);
 
         super.doResponse(dataFlowContext);
-
-        //如果不成功直接返回
-        if(dataFlowContext.getResponseEntity().getStatusCode() != HttpStatus.OK){
-            return ;
-        }
-
-        //赋权
-        privilegeUserDefault(dataFlowContext,paramInJson);
-    }
-
-    /**
-     * 添加员工
-     * @param paramInJson
-     * @return
-     */
-    private JSONObject addStaff(JSONObject paramInJson){
-
-        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;
     }
 
-    /**
-     * 添加用户
-     * @param paramObj
-     */
-    private JSONObject addUser(JSONObject paramObj,DataFlowContext dataFlowContext){
-
-        //校验json 格式中是否包含 name,email,levelCd,tel
-        Assert.jsonObjectHaveKey(paramObj,"name","请求参数中未包含name 节点,请确认");
-        Assert.jsonObjectHaveKey(paramObj,"email","请求参数中未包含email 节点,请确认");
-        Assert.jsonObjectHaveKey(paramObj,"tel","请求参数中未包含tel 节点,请确认");
-
-
-        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;
-    }
 
     private JSONObject modifyStaff(JSONObject paramObj,DataFlowContext dataFlowContext){
         //校验json 格式中是否包含 name,email,levelCd,tel
@@ -185,51 +134,4 @@ public class ModifyStaffServiceListener extends AbstractServiceApiDataFlowListen
         return userInfo;
     }
 
-    /**
-     * 对请求报文处理
-     * @param paramObj
-     * @return
-     */
-    private JSONObject refreshParamIn(JSONObject paramObj){
-        //paramObj.put("userId","-1");
-        paramObj.put("levelCd", UserLevelConstant.USER_LEVEL_STAFF);
-        //设置默认密码
-        String staffDefaultPassword = MappingCache.getValue(MappingConstant.KEY_STAFF_DEFAULT_PASSWORD);
-        Assert.hasLength(staffDefaultPassword,"映射表中未设置员工默认密码,请检查"+MappingConstant.KEY_STAFF_DEFAULT_PASSWORD);
-        staffDefaultPassword = AuthenticationFactory.passwdMd5(staffDefaultPassword);
-        paramObj.put("password",staffDefaultPassword);
-        return paramObj;
-    }
-
-
-    /**
-     * 用户赋权
-     * @return
-     */
-    private void privilegeUserDefault(DataFlowContext dataFlowContext,JSONObject paramObj){
-        ResponseEntity responseEntity= null;
-        AppService appService = DataFlowFactory.getService(dataFlowContext.getAppId(), ServiceCodeConstant.SERVICE_CODE_SAVE_USER_DEFAULT_PRIVILEGE);
-        if(appService == null){
-            responseEntity = new ResponseEntity<String>("当前没有权限访问"+ServiceCodeConstant.SERVICE_CODE_SAVE_USER_DEFAULT_PRIVILEGE,HttpStatus.UNAUTHORIZED);
-            dataFlowContext.setResponseEntity(responseEntity);
-            return ;
-        }
-        String requestUrl = appService.getUrl();
-        HttpHeaders header = new HttpHeaders();
-        header.add(CommonConstant.HTTP_SERVICE.toLowerCase(),ServiceCodeConstant.SERVICE_CODE_SAVE_USER_DEFAULT_PRIVILEGE);
-        super.freshHttpHeader(header,dataFlowContext.getRequestCurrentHeaders());
-        JSONObject paramInObj = new JSONObject();
-        paramInObj.put("userId",paramObj.getString("userId"));
-        paramInObj.put("storeTypeCd",paramObj.getString("storeTypeCd"));
-        paramInObj.put("userFlag","staff");
-        HttpEntity<String> httpEntity = new HttpEntity<String>(paramInObj.toJSONString(), header);
-        doRequest(dataFlowContext,appService,httpEntity);
-        responseEntity = dataFlowContext.getResponseEntity();
-
-        if(responseEntity.getStatusCode() != HttpStatus.OK){
-            dataFlowContext.setResponseEntity(responseEntity);
-        }
-    }
-
-
 }

+ 3 - 1
WebService/src/main/java/com/java110/web/smo/impl/StaffServiceSMOImpl.java

@@ -106,8 +106,10 @@ public class StaffServiceSMOImpl extends BaseComponentSMO implements IStaffServi
         ResponseEntity<String> responseEntity = null;
         //校验 前台数据
         modifyStaffValidate(pd);
+        JSONObject paramIn = JSONObject.parseObject(pd.getReqData());
+        paramIn.put("name",paramIn.getString("username"));
         //修改用户信息
-        responseEntity = this.callCenterService(restTemplate,pd,"",
+        responseEntity = this.callCenterService(restTemplate,pd,paramIn.toJSONString(),
                 ServiceConstant.SERVICE_API_URL+"/api/user.staff.modify", HttpMethod.POST);
         return responseEntity;
     }

+ 1 - 1
WebService/src/main/resources/components/edit-staff/editStaff.html

@@ -34,7 +34,7 @@
                                 <div class="col-sm-10"><input v-model="editStaffInfo.address" type="text" placeholder="请填写家庭住址" class="form-control"></div>
                             </div>
                             <div class="ibox-content">
-                                <button class="btn btn-primary float-right" type="button" v-on:click="editStaffInfo()" ><i class="fa fa-check"></i>&nbsp;修改</button>
+                                <button class="btn btn-primary float-right" type="button" v-on:click="editStaffSubmit()" ><i class="fa fa-check"></i>&nbsp;修改</button>
                                 <button type="button" class="btn btn-warning float-right" style="margin-right:20px;" data-dismiss="modal">取消</button>
                             </div>
                         </div>

+ 61 - 61
WebService/src/main/resources/components/edit-staff/editStaff.js

@@ -32,68 +32,68 @@
                 vc.component.editStaffInfo.address = _staffInfo.address;
             },
             editStaffValidate(){
-                            return vc.validate.validate({
-                                editStaffInfo:vc.component.editStaffInfo
-                            },{
-                                'editStaffInfo.username':[
-                                    {
-                                        limit:"required",
-                                        param:"",
-                                        errInfo:"用户名不能为空"
-                                    },
-                                    {
-                                        limit:"maxin",
-                                        param:"2,10",
-                                        errInfo:"用户名长度必须在2位至10位"
-                                    },
-                                ],
-                                'editStaffInfo.email':[
-                                    {
-                                        limit:"required",
-                                        param:"",
-                                        errInfo:"密码不能为空"
-                                    },
-                                    {
-                                        limit:"email",
-                                        param:"",
-                                        errInfo:"不是有效的邮箱"
-                                    },
-                                ],
-                                'editStaffInfo.tel':[
-                                    {
-                                        limit:"required",
-                                        param:"",
-                                        errInfo:"手机号不能为空"
-                                    },
-                                    {
-                                        limit:"phone",
-                                        param:"",
-                                        errInfo:"不是有效的手机号"
-                                    }
-                                ],
-                                'editStaffInfo.sex':[
-                                    {
-                                        limit:"required",
-                                        param:"",
-                                        errInfo:"性别不能为空"
-                                    }
-                                ],
-                                'editStaffInfo.address':[
-                                    {
-                                        limit:"required",
-                                        param:"",
-                                        errInfo:"地址不能为空"
-                                    },
-                                    {
-                                        limit:"maxLength",
-                                        param:"200",
-                                        errInfo:"地址长度不能超过200位"
-                                    },
-                                ]
-
-                            });
+                return vc.validate.validate({
+                    editStaffInfo:vc.component.editStaffInfo
+                },{
+                    'editStaffInfo.username':[
+                        {
+                            limit:"required",
+                            param:"",
+                            errInfo:"用户名不能为空"
+                        },
+                        {
+                            limit:"maxin",
+                            param:"2,10",
+                            errInfo:"用户名长度必须在2位至10位"
+                        },
+                    ],
+                    'editStaffInfo.email':[
+                        {
+                            limit:"required",
+                            param:"",
+                            errInfo:"密码不能为空"
+                        },
+                        {
+                            limit:"email",
+                            param:"",
+                            errInfo:"不是有效的邮箱"
+                        },
+                    ],
+                    'editStaffInfo.tel':[
+                        {
+                            limit:"required",
+                            param:"",
+                            errInfo:"手机号不能为空"
+                        },
+                        {
+                            limit:"phone",
+                            param:"",
+                            errInfo:"不是有效的手机号"
+                        }
+                    ],
+                    'editStaffInfo.sex':[
+                        {
+                            limit:"required",
+                            param:"",
+                            errInfo:"性别不能为空"
+                        }
+                    ],
+                    'editStaffInfo.address':[
+                        {
+                            limit:"required",
+                            param:"",
+                            errInfo:"地址不能为空"
+                        },
+                        {
+                            limit:"maxLength",
+                            param:"200",
+                            errInfo:"地址长度不能超过200位"
                         },
-            editStaffInfo:function(){
+                    ]
+
+                });
+            },
+            editStaffSubmit:function(){
                  if(!vc.component.editStaffValidate()){
                     vc.component.editStaffInfo.errorInfo = vc.validate.errInfo;
                     return ;