|
@@ -1,23 +1,23 @@
|
|
|
-package com.java110.api.listener.login;
|
|
|
|
|
|
|
+package com.java110.user.cmd;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.java110.api.listener.AbstractServiceApiDataFlowListener;
|
|
|
|
|
-import com.java110.core.annotation.Java110Listener;
|
|
|
|
|
|
|
+import com.java110.core.annotation.Java110Cmd;
|
|
|
import com.java110.core.context.DataFlowContext;
|
|
import com.java110.core.context.DataFlowContext;
|
|
|
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
|
|
|
|
|
|
|
+import com.java110.core.context.ICmdDataFlowContext;
|
|
|
|
|
+import com.java110.core.event.cmd.AbstractServiceCmdListener;
|
|
|
|
|
+import com.java110.core.event.cmd.CmdEvent;
|
|
|
import com.java110.core.factory.AuthenticationFactory;
|
|
import com.java110.core.factory.AuthenticationFactory;
|
|
|
import com.java110.core.factory.GenerateCodeFactory;
|
|
import com.java110.core.factory.GenerateCodeFactory;
|
|
|
import com.java110.dto.store.StoreUserDto;
|
|
import com.java110.dto.store.StoreUserDto;
|
|
|
import com.java110.dto.user.UserDto;
|
|
import com.java110.dto.user.UserDto;
|
|
|
import com.java110.dto.userLogin.UserLoginDto;
|
|
import com.java110.dto.userLogin.UserLoginDto;
|
|
|
-import com.java110.entity.center.AppService;
|
|
|
|
|
import com.java110.intf.store.IStoreInnerServiceSMO;
|
|
import com.java110.intf.store.IStoreInnerServiceSMO;
|
|
|
import com.java110.intf.user.IUserInnerServiceSMO;
|
|
import com.java110.intf.user.IUserInnerServiceSMO;
|
|
|
import com.java110.intf.user.IUserLoginInnerServiceSMO;
|
|
import com.java110.intf.user.IUserLoginInnerServiceSMO;
|
|
|
import com.java110.po.userLogin.UserLoginPo;
|
|
import com.java110.po.userLogin.UserLoginPo;
|
|
|
import com.java110.utils.constant.CommonConstant;
|
|
import com.java110.utils.constant.CommonConstant;
|
|
|
import com.java110.utils.constant.ResponseConstant;
|
|
import com.java110.utils.constant.ResponseConstant;
|
|
|
-import com.java110.utils.constant.ServiceCodeConstant;
|
|
|
|
|
|
|
+import com.java110.utils.exception.CmdException;
|
|
|
import com.java110.utils.exception.SMOException;
|
|
import com.java110.utils.exception.SMOException;
|
|
|
import com.java110.utils.util.Assert;
|
|
import com.java110.utils.util.Assert;
|
|
|
import com.java110.utils.util.BeanConvertUtil;
|
|
import com.java110.utils.util.BeanConvertUtil;
|
|
@@ -25,25 +25,19 @@ import com.java110.utils.util.DateUtil;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpMethod;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 用户注册 侦听
|
|
|
|
|
- * Created by wuxw on 2018/5/18.
|
|
|
|
|
|
|
+ * 保存编码映射处理类
|
|
|
*/
|
|
*/
|
|
|
-@Java110Listener("pcUserLoginListener")
|
|
|
|
|
-public class PcUserLoginListener extends AbstractServiceApiDataFlowListener {
|
|
|
|
|
-
|
|
|
|
|
- private final static Logger logger = LoggerFactory.getLogger(PcUserLoginListener.class);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+@Java110Cmd(serviceCode = "login.pcUserLogin")
|
|
|
|
|
+public class PcUserLoginCmd extends AbstractServiceCmdListener {
|
|
|
|
|
+ private final static Logger logger = LoggerFactory.getLogger(PcUserLoginCmd.class);
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IUserLoginInnerServiceSMO userLoginInnerServiceSMOImpl;
|
|
private IUserLoginInnerServiceSMO userLoginInnerServiceSMOImpl;
|
|
|
|
|
|
|
@@ -52,48 +46,19 @@ public class PcUserLoginListener extends AbstractServiceApiDataFlowListener {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IUserInnerServiceSMO userInnerServiceSMOImpl;
|
|
private IUserInnerServiceSMO userInnerServiceSMOImpl;
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public String getServiceCode() {
|
|
|
|
|
- return ServiceCodeConstant.SERVICE_CODE_PC_USER_LOGIN;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public HttpMethod getHttpMethod() {
|
|
|
|
|
- return HttpMethod.POST;
|
|
|
|
|
|
|
+ protected void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
|
|
|
|
|
+ String paramIn = cmdDataFlowContext.getReqData();
|
|
|
|
|
+ Assert.isJsonObject(paramIn, "用户注册请求参数有误,不是有效的json格式 " + paramIn);
|
|
|
|
|
+ Assert.jsonObjectHaveKey(paramIn, "username", "用户登录,未包含username节点,请检查" + paramIn);
|
|
|
|
|
+ Assert.jsonObjectHaveKey(paramIn, "passwd", "用户登录,未包含passwd节点,请检查" + paramIn);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public int getOrder() {
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ protected void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 请求参数格式:
|
|
|
|
|
- * {
|
|
|
|
|
- * "username":"admin",
|
|
|
|
|
- * "passwd":"1234565"
|
|
|
|
|
- * }
|
|
|
|
|
- * 返回报文:
|
|
|
|
|
- * {
|
|
|
|
|
- * "userId":"",
|
|
|
|
|
- * "token":"12dddd"
|
|
|
|
|
- * }
|
|
|
|
|
- *
|
|
|
|
|
- * @param event
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- public void soService(ServiceDataFlowEvent event) {
|
|
|
|
|
- //获取数据上下文对象
|
|
|
|
|
- DataFlowContext dataFlowContext = event.getDataFlowContext();
|
|
|
|
|
- String paramIn = dataFlowContext.getReqData();
|
|
|
|
|
- Assert.isJsonObject(paramIn, "用户注册请求参数有误,不是有效的json格式 " + paramIn);
|
|
|
|
|
- Assert.jsonObjectHaveKey(paramIn, "username", "用户登录,未包含username节点,请检查" + paramIn);
|
|
|
|
|
- Assert.jsonObjectHaveKey(paramIn, "passwd", "用户登录,未包含passwd节点,请检查" + paramIn);
|
|
|
|
|
ResponseEntity responseEntity = null;
|
|
ResponseEntity responseEntity = null;
|
|
|
- JSONObject paramInJson = JSONObject.parseObject(paramIn);
|
|
|
|
|
|
|
+ JSONObject paramInJson = JSONObject.parseObject(cmdDataFlowContext.getReqData());
|
|
|
//根据AppId 查询 是否有登录的服务,查询登录地址调用
|
|
//根据AppId 查询 是否有登录的服务,查询登录地址调用
|
|
|
UserDto userDto = new UserDto();
|
|
UserDto userDto = new UserDto();
|
|
|
userDto.setName(paramInJson.getString("username"));
|
|
userDto.setName(paramInJson.getString("username"));
|
|
@@ -107,7 +72,7 @@ public class PcUserLoginListener extends AbstractServiceApiDataFlowListener {
|
|
|
}
|
|
}
|
|
|
if (userDtos == null || userDtos.size() < 1) {
|
|
if (userDtos == null || userDtos.size() < 1) {
|
|
|
responseEntity = new ResponseEntity<String>("用户或密码错误", HttpStatus.UNAUTHORIZED);
|
|
responseEntity = new ResponseEntity<String>("用户或密码错误", HttpStatus.UNAUTHORIZED);
|
|
|
- dataFlowContext.setResponseEntity(responseEntity);
|
|
|
|
|
|
|
+ cmdDataFlowContext.setResponseEntity(responseEntity);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -120,7 +85,7 @@ public class PcUserLoginListener extends AbstractServiceApiDataFlowListener {
|
|
|
String state = storeUserDtos.get(0).getState();
|
|
String state = storeUserDtos.get(0).getState();
|
|
|
if ("48002".equals(state)) {
|
|
if ("48002".equals(state)) {
|
|
|
responseEntity = new ResponseEntity<String>("当前商户限制登录,请联系管理员", HttpStatus.UNAUTHORIZED);
|
|
responseEntity = new ResponseEntity<String>("当前商户限制登录,请联系管理员", HttpStatus.UNAUTHORIZED);
|
|
|
- dataFlowContext.setResponseEntity(responseEntity);
|
|
|
|
|
|
|
+ cmdDataFlowContext.setResponseEntity(responseEntity);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -145,26 +110,10 @@ public class PcUserLoginListener extends AbstractServiceApiDataFlowListener {
|
|
|
userLoginPo.setUserName(userInfo.getString("userName"));
|
|
userLoginPo.setUserName(userInfo.getString("userName"));
|
|
|
userLoginInnerServiceSMOImpl.saveUserLogin(userLoginPo);
|
|
userLoginInnerServiceSMOImpl.saveUserLogin(userLoginPo);
|
|
|
responseEntity = new ResponseEntity<String>(userInfo.toJSONString(), HttpStatus.OK);
|
|
responseEntity = new ResponseEntity<String>(userInfo.toJSONString(), HttpStatus.OK);
|
|
|
- dataFlowContext.setResponseEntity(responseEntity);
|
|
|
|
|
|
|
+ cmdDataFlowContext.setResponseEntity(responseEntity);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
logger.error("登录异常:", e);
|
|
logger.error("登录异常:", e);
|
|
|
throw new SMOException(ResponseConstant.RESULT_CODE_INNER_ERROR, "系统内部错误,请联系管理员");
|
|
throw new SMOException(ResponseConstant.RESULT_CODE_INNER_ERROR, "系统内部错误,请联系管理员");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 对请求报文处理
|
|
|
|
|
- *
|
|
|
|
|
- * @param paramIn
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- private JSONObject refreshParamIn(String paramIn) {
|
|
|
|
|
- JSONObject paramObj = JSONObject.parseObject(paramIn);
|
|
|
|
|
- paramObj.put("userId", "-1");
|
|
|
|
|
- paramObj.put("levelCd", "0");
|
|
|
|
|
-
|
|
|
|
|
- return paramObj;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|