Api/src/main/java/com/java110/api/listener/users/AddStaffServiceListener.java
@@ -63,7 +63,6 @@ //校验json 格式中是否包含 name,email,levelCd,tel Assert.jsonObjectHaveKey(paramIn,"name","请求参数中未包含name 节点,请确认"); Assert.jsonObjectHaveKey(paramIn,"email","请求参数中未包含email 节点,请确认"); Assert.jsonObjectHaveKey(paramIn,"levelCd","请求参数中未包含levelCd 节点,请确认"); Assert.jsonObjectHaveKey(paramIn,"tel","请求参数中未包含tel 节点,请确认"); Api/src/main/java/com/java110/api/listener/users/DisableStaffServiceListener.java
@@ -2,11 +2,8 @@ import com.alibaba.fastjson.JSONObject; import com.java110.api.listener.AbstractServiceApiDataFlowListener; import com.java110.common.cache.MappingCache; import com.java110.common.constant.CommonConstant; import com.java110.common.constant.MappingConstant; import com.java110.common.constant.ServiceCodeConstant; import com.java110.common.constant.UserLevelConstant; import com.java110.common.util.Assert; import com.java110.core.annotation.Java110Listener; import com.java110.core.context.DataFlowContext; @@ -53,12 +50,11 @@ Assert.jsonObjectHaveKey(paramIn,"userId","当前请求报文中未包含userId节点"); JSONObject business = JSONObject.parseObject("{\"datas\":{}}"); business.put(CommonConstant.HTTP_BUSINESS_SERVICE_CODE,ServiceCodeConstant.SERVICE_CODE_SAVE_USER_INFO); business.put(CommonConstant.HTTP_BUSINESS_SERVICE_NAME,"用户注册"); business.put(CommonConstant.HTTP_BUSINESS_SERVICE_CODE,ServiceCodeConstant.SERVICE_CODE_REMOVE_USER_INFO); business.put(CommonConstant.HTTP_BUSINESS_SERVICE_NAME,"停用用户"); business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessUser",refreshParamIn(paramIn)); HttpHeaders header = new HttpHeaders(); dataFlowContext.getRequestCurrentHeaders().put(CommonConstant.HTTP_USER_ID,"-1"); dataFlowContext.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD,"D"); String paramInObj = super.restToCenterProtocol(business,dataFlowContext.getRequestCurrentHeaders()).toJSONString(); @@ -76,13 +72,6 @@ */ private JSONObject refreshParamIn(String paramIn){ JSONObject paramObj = JSONObject.parseObject(paramIn); paramObj.put("userId","-1"); paramObj.put("levelCd", UserLevelConstant.USER_LEVEL_STAFF); //设置默认密码 String staffDefaultPassword = MappingCache.getValue(MappingConstant.KEY_STAFF_DEFAULT_PASSWORD); Assert.isNull(staffDefaultPassword,"映射表中未设置员工默认密码,请检查"+MappingConstant.KEY_STAFF_DEFAULT_PASSWORD); paramObj.put("password",staffDefaultPassword); return paramObj; } @Override Api/src/main/java/com/java110/api/listener/users/EnableStaffServiceListener.java
New file @@ -0,0 +1,81 @@ package com.java110.api.listener.users; import com.alibaba.fastjson.JSONObject; import com.java110.api.listener.AbstractServiceApiDataFlowListener; import com.java110.common.constant.CommonConstant; import com.java110.common.constant.ServiceCodeConstant; import com.java110.common.util.Assert; import com.java110.core.annotation.Java110Listener; import com.java110.core.context.DataFlowContext; import com.java110.entity.center.AppService; import com.java110.event.service.api.ServiceDataFlowEvent; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; /** * 启用员工接口 * @author wuxw * @create 2018-12-08 下午2:46 * @desc 启用员工信息,如二次入职,启用之前工号信息 **/ @Java110Listener("enableStaffServiceListener") public class EnableStaffServiceListener extends AbstractServiceApiDataFlowListener { @Override public String getServiceCode() { return ServiceCodeConstant.SERVICE_CODE_USER_STAFF_ENABLE; } /** * 接口请求方法 * @return */ @Override public HttpMethod getHttpMethod() { return HttpMethod.PUT; } /** * 业务逻辑处理 * 参数要求必须有员工ID * @param event */ @Override public void soService(ServiceDataFlowEvent event) { //获取数据上下文对象 DataFlowContext dataFlowContext = event.getDataFlowContext(); AppService service = event.getAppService(); String paramIn = dataFlowContext.getReqData(); Assert.jsonObjectHaveKey(paramIn,"userId","当前请求报文中未包含userId节点"); JSONObject business = JSONObject.parseObject("{\"datas\":{}}"); business.put(CommonConstant.HTTP_BUSINESS_SERVICE_CODE,ServiceCodeConstant.SERVICE_CODE_RECOVER_USER_INFO); business.put(CommonConstant.HTTP_BUSINESS_SERVICE_NAME,"停用用户"); business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessUser",refreshParamIn(paramIn)); HttpHeaders header = new HttpHeaders(); dataFlowContext.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD,"D"); String paramInObj = super.restToCenterProtocol(business,dataFlowContext.getRequestCurrentHeaders()).toJSONString(); HttpEntity<String> httpEntity = new HttpEntity<String>(paramInObj, header); //http://user-service/test/sayHello super.doRequest(dataFlowContext, service, httpEntity); super.doResponse(dataFlowContext); } /** * 对请求报文处理 * @param paramIn * @return */ private JSONObject refreshParamIn(String paramIn){ JSONObject paramObj = JSONObject.parseObject(paramIn); return paramObj; } @Override public int getOrder() { return 0; } } Api/src/main/java/com/java110/api/smo/impl/ApiServiceSMOImpl.java
@@ -240,6 +240,10 @@ DataFlowFactory.addCostTime(dataFlow, "judgeAuthority", "鉴权耗时", startDate); throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "requestTime 格式不对,遵循yyyyMMddHHmmss格式"); } //用户ID校验 if (StringUtil.isNullOrNone(dataFlow.getUserId())){ throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "USER_ID 不能为空"); } //判断 AppId 是否有权限操作相应的服务 @@ -252,6 +256,7 @@ throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "AppId 没有权限访问 serviceCode = " + dataFlow.getRequestHeaders().get(CommonConstant.HTTP_SERVICE)); } //检验白名单 List<String> whileListIp = dataFlow.getAppRoutes().get(0).getWhileListIp(); if (whileListIp != null && whileListIp.size() > 0 && !whileListIp.contains(dataFlow.getIp())) { java110-core/src/main/java/com/java110/core/context/ApiDataFlow.java
@@ -128,6 +128,7 @@ this.setTransactionId(headerAll.get(CommonConstant.HTTP_TRANSACTION_ID)); this.setReqSign(headerAll.get(CommonConstant.HTTP_SIGN)); this.setRequestTime(headerAll.get(CommonConstant.HTTP_REQ_TIME)); this.setUserId(headerAll.get(CommonConstant.HTTP_USER_ID)); if (headerAll != null){ this.requestHeaders.putAll(headerAll);