Commit 70f1ae185ef60428a67caf6cb7cb826215deefce

Authored by weiliwhereareyou@163.com
1 parent f594b1f8

初始化工程-接口定义

mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/login/SendVeriCodeReq.java
... ... @@ -36,7 +36,7 @@ public class SendVeriCodeReq extends BaseReq {
36 36 /**
37 37 * 消息类型
38 38 */
39   - @ApiModelProperty(value = "消息类型",required = false)
  39 + @ApiModelProperty(value = "消息类型:1保留,2注册,3找回密码,4修改新电话号码,5验证旧电话号码",required = true)
40 40 private Integer msgType;
41 41  
42 42  
... ...
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/buyer/impl/UserRPCImpl.java
1 1 package com.diligrp.mobsite.getway.rpc.buyer.impl;
2 2  
  3 +import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput;
  4 +import com.b2c.myapp.common.utils.BaseOutput;
  5 +import com.b2c.myapp.sdk.MyAppClient;
  6 +import com.diligrp.mobsite.getway.domain.common.ResultCode;
  7 +import com.diligrp.mobsite.getway.domain.except.ServiceException;
3 8 import com.diligrp.mobsite.getway.domain.protocol.AddCartProduct;
4 9 import com.diligrp.mobsite.getway.domain.protocol.ConsigneeInfo;
5 10 import com.diligrp.mobsite.getway.domain.protocol.cart.ModifyAmountReq;
  11 +import com.diligrp.mobsite.getway.rpc.buyer.GoodsRPC;
6 12 import com.diligrp.mobsite.getway.rpc.buyer.UserRPC;
  13 +import com.diligrp.website.util.redis.RedisUtil;
  14 +import com.diligrp.website.util.security.Validator;
  15 +import com.diligrp.website.web.interfaces.WebsiteClient;
  16 +import org.slf4j.Logger;
  17 +import org.slf4j.LoggerFactory;
7 18 import org.springframework.stereotype.Service;
8 19  
  20 +import javax.annotation.Resource;
9 21 import java.util.List;
10 22  
11 23  
... ... @@ -22,6 +34,18 @@ import java.util.List;
22 34 public class UserRPCImpl implements UserRPC {
23 35  
24 36  
  37 + @Resource
  38 + private RedisUtil redisUtil;
  39 + @Resource
  40 + private MyAppClient userClient;
  41 + @Resource
  42 + private WebsiteClient websiteClient;
  43 + @Resource
  44 + private GoodsRPC goodsRPC;
  45 +
  46 +
  47 + private static final Logger logger = LoggerFactory.getLogger(UserRPCImpl.class);
  48 +
25 49 @Override
26 50 public boolean checkFavorites(Long id, Long userId, Integer type) {
27 51 return false;
... ... @@ -54,7 +78,26 @@ public class UserRPCImpl implements UserRPC {
54 78  
55 79 @Override
56 80 public boolean checkMobile(String mobile) {
57   - return false;
  81 + BaseOutput<BuyerInfoOutput> output = null;
  82 + boolean flag = false;
  83 + try {
  84 + output = userClient.getBuyerInfoService().getBuyerInfoByMobilePhone(mobile);
  85 + } catch (Exception e) {
  86 + logger.error("检测电话号码接口挂掉:msg={}",e.getMessage());
  87 + throw new ServiceException();
  88 + }
  89 +
  90 + if (output==null||!output.getCode().equals(ResultCode.SUCCESS)){
  91 + logger.error("手机号查询买家接口失败:[userId={},code={},result={}]",new Object[]{mobile,output.getCode(),output.getResult()});
  92 + throw new ServiceException();
  93 + }
  94 + flag = !Validator.isNull(output.getData());
  95 + if(flag){
  96 + logger.info("success:电话号码没有被注册:mobile={}",mobile);
  97 + }else {
  98 + logger.info("error:电话号码已经被注册:mobile={}",mobile);
  99 + }
  100 + return flag;
58 101 }
59 102  
60 103 @Override
... ...
mobsite-getway-service/src/main/java/com/diligrp/mobsite/getway/service/buyer/user/impl/UserServiceImpl.java
1 1 package com.diligrp.mobsite.getway.service.buyer.user.impl;
2 2  
  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.except.ServiceException;
3 8 import com.diligrp.mobsite.getway.domain.protocol.login.*;
4 9 import com.diligrp.mobsite.getway.domain.protocol.register.*;
5 10 import com.diligrp.mobsite.getway.domain.protocol.user.*;
  11 +import com.diligrp.mobsite.getway.manager.common.RegisterNoMapperManager;
  12 +import com.diligrp.mobsite.getway.rpc.buyer.*;
  13 +import com.diligrp.mobsite.getway.rpc.utils.UserRedisUtil;
6 14 import com.diligrp.mobsite.getway.service.buyer.user.UserService;
  15 +import com.diligrp.mobsite.getway.service.common.utils.PassportUtils;
  16 +import com.diligrp.website.util.redis.impl.RedisUtilImpl;
  17 +import com.diligrp.website.util.security.Validator;
  18 +import com.diligrp.website.web.interfaces.domain.output.DataDictionaryResp;
  19 +import org.slf4j.Logger;
  20 +import org.slf4j.LoggerFactory;
  21 +import org.springframework.beans.factory.annotation.Autowired;
7 22 import org.springframework.stereotype.Service;
8 23  
  24 +import javax.annotation.Resource;
  25 +
9 26 /**
10 27 * <B>Description</B> 用户 服务层 <br />
11 28 * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br />
... ... @@ -18,6 +35,30 @@ import org.springframework.stereotype.Service;
18 35 @Service("userService")
19 36 public class UserServiceImpl implements UserService {
20 37  
  38 + @Resource
  39 + private UserRPC userRPC;
  40 + @Resource
  41 + private GoodsRPC goodsRPC;
  42 + @Autowired
  43 + private RedisUtilImpl redisUtil;
  44 + @Autowired
  45 + private UserRedisUtil userRedisUtil;
  46 +
  47 + @Resource
  48 + private RegisterNoMapperManager registerNoMapperManager;
  49 + @Resource
  50 + private PassportRPC passportRPC;
  51 + @Resource
  52 + private ConfigRPC configRPC;
  53 +
  54 + @Resource
  55 + private ShopRPC shopRPC;
  56 + @Autowired
  57 + private MessageRPC messageRPC;
  58 +
  59 +
  60 + private static Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
  61 +
21 62 @Override
22 63 public LoginResp login(LoginReq req) {
23 64 return null;
... ... @@ -35,7 +76,68 @@ public class UserServiceImpl implements UserService {
35 76  
36 77 @Override
37 78 public SendVeriCodeResp sendVeriCode(SendVeriCodeReq req) {
38   - return null;
  79 + SendVeriCodeResp resp = new SendVeriCodeResp();
  80 +
  81 + String mobile = req.getMobile();
  82 + boolean existFlag = !userRPC.checkMobile(mobile);
  83 +
  84 + Integer msgType = req.getMsgType();
  85 + String code = null;
  86 + String message = null;
  87 +
  88 + String redisKey = redisUtil.makeKey(RedisKey.USER_AUTH_CODE + String.valueOf(msgType), mobile);
  89 + String veriCode = redisUtil.getString(redisKey);
  90 +
  91 + if (Validator.isEmpty(veriCode)) {
  92 + //生成验证码
  93 + veriCode = PassportUtils.generateMobileRandomNumber();
  94 + redisUtil.setStringByExpire(redisKey, String.valueOf(veriCode), RedisKey.USER_SEND_VERICODE_EXPIRE_TIME);
  95 + }
  96 +
  97 + if (!Validator.isNull(msgType) && msgType != SendVeriCodeReq.MSG_TYPE_DEFAULT) {
  98 + if (msgType==SendVeriCodeReq.MSG_TYPE_REGISTER) {
  99 + //注册,电话号码已经存在
  100 + if(existFlag){
  101 + throw new ServiceException(ResultCode.BUSINESS_FAILED, ErrorMessage.USER_MOBILE_EXIST);
  102 + }
  103 + String passkey = configRPC.getSystemConfig(Constant.USER_REGISTER_PASS_KEY);
  104 + resp.setPassKey(passkey);
  105 +
  106 + messageRPC.sendSMSMsg(mobile, veriCode, Constant.SMS_CONTENT_ACCOUNT_REGISTRATION);
  107 + resp.setSendCode(SendVeriCodeResp.SEND_CODE_SUCCESS);
  108 + return resp;
  109 + }else if(msgType==SendVeriCodeReq.MSG_TYPE_RETRIEVE_PASSWORD) {
  110 + //找回密码,电话号码没有存在
  111 + if (!existFlag) {
  112 + throw new ServiceException(ResultCode.BUSINESS_FAILED,ErrorMessage.USER_MOBILE_NOT_EXIST);
  113 + }
  114 + messageRPC.sendSMSMsg(mobile, veriCode,Constant.SMS_CONTENT_RETRIEVE_PASSWORD);
  115 + resp.setSendCode(SendVeriCodeResp.SEND_CODE_SUCCESS);
  116 + return resp;
  117 + }else if(msgType==SendVeriCodeReq.MSG_TYPE_MODIFY_NEW_MOBILE) {
  118 + //修改手机号,电话号码已经存在
  119 + if (existFlag) {
  120 + throw new ServiceException(ResultCode.BUSINESS_FAILED,ErrorMessage.USER_MOBILE_EXIST);
  121 + }
  122 + code = Constant.SMS_CONTENT_MODIFY_OLD_PHONE;
  123 + }else if (msgType==SendVeriCodeReq.MSG_TYPE_CHECK_OLD_MOBILE) {
  124 + //验证旧的手机号,手机不存在
  125 + if (!existFlag) {
  126 + throw new ServiceException(ResultCode.BUSINESS_FAILED,ErrorMessage.USER_MOBILE_NOT_EXIST);
  127 + }
  128 + code = Constant.SMS_CONTENT_MODIFY_OLD_PHONE;
  129 + }
  130 + DataDictionaryResp dataDic = configRPC.getMessageTemplate(Constant.DIC_SMS_CONTENT);
  131 + message = dataDic.getValueByCode(code).getRemark().replace("{code}", veriCode);
  132 + }else {
  133 + message = Constant.SMS_CONTENT_DEFAULT.replace("{code}", veriCode);
  134 + }
  135 +
  136 + messageRPC.sendSMS(mobile, message);
  137 +
  138 + resp.setSendCode(SendVeriCodeResp.SEND_CODE_SUCCESS);
  139 +
  140 + return resp;
39 141 }
40 142  
41 143 @Override
... ...
mobsite-getway-web/src/main/java/com/diligrp/mobsite/getway/web/api/buyer/user/UserController.java
... ... @@ -169,71 +169,23 @@ public class UserController extends BaseApiController {
169 169 * @createTime 2014年8月24日 下午10:55:03
170 170 * @author weili
171 171 */
172   - @ApiOperation(value = "验证手机收到的验证码", httpMethod = "POST" , notes = "验证手机收到的验证码",response = CheckVeriCodeResp.class)
173   - @RequestMapping(value = "/checkAuthCode",method = RequestMethod.POST)
174   - @ResponseBody
175   - public void checkAuthCode(@RequestBody CheckVeriCodeReq temp){
176   - CheckVeriCodeReq req= super.getRequest(CheckVeriCodeReq.class);
177   - try {
178   - BeanValidator.validator(req);
179   - CheckVeriCodeResp resp = userService.checkVeriCode(req);
180   - super.sendSuccessResp(resp);
181   - } catch (ServiceException e){
182   - LOGGER.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s",
183   - e.getCode(), e.getMessage(), req.getUserId()), e);
184   - sendError(e.getCode(), e.getMessage());
185   - } catch (Exception e) {
186   - LOGGER.error("验证手机收到的验证码:", e);
187   - super.sendError(e.getMessage());
188   - }
189   - }
190   - //
191   - ///**
192   - // * 修改用户信息
193   - // * @createTime 2014年8月24日 下午10:55:03
194   - // * @author weili
195   - // */
196   - //@RequestMapping("/updateUserInfo")
197   - //@ResponseBody
198   - //@ApiOperation(value = "修改用户信息", httpMethod = "POST")
199   - //public void updateUserInfo(){
200   - // UpdateUserInfoReq req = super.getRequest(UpdateUserInfoReq.class);
201   - // try {
202   - // UpdateUserInfoResp resp = userService.updateUserInfo(req);
203   - // super.sendSuccessResp(resp);
204   - // } catch (ServiceException e){
205   - // LOGGER.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s",
206   - // e.getCode(), e.getMessage(), req.getUserId()), e);
207   - // sendError(e.getCode(), e.getMessage());
208   - // } catch (Exception e) {
209   - // LOGGER.error("修改密码:", e);
210   - // super.sendError(e.getMessage());
211   - // }
212   - //
213   - //}
214   - //
215   - //
216   - ///**
217   - // * 完善用户信息
218   - // * @createTime 2014年8月24日 下午10:55:03
219   - // * @author weili
220   - // */
221   - //@RequestMapping("/completeUserInfo")
  172 + //@ApiOperation(value = "验证手机收到的验证码", httpMethod = "POST" , notes = "验证手机收到的验证码",response = CheckVeriCodeResp.class)
  173 + //@RequestMapping(value = "/checkAuthCode",method = RequestMethod.POST)
222 174 //@ResponseBody
223   - //public void completeUserInfo(){
224   - // CompleteUserInfoReq req = super.getRequest(CompleteUserInfoReq.class);
  175 + //public void checkAuthCode(@RequestBody CheckVeriCodeReq temp){
  176 + // CheckVeriCodeReq req= super.getRequest(CheckVeriCodeReq.class);
225 177 // try {
226   - // UpdateUserInfoResp resp = userService.completeUserInfo(req);
  178 + // BeanValidator.validator(req);
  179 + // CheckVeriCodeResp resp = userService.checkVeriCode(req);
227 180 // super.sendSuccessResp(resp);
228 181 // } catch (ServiceException e){
229 182 // LOGGER.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s",
230 183 // e.getCode(), e.getMessage(), req.getUserId()), e);
231 184 // sendError(e.getCode(), e.getMessage());
232 185 // } catch (Exception e) {
233   - // LOGGER.error("修改密码:", e);
  186 + // LOGGER.error("验证手机收到的验证码:", e);
234 187 // super.sendError(e.getMessage());
235 188 // }
236   - //
237 189 //}
238 190  
239 191  
... ...
mobsite-getway-web/src/main/resources/hbase-site.xml deleted 100644 → 0
1   -<?xml version="1.0"?>
2   -<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
3   -<!-- /** * * Licensed to the Apache Software Foundation (ASF) under one *
4   - or more contributor license agreements. See the NOTICE file * distributed
5   - with this work for additional information * regarding copyright ownership.
6   - The ASF licenses this file * to you under the Apache License, Version 2.0
7   - (the * "License"); you may not use this file except in compliance * with
8   - the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0
9   - * * Unless required by applicable law or agreed to in writing, software *
10   - distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT
11   - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the
12   - License for the specific language governing permissions and * limitations
13   - under the License. */ -->
14   -<configuration>
15   -
16   - <property>
17   - <name>hbase.master</name>
18   - <value>node1</value>
19   - </property>
20   -
21   - <property>
22   - <name>hbase.master.port</name>
23   - <value>60000</value>
24   - </property>
25   -
26   - <property>
27   - <name>hbase.zookeeper.property.clientPort</name>
28   - <value>2181</value>
29   - </property>
30   -
31   - <property>
32   - <name>hbase.rootdir</name>
33   - <value>hdfs://mycluster/hbase</value>
34   - </property>
35   -
36   - <property>
37   - <name>hbase.zookeeper.quorum</name>
38   - <value>node2,node3,node4</value>
39   - </property>
40   -</configuration>
mobsite-getway-web/src/main/resources/monitor.xml deleted 100644 → 0
1   -<?xml version="1.0" encoding="UTF-8" ?>
2   -<!DOCTYPE log4j:configuration PUBLIC
3   - "-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
4   -<log4j:configuration>
5   -
6   - <appender name="MONITOR_LOG" class="org.apache.log4j.DailyRollingFileAppender">
7   - <param name="Encoding" value="UTF-8"/>
8   - <param name="Append" value="true" />
9   - <param name="File" value="${catalina.base}/logs/monitor/monitor.log"/>
10   - <!-- <param name="File" value="/diliapp/servers/apache-tomcat-6.0.43/monitor/monitor.log"/>-->
11   - <!--<param name="File" value="/home/tomcat/monitor/mobapi-gateway/monitor.log"/>-->
12   -
13   - <param name="DatePattern" value="'.'yyyy-MM-dd" />
14   - <layout class="org.apache.log4j.PatternLayout">
15   - <param name="ConversionPattern" value="[%p] [%d] [%r] [%c] - %m %n"/>
16   - </layout>
17   - </appender>
18   -
19   - <category name="MONITOR_LOG" additivity="false">
20   - <priority value="INFO"/>
21   - <appender-ref ref="MONITOR_LOG"/>
22   - </category>
23   -
24   -</log4j:configuration>
25 0 \ No newline at end of file
mobsite-getway-web/src/main/resources/spring-rpc.xml
... ... @@ -49,13 +49,13 @@
49 49  
50 50  
51 51  
52   - <bean id="imageUploadService" class="com.dili.imageserver.sdk.service.ImageUploadService">
53   - <property name="IMAGE_UPLOAD_URL_PREFIX" value="${project.imageserver.prefix}"/>
54   - <property name="AUTH_TOKEN" value="LeaDOqaef8mo4G6bSq8o2bh7lEPlViRU"/>
55   - <property name="ENCODING" value="UTF-8"></property>
56   - <property name="DEFAULT_MAX_PER_ROUTE" value="20"></property>
57   - <property name="MAX_TOTAL" value="100"></property>
58   - </bean>
  52 + <!--<bean id="imageUploadService" class="com.dili.imageserver.sdk.service.ImageUploadService">-->
  53 + <!--<property name="IMAGE_UPLOAD_URL_PREFIX" value="${project.imageserver.prefix}"/>-->
  54 + <!--<property name="AUTH_TOKEN" value="LeaDOqaef8mo4G6bSq8o2bh7lEPlViRU"/>-->
  55 + <!--<property name="ENCODING" value="UTF-8"></property>-->
  56 + <!--<property name="DEFAULT_MAX_PER_ROUTE" value="20"></property>-->
  57 + <!--<property name="MAX_TOTAL" value="100"></property>-->
  58 + <!--</bean>-->
59 59 <bean id="dataStoredConfig" class="com.dili.dataStored.sdk.common.DataStoredConfig">
60 60 <property name="trackercount" value="${project.fastdfs.trackercount}"/>
61 61 <property name="connectTimeout" value="${project.fastdfs.connectTimeout}"/>
... ...