wuxw лет назад: 6
Родитель
Сommit
66d928996d

+ 145 - 0
Api/src/main/java/com/java110/api/listener/users/ChangeStaffPwdServiceListener.java

@@ -0,0 +1,145 @@
+package com.java110.api.listener.users;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.listener.AbstractServiceApiDataFlowListener;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.factory.DataFlowFactory;
+import com.java110.entity.center.AppService;
+import com.java110.event.service.api.ServiceDataFlowEvent;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.CommonConstant;
+import com.java110.utils.constant.ServiceCodeConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import com.java110.utils.util.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 修改员工 2018年12月6日
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("modifyStaffServiceListener")
+public class ChangeStaffPwdServiceListener extends AbstractServiceApiDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(ChangeStaffPwdServiceListener.class);
+
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_CHANGE_STAFF_PWD;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.POST;
+    }
+
+
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+
+
+    /**
+     * 添加员工信息
+     *
+     * @param event
+     */
+    @Override
+    public void soService(ServiceDataFlowEvent event) {
+        //获取数据上下文对象
+        DataFlowContext dataFlowContext = event.getDataFlowContext();
+        AppService service = event.getAppService();
+        String paramIn = dataFlowContext.getReqData();
+        Assert.isJsonObject(paramIn, "添加员工时请求参数有误,不是有效的json格式 " + paramIn);
+        JSONObject paramInJson = JSONObject.parseObject(paramIn);
+        Assert.jsonObjectHaveKey(paramInJson, "userId", "请求参数中未包含userId 节点,请确认");
+        Assert.jsonObjectHaveKey(paramInJson, "oldPwd", "请求参数中未包含oldPwd 节点,请确认");
+        Assert.jsonObjectHaveKey(paramInJson, "newPwd", "请求参数中未包含newPwd 节点,请确认");
+
+        JSONArray businesses = new JSONArray();
+        //判断请求报文中包含 userId 并且 不为-1时 将已有用户添加为员工,反之,则添加用户再将用户添加为员工
+        JSONObject staffBusiness = modifyStaff(paramInJson, dataFlowContext);
+        businesses.add(staffBusiness);
+
+        HttpHeaders header = new HttpHeaders();
+        dataFlowContext.getRequestCurrentHeaders().put(CommonConstant.HTTP_USER_ID, paramInJson.getString("userId"));
+        dataFlowContext.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D");
+
+        String paramInObj = super.restToCenterProtocol(businesses, dataFlowContext.getRequestCurrentHeaders()).toJSONString();
+
+        //将 rest header 信息传递到下层服务中去
+        super.freshHttpHeader(header, dataFlowContext.getRequestCurrentHeaders());
+
+        HttpEntity<String> httpEntity = new HttpEntity<String>(paramInObj, header);
+        //http://user-service/test/sayHello
+        super.doRequest(dataFlowContext, service, httpEntity);
+
+        super.doResponse(dataFlowContext);
+    }
+
+
+    private JSONObject modifyStaff(JSONObject paramObj, DataFlowContext dataFlowContext) {
+        //校验json 格式中是否包含 name,email,levelCd,tel
+        Assert.jsonObjectHaveKey(paramObj, "name", "请求参数中未包含name 节点,请确认");
+        Assert.jsonObjectHaveKey(paramObj, "tel", "请求参数中未包含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;
+    }
+
+    /**
+     * 构建员工信息
+     *
+     * @param paramObj
+     * @param dataFlowContext
+     * @return
+     */
+    private JSONObject builderStaffInfo(JSONObject paramObj, DataFlowContext dataFlowContext) {
+
+        //首先根据员工ID查询员工信息,根据员工信息修改相应的数据
+        ResponseEntity responseEntity = null;
+        AppService appService = DataFlowFactory.getService(dataFlowContext.getAppId(), ServiceCodeConstant.SERVICE_CODE_QUERY_USER_USERINFO);
+        if (appService == null) {
+            throw new ListenerExecuteException(1999, "当前没有权限访问" + ServiceCodeConstant.SERVICE_CODE_QUERY_USER_USERINFO);
+
+        }
+        String requestUrl = appService.getUrl() + "?userId=" + paramObj.getString("userId");
+        HttpHeaders header = new HttpHeaders();
+        header.add(CommonConstant.HTTP_SERVICE.toLowerCase(), ServiceCodeConstant.SERVICE_CODE_QUERY_USER_USERINFO);
+        dataFlowContext.getRequestHeaders().put("REQUEST_URL", requestUrl);
+        HttpEntity<String> httpEntity = new HttpEntity<String>("", header);
+        doRequest(dataFlowContext, appService, httpEntity);
+        responseEntity = dataFlowContext.getResponseEntity();
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            dataFlowContext.setResponseEntity(responseEntity);
+        }
+
+        JSONObject userInfo = JSONObject.parseObject(responseEntity.getBody().toString());
+
+        if (!paramObj.getString("oldPwd").equals(userInfo.getString("password"))) {
+            throw new IllegalArgumentException("原始密码错误");
+        }
+        userInfo.putAll(paramObj);
+        userInfo.put("password", paramObj.getString("newPwd"));
+
+        return userInfo;
+    }
+
+}

