Commit d507c2be9dba175e26c7fd69efacec90440ff9ef

Authored by weiliwhereareyou@163.com
1 parent 5f944c8a

登录注册接口开发

mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/common/Constant.java
... ... @@ -170,8 +170,8 @@ public class Constant {
170 170 /**
171 171 * 代购订单使用
172 172 */
173   - public static final Long OPERATOR_ROLE_BUYER = 10L; //操作人角色 10买家
174   - public static final Long OPERATOR_ROLE_SELLER = 20L; //操作人角色 20卖家
  173 + public static final Integer OPERATOR_ROLE_BUYER = 10; //操作人角色 10买家
  174 + public static final Integer OPERATOR_ROLE_SELLER = 20; //操作人角色 20卖家
175 175 /** 是否选择代找物流:1-是,2-否*/
176 176 public static final Integer QUERYPARAM_ISAGENTLOGISTICS_YES = 1;
177 177 public static final Integer QUERYPARAM_ISAGENTLOGISTICS_NO = 0;
... ...
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/login/SendVeriCodeReq.java
... ... @@ -37,7 +37,7 @@ public class SendVeriCodeReq extends BaseReq {
37 37 /**
38 38 * 消息类型
39 39 */
40   - @ApiModelProperty(value = "消息类型:1登录,2注册,3找回密码",required = true)
  40 + @ApiModelProperty(value = "消息类型:1验证码登录,2注册,3找回密码",required = true)
41 41 private Integer msgType;
42 42  
43 43  
... ...
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/login/SendVeriCodeResp.java
... ... @@ -30,11 +30,14 @@ public class SendVeriCodeResp extends BaseResp {
30 30 */
31 31 @ApiModelProperty(value = "发送结果:1成功")
32 32 private Integer sendCode = SEND_CODE_ERROR;
33   - ///**
34   - // * 万能验证码
35   - // */
36   - //@ApiModelProperty(value = "万能验证码")
37   - //private String passKey;
  33 + /**
  34 + * 验证码
  35 + */
  36 + @ApiModelProperty(value = "验证码(测试用)")
  37 + private String passKey;
  38 +
  39 +
  40 +
38 41  
39 42 /**
40 43 * get value of SendVeriCodeResp.sendCode
... ... @@ -59,4 +62,11 @@ public class SendVeriCodeResp extends BaseResp {
59 62 }
60 63  
61 64  
  65 + public String getPassKey() {
  66 + return passKey;
  67 + }
  68 +
  69 + public void setPassKey(String passKey) {
  70 + this.passKey = passKey;
  71 + }
62 72 }
... ...
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/PassportRPC.java
... ... @@ -7,6 +7,7 @@ import com.diligrp.mobsite.getway.domain.protocol.login.LoginReq;
7 7 import com.diligrp.mobsite.getway.domain.protocol.register.SellerRegisterReq;
8 8 import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterReq;
9 9 import com.diligrp.mobsite.getway.domain.protocol.user.ModifyPwdReq;
  10 +import com.diligrp.mobsite.getway.rpc.base.BaseOutput;
10 11 import com.diligrp.mobsite.getway.rpc.base.BaseService;
11 12  
12 13  
... ... @@ -31,9 +32,9 @@ public interface PassportRPC extends BaseService {
31 32  
32 33 BuyerInfoOutput buyerLogin(LoginReq req);
33 34  
34   - boolean sendVeriCodeOfSeller(String mobile,Integer msgType);
  35 + BaseOutput<String> sendVeriCodeOfSeller(String mobile, Integer msgType);
35 36  
36   - boolean sendVeriCodeOfBuyer(String mobile,Integer msgType);
  37 + BaseOutput<String> sendVeriCodeOfBuyer(String mobile,Integer msgType);
37 38  
38 39 boolean verifySellerSmsCode(String mobile, String veriCode);
39 40  
... ...
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/base/impl/BaseServiceImpl.java
... ... @@ -54,12 +54,9 @@ import java.util.Map;
54 54 }
55 55  
56 56 int code = request.code();
57   - if (code != 200) {
58   - output.setCode(code);
59   - output.setResult(request.message());
60   - } else {
61   - output.setCode(code);
62   - output.setResult(request.message());
  57 + output.setCode(code);
  58 + output.setResult(request.message());
  59 + if (code == 200) {
63 60 String result = request.body();
64 61 if (type != null) {
65 62 output = JSON.parseObject(result, type);
... ... @@ -72,6 +69,9 @@ import java.util.Map;
72 69  
73 70 //将javabean实体类转为map类型,然后返回一个map类型的值
74 71 public static Map<String, Object> beanToMap(Object obj) {
  72 + if(obj==null){
  73 + return null;
  74 + }
75 75 if(obj instanceof Map){
76 76 return (Map<String, Object>)obj;
77 77 }
... ... @@ -93,4 +93,6 @@ import java.util.Map;
93 93 }
94 94 return params;
95 95 }
  96 +
  97 +
96 98 }
... ...
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/impl/PassportRPCImpl.java
... ... @@ -201,7 +201,7 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC {
201 201  
202 202  
203 203 @Override
204   - public boolean sendVeriCodeOfSeller(String mobile,Integer msgType) {
  204 + public BaseOutput<String> sendVeriCodeOfSeller(String mobile,Integer msgType) {
205 205 BaseOutput<String> output = null;
206 206 TypeReference<BaseOutput<Integer>> type = new TypeReference<BaseOutput<Integer>>() {
207 207 };
... ... @@ -232,22 +232,24 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC {
232 232 throw new ServiceException(output.getCode(),output.getResult());
233 233 }
234 234  
235   - return output.getCode().equals(com.b2c.myapp.common.utils.ResultCode.OK);
  235 + System.out.println("验证码 = " + output.getData());
  236 +
  237 + return output;
236 238 }
237 239  
238 240  
239 241 @Override
240   - public boolean sendVeriCodeOfBuyer(String mobile,Integer msgType) {
  242 + public BaseOutput<String> sendVeriCodeOfBuyer(String mobile,Integer msgType) {
241 243 BaseOutput<String> output = null;
242 244 try {
243 245 if (msgType== SendVeriCodeReq.MSG_TYPE_LOGIN){
244   - output = super.httpGet("/api/login/sendSMS/"+mobile, null, null);
  246 + output = super.httpGet("/api/login/sendSMS/"+mobile, null, new TypeReference<BaseOutput<String>>(){});
245 247 }
246 248 if (msgType== SendVeriCodeReq.MSG_TYPE_REGISTER){
247   - output = super.httpGet("/api/register/sendBuyerRegisterSMS/"+mobile, null, null);
  249 + output = super.httpGet("/api/register/sendBuyerRegisterSMS/"+mobile, null, new TypeReference<BaseOutput<String>>(){});
248 250 }
249 251 if (msgType== SendVeriCodeReq.MSG_TYPE_RETRIEVE_PASSWORD){
250   - output = super.httpGet("/api/forgot/sendBuyerForgotPasswordSMS/"+mobile, null, null);
  252 + output = super.httpGet("/api/forgot/sendBuyerForgotPasswordSMS/"+mobile, null, new TypeReference<BaseOutput<String>>(){});
251 253 }
252 254 } catch (Exception e) {
253 255  
... ... @@ -278,7 +280,8 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC {
278 280 throw new ServiceException(output.getCode(),output.getResult());
279 281 }
280 282  
281   - return output.getCode().equals(com.b2c.myapp.common.utils.ResultCode.OK);
  283 + System.out.println("验证码(买家) = " + output.getData());
  284 + return output;
282 285 }
283 286  
284 287 @Override
... ...
mobsite-getway-service/src/main/java/com/diligrp/mobsite/getway/service/buyer/user/impl/UserServiceImpl.java
... ... @@ -16,6 +16,7 @@ import com.diligrp.mobsite.getway.domain.protocol.user.model.RegisterNoPlatform;
16 16 import com.diligrp.mobsite.getway.manager.common.RegisterNoMapperManager;
17 17 import com.diligrp.mobsite.getway.rpc.PassportRPC;
18 18 import com.diligrp.mobsite.getway.rpc.UserRPC;
  19 +import com.diligrp.mobsite.getway.rpc.base.BaseOutput;
19 20 import com.diligrp.mobsite.getway.service.buyer.user.UserService;
20 21 import com.diligrp.website.util.redis.impl.RedisUtilImpl;
21 22 import com.diligrp.website.util.security.Validator;
... ... @@ -69,6 +70,7 @@ public class UserServiceImpl implements UserService {
69 70  
70 71 //缓存用户信息
71 72 cacheUserInfo(userInfo.getId(),req.getDeviceId());
  73 +
72 74 if (Validator.isEmpty(req.getRegisterNo())){
73 75 logger.error("卖家登录激光推送id为空[userId=]",userInfo.getId());
74 76 }else{
... ... @@ -201,9 +203,10 @@ public class UserServiceImpl implements UserService {
201 203 throw new ServiceException(ErrorMessage.USER_MOBILE_EXIST);
202 204 }
203 205 }
204   - passportRPC.sendVeriCodeOfBuyer(mobile,req.getMsgType());
  206 + BaseOutput<String> out = passportRPC.sendVeriCodeOfBuyer(mobile, req.getMsgType());
205 207 SendVeriCodeResp resp = new SendVeriCodeResp();
206 208 resp.setSendCode(SendVeriCodeResp.SEND_CODE_SUCCESS);
  209 + resp.setPassKey(out.getData());
207 210 return resp;
208 211 }
209 212  
... ...
mobsite-getway-service/src/main/java/com/diligrp/mobsite/getway/service/seller/impl/SellerUserServiceImpl.java
... ... @@ -19,6 +19,7 @@ import com.diligrp.mobsite.getway.manager.common.RegisterNoMapperManager;
19 19 import com.diligrp.mobsite.getway.rpc.PassportRPC;
20 20 import com.diligrp.mobsite.getway.rpc.SellerRPC;
21 21 import com.diligrp.mobsite.getway.rpc.ShopRPC;
  22 +import com.diligrp.mobsite.getway.rpc.base.BaseOutput;
22 23 import com.diligrp.mobsite.getway.service.seller.SellerUserService;
23 24 import com.diligrp.website.util.redis.impl.RedisUtilImpl;
24 25 import com.diligrp.website.util.security.Validator;
... ... @@ -191,9 +192,10 @@ public class SellerUserServiceImpl implements SellerUserService {
191 192 throw new ServiceException(ErrorMessage.USER_MOBILE_EXIST);
192 193 }
193 194 }
194   - passportRPC.sendVeriCodeOfSeller(mobile,req.getMsgType());
  195 + BaseOutput<String> out = passportRPC.sendVeriCodeOfSeller(mobile, req.getMsgType());
195 196 SendVeriCodeResp resp = new SendVeriCodeResp();
196 197 resp.setSendCode(SendVeriCodeResp.SEND_CODE_SUCCESS);
  198 + resp.setPassKey(out.getData());
197 199 return resp;
198 200 }
199 201  
... ...
mobsite-getway-web/pom.xml
... ... @@ -37,7 +37,7 @@
37 37 <artifactId>tomcat7-maven-plugin</artifactId>
38 38 <version>2.2</version>
39 39 <configuration>
40   - <port>8082</port>
  40 + <port>8080</port>
41 41 <url>http://10.28.11.181:8080/manager</url>
42 42 <username>gateway</username>
43 43 <password>123456</password>
... ...
mobsite-getway-web/src/main/java/com/diligrp/mobsite/getway/web/api/base/version/VersionController.java
... ... @@ -26,7 +26,7 @@ import javax.annotation.Resource;
26 26 */
27 27 @Controller
28 28 @RequestMapping("/mobsiteApp/version/")
29   -@Api(value = "mobsiteApp/version", description = "版本接口")
  29 +@Api(value = "mobsiteApp-version", description = "版本接口")
30 30 public class VersionController extends BaseApiController{
31 31  
32 32 @Resource
... ...
mobsite-getway-web/src/main/java/com/diligrp/mobsite/getway/web/api/buyer/user/UserController.java
... ... @@ -147,7 +147,7 @@ public class UserController extends BaseApiController {
147 147 @ApiOperation(value = "发送验证码到手机", httpMethod = "POST" , notes = "发送验证码到手机",response = SendVeriCodeResp.class)
148 148 @RequestMapping(value = "/sendAuthCode",method = RequestMethod.POST)
149 149 @ResponseBody
150   - public void sendAuthCode(@RequestBody SendVeriCodeReq temp){
  150 + public void sendAuthCode(@RequestBody SendVeriCodeReq temp){
151 151 SendVeriCodeReq req= super.getRequest(SendVeriCodeReq.class);
152 152 try {
153 153 BeanValidator.validator(req);
... ...
mobsite-getway-web/src/main/java/com/diligrp/mobsite/getway/web/filter/LoginTimeoutInterceptor.java
1 1 package com.diligrp.mobsite.getway.web.filter;
2 2  
3   -import com.diligrp.mobsite.getway.domain.common.*;
4   -import com.diligrp.mobsite.getway.domain.protocol.*;
  3 +import com.diligrp.mobsite.getway.domain.common.Constant;
  4 +import com.diligrp.mobsite.getway.domain.common.ErrorMessage;
  5 +import com.diligrp.mobsite.getway.domain.common.RedisKey;
  6 +import com.diligrp.mobsite.getway.domain.common.ResultCode;
  7 +import com.diligrp.mobsite.getway.domain.protocol.BaseReq;
  8 +import com.diligrp.mobsite.getway.domain.protocol.Token;
5 9 import com.diligrp.mobsite.getway.web.utils.WebContent;
6 10 import com.diligrp.website.util.redis.RedisUtil;
7 11 import com.diligrp.website.util.security.Validator;
8 12 import org.nutz.json.Json;
9   -import org.slf4j.*;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
10 15 import org.springframework.beans.factory.annotation.Value;
11 16 import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
12 17  
13 18 import javax.annotation.Resource;
14   -import javax.servlet.http.*;
  19 +import javax.servlet.http.HttpServletRequest;
  20 +import javax.servlet.http.HttpServletResponse;
15 21  
16 22 /**
17 23 * <B>Description</B> 验证用户超时检测 <br />
... ... @@ -49,9 +55,9 @@ public class LoginTimeoutInterceptor extends HandlerInterceptorAdapter {
49 55 }
50 56  
51 57 //检测token信息
52   - //if (!checkTokenInfo(body,request)) {
53   - // return false;
54   - //}
  58 + if (!checkTokenInfo(body,request)) {
  59 + return false;
  60 + }
55 61  
56 62 return super.preHandle(request, response, handler);
57 63 }
... ... @@ -83,10 +89,18 @@ public class LoginTimeoutInterceptor extends HandlerInterceptorAdapter {
83 89 return false;
84 90 }
85 91  
86   - //登录redisKey=userId-deviceId
87   -// String loginKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, userId + Constant.COMMON_DASH + baseReq.getDeviceId());
  92 +
  93 + String regularStr = "";
  94 + if (token.getUserRole() == Constant.OPERATOR_ROLE_BUYER){
  95 + regularStr = Constant.USER_ROLE_SIGN_BUYER;
  96 + }else if (token.getUserRole() == Constant.OPERATOR_ROLE_SELLER){
  97 + regularStr = Constant.USER_ROLE_SIGN_SELLER;
  98 + }else {
  99 + log.error("请求参数userRole异常");
  100 + return false;
  101 + }
88 102 //登录排斥验证
89   - String loginKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, token.getUserRole()+String.valueOf(userId));
  103 + String loginKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, regularStr+String.valueOf(userId));
90 104 String loginValue = redisUtil.getString(loginKey);
91 105 if(Validator.isEmpty(loginValue) || !loginValue.equals(String.valueOf(userId))) {
92 106 log.error("用户没有登录请重新登录[userId={}]",userId);
... ... @@ -95,7 +109,7 @@ public class LoginTimeoutInterceptor extends HandlerInterceptorAdapter {
95 109 }
96 110  
97 111 //登录设备排斥验证
98   - String loginDevicedKey = redisUtil.makeKey(RedisKey.USER_DEVICEID, token.getUserRole()+String.valueOf(userId));
  112 + String loginDevicedKey = redisUtil.makeKey(RedisKey.USER_DEVICEID, regularStr+String.valueOf(userId));
99 113 String loginDevicedValue = redisUtil.getString(loginDevicedKey);
100 114 if (!Validator.isNull(baseReq.getDeviceId())) {
101 115 if(Validator.isEmpty(loginDevicedValue) || !loginDevicedValue.equals(baseReq.getDeviceId())) {
... ... @@ -106,7 +120,7 @@ public class LoginTimeoutInterceptor extends HandlerInterceptorAdapter {
106 120 }
107 121  
108 122 //登录延时
109   - logoutDelay(userId,baseReq.getDeviceId(),token.getUserRole());
  123 + logoutDelay(userId,baseReq.getDeviceId(),regularStr);
110 124  
111 125 return true;
112 126 }
... ... @@ -115,10 +129,10 @@ public class LoginTimeoutInterceptor extends HandlerInterceptorAdapter {
115 129 * 延迟登录超时时间
116 130 * @param userId 用户ID
117 131 */
118   - private void logoutDelay(long userId,String deviceId,Integer userRole) {
  132 + private void logoutDelay(long userId,String deviceId,String regularStr) {
119 133 try {
120 134 //cookievalue的rediskey
121   - String loginKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, userRole+String.valueOf(userId));
  135 + String loginKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, regularStr+String.valueOf(userId));
122 136 //缓存cookievalue
123 137 redisUtil.setStringByExpire(loginKey, String.valueOf(userId), loginExpireTime);
124 138  
... ...
mobsite-getway-web/src/main/resources/mybatis/sqlmap/RegisterNoMapperDao.xml
... ... @@ -92,7 +92,7 @@
92 92 and userid = #{param.userid}
93 93 </if>
94 94 <if test="param.userType != null and param.userType != ''">
95   - and userType = #{param.userType}
  95 + and user_type = #{param.userType}
96 96 </if>
97 97 <if test="param.registerNo != null and param.registerNo != ''">
98 98 and register_no = #{param.registerNo}
... ... @@ -133,7 +133,7 @@
133 133 and userid = #{param.userid}
134 134 </if>
135 135 <if test="param.userType != null and param.userType != ''">
136   - and userType = #{param.userType}
  136 + and user_type = #{param.userType}
137 137 </if>
138 138 <if test="param.registerNo != null and param.registerNo != ''">
139 139 and register_no = #{param.registerNo}
... ... @@ -180,7 +180,7 @@
180 180 and userid = #{param.userid}
181 181 </if>
182 182 <if test="param.userType != null and param.userType != ''">
183   - and userType = #{param.userType}
  183 + and user_type = #{param.userType}
184 184 </if>
185 185 <if test="param.registerNo != null and param.registerNo != ''">
186 186 and register_no = #{param.registerNo}
... ... @@ -225,7 +225,7 @@
225 225 </foreach>
226 226 </if>
227 227 <if test="param.userType != null and param.userType != ''">
228   - and userType = #{param.userType}
  228 + and user_type = #{param.userType}
229 229 </if>
230 230 <if test="device_type != null and device_type != ''">
231 231 and device_type = #{device_type}
... ...
mobsite-getway-web/src/main/resources/spring-web.xml
... ... @@ -104,15 +104,15 @@
104 104  
105 105 <!--卖家-->
106 106  
107   - <mvc:exclude-mapping path="/mobsiteApp/user/buyerLogin"/>
108   - <mvc:exclude-mapping path="/mobsiteApp/user/buyerLogins"/>
109   - <mvc:exclude-mapping path="/mobsiteApp/user/sendAuthCode"/>
110   - <mvc:exclude-mapping path="/mobsiteApp/user/checkAuthCode"/>
111   - <mvc:exclude-mapping path="/mobsiteApp/user/buyerRegister"/>
112   - <mvc:exclude-mapping path="/mobsiteApp/user/buyerRegisters"/>
113   - <mvc:exclude-mapping path="/mobsiteApp/user/loginForAuth"/>
114   - <mvc:exclude-mapping path="/mobsiteApp/user/logout"/>
115   - <mvc:exclude-mapping path="/mobsiteApp/user/modifyPwd"/>
  107 + <mvc:exclude-mapping path="/mobsiteApp/seller/user/sellerLogin"/>
  108 + <mvc:exclude-mapping path="/mobsiteApp/seller/user/sellerLogins"/>
  109 + <mvc:exclude-mapping path="/mobsiteApp/seller/user/sendAuthCode"/>
  110 + <mvc:exclude-mapping path="/mobsiteApp/seller/user/checkAuthCode"/>
  111 + <mvc:exclude-mapping path="/mobsiteApp/seller/user/checkMobile"/>
  112 + <mvc:exclude-mapping path="/mobsiteApp/seller/user/sellerRegister"/>
  113 + <mvc:exclude-mapping path="/mobsiteApp/seller/user/sellerRegisters"/>
  114 + <mvc:exclude-mapping path="/mobsiteApp/seller/user/logout"/>
  115 + <mvc:exclude-mapping path="/mobsiteApp/seller/user/modifyPwd"/>
116 116 <bean class="com.diligrp.mobsite.getway.web.filter.LoginTimeoutInterceptor"/>
117 117 </mvc:interceptor>
118 118 <!-- <mvc:interceptor>
... ...