+ 32 - 0
WebService/src/main/java/com/java110/web/components/staff/ChangeStaffPwdComponent.java

@@ -0,0 +1,32 @@
+package com.java110.web.components.staff;
+
+
+import com.java110.core.context.IPageData;
+import com.java110.web.smo.IChangeStaffPwdServiceSMO;
+import com.java110.web.smo.IStaffServiceSMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+/**
+ * 搜索员工
+ */
+@Component("changeStaffPwd")
+public class ChangeStaffPwdComponent {
+
+    @Autowired
+    IChangeStaffPwdServiceSMO changeStaffPwdServiceSMOImpl;
+
+    public ResponseEntity<String> change(IPageData pd) {
+        return changeStaffPwdServiceSMOImpl.change(pd);
+    }
+
+    public IChangeStaffPwdServiceSMO getChangeStaffPwdServiceSMOImpl() {
+        return changeStaffPwdServiceSMOImpl;
+    }
+
+    public void setChangeStaffPwdServiceSMOImpl(IChangeStaffPwdServiceSMO changeStaffPwdServiceSMOImpl) {
+        this.changeStaffPwdServiceSMOImpl = changeStaffPwdServiceSMOImpl;
+    }
+}

+ 19 - 0
WebService/src/main/java/com/java110/web/smo/IChangeStaffPwdServiceSMO.java

@@ -0,0 +1,19 @@
+package com.java110.web.smo;
+
+import com.java110.core.context.IPageData;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 修改员工密码
+ * Created by Administrator on 2019/4/2.
+ */
+public interface IChangeStaffPwdServiceSMO {
+
+    /**
+     * 保存员工信息
+     *
+     * @param pd
+     * @return
+     */
+    ResponseEntity<String> change(IPageData pd);
+}

+ 71 - 0
WebService/src/main/java/com/java110/web/smo/impl/ChangeStaffPwdSMOImpl.java

@@ -0,0 +1,71 @@
+package com.java110.web.smo.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.component.AbstractComponentSMO;
+import com.java110.core.context.IPageData;
+import com.java110.core.factory.AuthenticationFactory;
+import com.java110.entity.component.ComponentValidateResult;
+import com.java110.utils.constant.ServiceConstant;
+import com.java110.utils.exception.SMOException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.web.smo.IChangeStaffPwdServiceSMO;
+import com.java110.web.smo.carInout.IListCarInoutsSMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Map;
+
+/**
+ * 查询carInout服务类
+ */
+@Service("changeStaffPwdSMOImpl")
+public class ChangeStaffPwdSMOImpl extends AbstractComponentSMO implements IChangeStaffPwdServiceSMO {
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Override
+    public ResponseEntity<String> change(IPageData pd) throws SMOException {
+        return businessProcess(pd);
+    }
+
+    @Override
+    protected void validate(IPageData pd, JSONObject paramIn) {
+        Assert.hasKeyAndValue(paramIn, "communityId", "必填,请填写小区信息");
+        Assert.hasKeyAndValue(paramIn, "oldPwd", "必填,请填写原始密码");
+        Assert.hasKeyAndValue(paramIn, "newPwd", "必填,请填写新密码");
+
+        //super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.AGENT_HAS_LIST_CARINOUT);
+    }
+
+    @Override
+    protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) {
+        ComponentValidateResult result = super.validateStoreStaffCommunityRelationship(pd, restTemplate);
+
+        Map paramMap = BeanConvertUtil.beanCovertMap(result);
+        paramIn.putAll(paramMap);
+
+        paramIn.put("oldPwd", AuthenticationFactory.passwdMd5(paramIn.getString("oldPwd")));
+        paramIn.put("newPwd", AuthenticationFactory.passwdMd5(paramIn.getString("newPwd")));
+
+        String apiUrl = ServiceConstant.SERVICE_API_URL + "/api/user.changeStaffPwd";
+
+        ResponseEntity<String> responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(),
+                apiUrl,
+                HttpMethod.POST);
+
+        return responseEntity;
+    }
+
+    public RestTemplate getRestTemplate() {
+        return restTemplate;
+    }
+
+    public void setRestTemplate(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+}

+ 62 - 0
WebService/src/main/resources/components/staffPackage/changeStaffPwd/changeStaffPwd.html

@@ -0,0 +1,62 @@
+<div>
+    <div class="row">
+        <div class="col-lg-12">
+            <div class="ibox ">
+                <div class="ibox-title">
+                    <h5>修改密码</h5>
+                    <div class="ibox-tools" style="top:10px;">
+
+                    </div>
+                </div>
+                <div class="ibox-content">
+                    <div>
+                        <div>
+                            <div class="form-group row">
+                                <div class="col-sm-2"></div>
+                                <label class="col-sm-2 col-form-label">原始密码</label>
+                                <div class="col-sm-6">
+                                    <div class="custom-file">
+                                        <input v-model="changeStaffPwdInfo.oldPwd" type="password" placeholder="必填,请输入原始密码"
+                                               class="form-control">
+                                    </div>
+                                </div>
+                                <div class="col-sm-2"></div>
+                            </div>
+                            <div class="form-group row">
+                                <div class="col-sm-2"></div>
+                                <label class="col-sm-2 col-form-label">新密码</label>
+                                <div class="col-sm-6">
+                                    <div class="custom-file">
+                                        <input v-model="changeStaffPwdInfo.newPwd" type="password" placeholder="必填,请输入新密码"
+                                               class="form-control">
+                                    </div>
+                                </div>
+                                <div class="col-sm-2"></div>
+                            </div>
+                            <div class="form-group row">
+                                <div class="col-sm-2"></div>
+                                <label class="col-sm-2 col-form-label">确认密码</label>
+                                <div class="col-sm-6">
+                                    <div class="custom-file">
+                                        <input v-model="changeStaffPwdInfo.reNewPwd" type="password" placeholder="必填,请输入确认密码"
+                                               class="form-control">
+                                    </div>
+                                </div>
+                                <div class="col-sm-2"></div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <div class="row">
+        <div class="col-md-10"></div>
+        <div class="col-md-2 " style="margin-bottom:10px; text-align:right">
+            <button type="button" class="btn btn-primary"
+                    v-on:click="_changePwd()">确认修改
+            </button>
+        </div>
+    </div>
+</div>

+ 97 - 0
WebService/src/main/resources/components/staffPackage/changeStaffPwd/changeStaffPwd.js

@@ -0,0 +1,97 @@
+/**
+ 权限组
+ **/
+(function (vc) {
+
+    vc.extends({
+        data: {
+            changeStaffPwdInfo: {
+                communityId: vc.getCurrentCommunity().communityId,
+                oldPwd: '',
+                newPwd: '',
+                reNewPwd:''
+            }
+        },
+
+        _initMethod: function () {
+
+        },
+        _initEvent: function () {
+
+        },
+        methods: {
+            assetImportValidate: function () {
+                return vc.validate.validate({
+                    changeStaffPwdInfo: vc.component.changeStaffPwdInfo
+                }, {
+
+                    'changeStaffPwdInfo.oldPwd': [
+                        {
+                            limit: "required",
+                            param: "",
+                            errInfo: "原始密码不能为空"
+                        }
+                    ],
+                    'changeStaffPwdInfo.newPwd': [
+                        {
+                            limit: "required",
+                            param: "",
+                            errInfo: "新密码不能为空"
+                        }
+                    ],
+                    'changeStaffPwdInfo.reNewPwd': [
+                        {
+                            limit: "required",
+                            param: "",
+                            errInfo: "确认密码不能为空"
+                        }
+                    ],
+                    'changeStaffPwdInfo.communityId': [
+                        {
+                            limit: "required",
+                            param: "",
+                            errInfo: "还未入驻小区,请先入驻小区"
+                        }
+                    ]
+                });
+            },
+            _changePwd: function () {
+
+                if (!vc.component.assetImportValidate()) {
+                    return;
+                }
+
+                if(vc.component.changeStaffPwdInfo.newPwd != vc.component.changeStaffPwdInfo.reNewPwd){
+                    vc.toast('两次密码不一致');
+                    return ;
+                }
+
+                vc.http.post(
+                    'changeStaffPwd',
+                    'change',
+                    JSON.stringify(vc.component.addStaffInfo),
+                    {
+                        emulateJSON:true
+                     },
+                     function(json,res){
+                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
+                        if(res.status == 200){
+                            //关闭model
+                            vc.toast("修改成功");
+                            vc.component.changeStaffPwdInfo.oldPwd = '';
+                            vc.component.changeStaffPwdInfo.newPwd = '';
+                            vc.component.changeStaffPwdInfo.reNewPwd = '';
+                            return ;
+                        }
+                        vc.toast(json);
+                     },
+                     function(errInfo,error){
+                        console.log('请求失败处理');
+                        vc.toast(errInfo);
+                     });
+
+            }
+        }
+    });
+
+})(window.vc);

+ 36 - 0
WebService/src/main/resources/views/changeStaffPwdFlow.html

@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang="en"
+      xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:th="http://www.thymeleaf.org"
+      xmlns:vc="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"/>
+    <title>修改密码|精诚物业服务有限公司</title>
+    <vc:create name="commonTop"></vc:create>
+</head>
+<body>
+<vc:create name="bodyTop"></vc:create>
+<div id="wrapper">
+    <vc:create name="menu"></vc:create>
+
+
+    <div id="page-wrapper" class="gray-bg dashbard-1">
+        <div class="row border-bottom">
+            <vc:create name="nav"></vc:create>
+        </div>
+        <div class="wrapper wrapper-content" style="padding-bottom: 0px;">
+            <vc:create name="breadcrumb"></vc:create>
+        </div>
+        <!-- id="component" -->
+        <div class="wrapper wrapper-content animated fadeInRight">
+            <vc:create name="changeStaffPwd"></vc:create>
+        </div>
+
+        <vc:create name="copyright"></vc:create>
+
+    </div>
+</div>
+
+<vc:create name="commonBottom"></vc:create>
+</body>
+</html>

+ 5 - 0
java110-utils/src/main/java/com/java110/utils/constant/ServiceCodeConstant.java

@@ -300,6 +300,11 @@ public class ServiceCodeConstant {
      */
     public static final String SERVICE_CODE_QUERY_STAFF_BY_NAME = "query.staff.byName";
 
+    /**
+     * 修改员工密码
+     */
+    public static final String SERVICE_CODE_CHANGE_STAFF_PWD = "user.changeStaffPwd";
+
     /**
      * 保存商户信息
      */