Commit 19148fe13283336f8d094b15449260c72ab440cc
1 parent
70f1ae18
初始化工程-接口定义
Showing
13 changed files
with
811 additions
and
104 deletions
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/login/CheckVeriCodeReq.java
... | ... | @@ -19,12 +19,12 @@ public class CheckVeriCodeReq extends BaseReq { |
19 | 19 | /** |
20 | 20 | * 手机验证码 |
21 | 21 | */ |
22 | - @ApiModelProperty(value = "验证码") | |
22 | + @ApiModelProperty(value = "验证码",required = true) | |
23 | 23 | private String veriCode; |
24 | 24 | /** |
25 | 25 | * 手机号码 |
26 | 26 | */ |
27 | - @ApiModelProperty(value = "手机号码") | |
27 | + @ApiModelProperty(value = "手机号码",required = true) | |
28 | 28 | private String mobile; |
29 | 29 | /** |
30 | 30 | * 消息类型 | ... | ... |
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/login/CheckVeriCodeResp.java
1 | 1 | package com.diligrp.mobsite.getway.domain.protocol.login; |
2 | 2 | |
3 | 3 | import com.diligrp.mobsite.getway.domain.protocol.BaseResp; |
4 | - | |
4 | +import io.swagger.annotations.ApiModelProperty; | |
5 | 5 | |
6 | 6 | |
7 | 7 | /** |
... | ... | @@ -22,7 +22,7 @@ public class CheckVeriCodeResp extends BaseResp { |
22 | 22 | /** |
23 | 23 | * 验证结果:1-验证码正确,2验证码错误 |
24 | 24 | */ |
25 | - @Deprecated | |
25 | + @ApiModelProperty(value = "验证结果:1-验证码正确,2验证码错误") | |
26 | 26 | private Integer checkFlag = CHECK_FLAG_RIGHT; |
27 | 27 | |
28 | 28 | ... | ... |
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/login/SendVeriCodeResp.java
... | ... | @@ -28,11 +28,12 @@ public class SendVeriCodeResp extends BaseResp { |
28 | 28 | /** |
29 | 29 | * 发送结果 |
30 | 30 | */ |
31 | - @ApiModelProperty(value = "发送结果") | |
31 | + @ApiModelProperty(value = "发送结果:1成功") | |
32 | 32 | private Integer sendCode = SEND_CODE_ERROR; |
33 | 33 | /** |
34 | 34 | * 万能验证码 |
35 | 35 | */ |
36 | + @ApiModelProperty(value = "万能验证码") | |
36 | 37 | private String passKey; |
37 | 38 | |
38 | 39 | /** | ... | ... |
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/user/ModifyPwdReq.java
... | ... | @@ -19,23 +19,25 @@ public class ModifyPwdReq extends BaseReq { |
19 | 19 | /** |
20 | 20 | * 验证码 |
21 | 21 | */ |
22 | + @ApiModelProperty(value = "验证码",required = true) | |
22 | 23 | private String authCode; |
23 | 24 | |
24 | 25 | /** |
25 | 26 | * 新的密码 |
26 | 27 | */ |
27 | - @ApiModelProperty(value = "新密码") | |
28 | + @ApiModelProperty(value = "新密码",required = true) | |
28 | 29 | private String password; |
29 | 30 | |
30 | 31 | /** |
31 | 32 | * 重复新密码 |
32 | 33 | */ |
33 | - @ApiModelProperty(value = "重复新密码") | |
34 | + @ApiModelProperty(value = "重复新密码",required = true) | |
34 | 35 | private String repPassword; |
35 | 36 | |
36 | 37 | /** |
37 | - * 用户账号 | |
38 | + * 手机号 | |
38 | 39 | */ |
40 | + @ApiModelProperty(value = "账号(手机号)",required = true) | |
39 | 41 | private String accountName; |
40 | 42 | |
41 | 43 | /** | ... | ... |
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/buyer/UserRPC.java
1 | 1 | package com.diligrp.mobsite.getway.rpc.buyer; |
2 | 2 | |
3 | +import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; | |
3 | 4 | import com.diligrp.mobsite.getway.domain.protocol.AddCartProduct; |
4 | 5 | import com.diligrp.mobsite.getway.domain.protocol.ConsigneeInfo; |
5 | 6 | import com.diligrp.mobsite.getway.domain.protocol.cart.ModifyAmountReq; |
... | ... | @@ -138,4 +139,5 @@ public interface UserRPC { |
138 | 139 | boolean checkPassword(Long userId, String password); |
139 | 140 | |
140 | 141 | |
142 | + BuyerInfoOutput getUserByMobile(String accountName); | |
141 | 143 | } | ... | ... |
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/buyer/impl/UserRPCImpl.java
... | ... | @@ -3,6 +3,7 @@ package com.diligrp.mobsite.getway.rpc.buyer.impl; |
3 | 3 | import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; |
4 | 4 | import com.b2c.myapp.common.utils.BaseOutput; |
5 | 5 | import com.b2c.myapp.sdk.MyAppClient; |
6 | +import com.diligrp.mobsite.getway.domain.common.ErrorMessage; | |
6 | 7 | import com.diligrp.mobsite.getway.domain.common.ResultCode; |
7 | 8 | import com.diligrp.mobsite.getway.domain.except.ServiceException; |
8 | 9 | import com.diligrp.mobsite.getway.domain.protocol.AddCartProduct; |
... | ... | @@ -154,4 +155,27 @@ public class UserRPCImpl implements UserRPC { |
154 | 155 | public boolean checkPassword(Long userId, String password) { |
155 | 156 | return false; |
156 | 157 | } |
158 | + | |
159 | + @Override | |
160 | + public BuyerInfoOutput getUserByMobile(String accountName) { | |
161 | + BaseOutput<BuyerInfoOutput> output = null; | |
162 | + boolean flag = false; | |
163 | + try { | |
164 | + output = userClient.getBuyerInfoService().getBuyerInfoByMobilePhone(accountName); | |
165 | + } catch (Exception e) { | |
166 | + logger.error("检测电话号码接口挂掉:msg={}",e.getMessage()); | |
167 | + throw new ServiceException(); | |
168 | + } | |
169 | + | |
170 | + if (output==null||!output.getCode().equals(ResultCode.SUCCESS)){ | |
171 | + logger.error("手机号查询买家接口失败:[userId={},code={},result={}]",new Object[]{accountName,output.getCode(),output.getResult()}); | |
172 | + throw new ServiceException(); | |
173 | + } | |
174 | + | |
175 | + if(Validator.isNull(output.getData())){ | |
176 | + logger.info("查询用户为空:[mobile={}]",new Object[]{accountName}); | |
177 | + throw new ServiceException(ResultCode.BUSINESS_FAILED, ErrorMessage.USER_NOT_EXIST); | |
178 | + } | |
179 | + return output.getData(); | |
180 | + } | |
157 | 181 | } | ... | ... |
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/seller/SellerRPC.java
0 → 100644
1 | +package com.diligrp.mobsite.getway.rpc.seller; | |
2 | + | |
3 | +import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; | |
4 | +import com.diligrp.mobsite.getway.domain.protocol.ConsigneeInfo; | |
5 | +import com.diligrp.mobsite.getway.domain.protocol.cart.ModifyAmountReq; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | + | |
10 | +/** | |
11 | + * <B>Description</B> userrpc <br /> | |
12 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> | |
13 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | |
14 | + * <B>Company</B> 地利集团 | |
15 | + * | |
16 | + * @author wujianjun | |
17 | + * @createTime Aug 19, 2014 2:33:16 PM | |
18 | + */ | |
19 | +public interface SellerRPC { | |
20 | + | |
21 | + | |
22 | + | |
23 | + /** | |
24 | + * 验证电话号码是否存在 | |
25 | + * | |
26 | + * 没有被使用:true | |
27 | + * 已经被使用:false | |
28 | + * | |
29 | + * @param mobile | |
30 | + * @return | |
31 | + * @createTime 2014年8月27日 下午2:31:07 | |
32 | + * @author zhangshirui | |
33 | + */ | |
34 | + boolean checkMobile(String mobile); | |
35 | + | |
36 | + | |
37 | + /** | |
38 | + * 修改进货单数量 | |
39 | + * @param req | |
40 | + * @return | |
41 | + * @createTime 2015年3月9日 下午2:49:27 | |
42 | + * @author zhangshirui | |
43 | + */ | |
44 | + boolean modifyAmount(ModifyAmountReq req); | |
45 | + | |
46 | + /** | |
47 | + * 修改密码 | |
48 | + * @param accountName | |
49 | + * @param newPassword | |
50 | + * @return | |
51 | + * @createTime 2014年8月28日 下午3:01:49 | |
52 | + * @author zhangshirui | |
53 | + */ | |
54 | + boolean modifyPwd(String accountName, String newPassword); | |
55 | + | |
56 | + Long addConsignee(ConsigneeInfo consigneeInfo, Long userId); | |
57 | + | |
58 | + boolean updateConsignee(ConsigneeInfo consigneeInfo, Long userId); | |
59 | + | |
60 | + ConsigneeInfo getConsignee(Long id); | |
61 | + | |
62 | + boolean delConsignee(Long id); | |
63 | + | |
64 | + List<ConsigneeInfo> getConsigneeByUserId(Long userId); | |
65 | + | |
66 | + ConsigneeInfo getDefaultConsignee(Long userId); | |
67 | + | |
68 | + boolean setDefaultConsignee(Long id, Long userId); | |
69 | + | |
70 | + | |
71 | + /** | |
72 | + * 密码加密 | |
73 | + * @param pwd | |
74 | + * @return | |
75 | + * @createTime 2014年9月19日 上午10:04:35 | |
76 | + * @author zhangshirui | |
77 | + */ | |
78 | + String getEncryptPwd(String pwd); | |
79 | + | |
80 | + | |
81 | + | |
82 | + /** | |
83 | + * 验证用户密码 | |
84 | + * @param userId | |
85 | + * @param password | |
86 | + * @return | |
87 | + * @createTime 2015年6月24日 下午1:45:53 | |
88 | + * @author zhangshirui | |
89 | + */ | |
90 | + boolean checkPassword(Long userId, String password); | |
91 | + | |
92 | + | |
93 | + BuyerInfoOutput getUserByMobile(String accountName); | |
94 | +} | ... | ... |
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/seller/impl/SellerRPCImpl.java
0 → 100644
1 | +package com.diligrp.mobsite.getway.rpc.seller.impl; | |
2 | + | |
3 | +import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; | |
4 | +import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; | |
5 | +import com.b2c.myapp.common.utils.BaseOutput; | |
6 | +import com.b2c.myapp.sdk.MyAppClient; | |
7 | +import com.diligrp.mobsite.getway.domain.common.ErrorMessage; | |
8 | +import com.diligrp.mobsite.getway.domain.common.ResultCode; | |
9 | +import com.diligrp.mobsite.getway.domain.except.ServiceException; | |
10 | +import com.diligrp.mobsite.getway.domain.protocol.ConsigneeInfo; | |
11 | +import com.diligrp.mobsite.getway.domain.protocol.cart.ModifyAmountReq; | |
12 | +import com.diligrp.mobsite.getway.rpc.buyer.GoodsRPC; | |
13 | +import com.diligrp.mobsite.getway.rpc.seller.SellerRPC; | |
14 | +import com.diligrp.website.util.redis.RedisUtil; | |
15 | +import com.diligrp.website.util.security.Validator; | |
16 | +import com.diligrp.website.web.interfaces.WebsiteClient; | |
17 | +import org.slf4j.Logger; | |
18 | +import org.slf4j.LoggerFactory; | |
19 | +import org.springframework.stereotype.Service; | |
20 | + | |
21 | +import javax.annotation.Resource; | |
22 | +import java.util.List; | |
23 | + | |
24 | + | |
25 | +/** | |
26 | + * <B>Description</B> 用户rpc <br /> | |
27 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> | |
28 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | |
29 | + * <B>Company</B> 地利集团 | |
30 | + * | |
31 | + * @author zhangshirui | |
32 | + * @createTime Aug 19, 2014 2:34:13 PM | |
33 | + */ | |
34 | +@Service | |
35 | +public class SellerRPCImpl implements SellerRPC { | |
36 | + | |
37 | + | |
38 | + @Resource | |
39 | + private RedisUtil redisUtil; | |
40 | + @Resource | |
41 | + private MyAppClient userClient; | |
42 | + @Resource | |
43 | + private WebsiteClient websiteClient; | |
44 | + @Resource | |
45 | + private GoodsRPC goodsRPC; | |
46 | + | |
47 | + | |
48 | + private static final Logger logger = LoggerFactory.getLogger(SellerRPCImpl.class); | |
49 | + | |
50 | + | |
51 | + | |
52 | + @Override | |
53 | + public boolean checkMobile(String mobile) { | |
54 | + BaseOutput<SellerInfoOutput> output = null; | |
55 | + boolean flag = false; | |
56 | + try { | |
57 | + output = userClient.getSellerInfoService().getSellerInfoByMobilePhone(mobile); | |
58 | + } catch (Exception e) { | |
59 | + logger.error("检测电话号码接口挂掉:msg={}",e.getMessage()); | |
60 | + throw new ServiceException(); | |
61 | + } | |
62 | + | |
63 | + if (output==null||!output.getCode().equals(ResultCode.SUCCESS)){ | |
64 | + logger.error("手机号查询卖家接口失败:[userId={},code={},result={}]",new Object[]{mobile,output.getCode(),output.getResult()}); | |
65 | + throw new ServiceException(); | |
66 | + } | |
67 | + flag = !Validator.isNull(output.getData()); | |
68 | + if(flag){ | |
69 | + logger.info("success:电话号码没有被注册:mobile={}",mobile); | |
70 | + }else { | |
71 | + logger.info("error:电话号码已经被注册:mobile={}",mobile); | |
72 | + } | |
73 | + return flag; | |
74 | + } | |
75 | + | |
76 | + @Override | |
77 | + public boolean modifyAmount(ModifyAmountReq req) { | |
78 | + return false; | |
79 | + } | |
80 | + | |
81 | + @Override | |
82 | + public boolean modifyPwd(String accountName, String newPassword) { | |
83 | + return false; | |
84 | + } | |
85 | + | |
86 | + @Override | |
87 | + public Long addConsignee(ConsigneeInfo consigneeInfo, Long userId) { | |
88 | + return null; | |
89 | + } | |
90 | + | |
91 | + @Override | |
92 | + public boolean updateConsignee(ConsigneeInfo consigneeInfo, Long userId) { | |
93 | + return false; | |
94 | + } | |
95 | + | |
96 | + @Override | |
97 | + public ConsigneeInfo getConsignee(Long id) { | |
98 | + return null; | |
99 | + } | |
100 | + | |
101 | + @Override | |
102 | + public boolean delConsignee(Long id) { | |
103 | + return false; | |
104 | + } | |
105 | + | |
106 | + @Override | |
107 | + public List<ConsigneeInfo> getConsigneeByUserId(Long userId) { | |
108 | + return null; | |
109 | + } | |
110 | + | |
111 | + @Override | |
112 | + public ConsigneeInfo getDefaultConsignee(Long userId) { | |
113 | + return null; | |
114 | + } | |
115 | + | |
116 | + @Override | |
117 | + public boolean setDefaultConsignee(Long id, Long userId) { | |
118 | + return false; | |
119 | + } | |
120 | + | |
121 | + @Override | |
122 | + public String getEncryptPwd(String pwd) { | |
123 | + return null; | |
124 | + } | |
125 | + | |
126 | + @Override | |
127 | + public boolean checkPassword(Long userId, String password) { | |
128 | + return false; | |
129 | + } | |
130 | + | |
131 | + @Override | |
132 | + public BuyerInfoOutput getUserByMobile(String accountName) { | |
133 | + BaseOutput<BuyerInfoOutput> output = null; | |
134 | + boolean flag = false; | |
135 | + try { | |
136 | + output = userClient.getBuyerInfoService().getBuyerInfoByMobilePhone(accountName); | |
137 | + } catch (Exception e) { | |
138 | + logger.error("检测电话号码接口挂掉:msg={}",e.getMessage()); | |
139 | + throw new ServiceException(); | |
140 | + } | |
141 | + | |
142 | + if (output==null||!output.getCode().equals(ResultCode.SUCCESS)){ | |
143 | + logger.error("手机号查询买家接口失败:[userId={},code={},result={}]",new Object[]{accountName,output.getCode(),output.getResult()}); | |
144 | + throw new ServiceException(); | |
145 | + } | |
146 | + | |
147 | + if(Validator.isNull(output.getData())){ | |
148 | + logger.info("查询用户为空:[mobile={}]",new Object[]{accountName}); | |
149 | + throw new ServiceException(ResultCode.BUSINESS_FAILED, ErrorMessage.USER_NOT_EXIST); | |
150 | + } | |
151 | + return output.getData(); | |
152 | + } | |
153 | +} | ... | ... |
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.alibaba.fastjson.JSONObject; | |
4 | +import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; | |
3 | 5 | import com.diligrp.mobsite.getway.domain.common.Constant; |
4 | 6 | import com.diligrp.mobsite.getway.domain.common.ErrorMessage; |
5 | 7 | import com.diligrp.mobsite.getway.domain.common.RedisKey; |
... | ... | @@ -22,6 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired; |
22 | 24 | import org.springframework.stereotype.Service; |
23 | 25 | |
24 | 26 | import javax.annotation.Resource; |
27 | +import java.util.HashMap; | |
28 | +import java.util.Map; | |
25 | 29 | |
26 | 30 | /** |
27 | 31 | * <B>Description</B> 用户 服务层 <br /> |
... | ... | @@ -71,7 +75,11 @@ public class UserServiceImpl implements UserService { |
71 | 75 | |
72 | 76 | @Override |
73 | 77 | public CheckVeriCodeResp checkVeriCode(CheckVeriCodeReq req) { |
74 | - return null; | |
78 | + CheckVeriCodeResp resp = new CheckVeriCodeResp(); | |
79 | + | |
80 | + checkVeriCode(req.getVeriCode(), req.getMobile(),req.getMsgType()); | |
81 | + | |
82 | + return resp; | |
75 | 83 | } |
76 | 84 | |
77 | 85 | @Override |
... | ... | @@ -157,7 +165,71 @@ public class UserServiceImpl implements UserService { |
157 | 165 | |
158 | 166 | @Override |
159 | 167 | public UserRegisterResp userRegister(UserRegisterReq req) { |
160 | - return null; | |
168 | + UserRegisterResp resp = new UserRegisterResp(); | |
169 | + | |
170 | + //手机号码和账号验证、验证码 | |
171 | + if (!checkRegisterInfo(resp, req)) { | |
172 | + return resp; | |
173 | + } | |
174 | + | |
175 | + resp = passportRPC.register(req); | |
176 | + | |
177 | + return resp; | |
178 | + } | |
179 | + | |
180 | + | |
181 | + /** | |
182 | + * 检测注册信息是否正确 | |
183 | + * 1.电话号码 | |
184 | + * 2.账号,会员名 | |
185 | + * 3.验证码 | |
186 | + * @createTime 2014年10月31日 下午2:37:16 | |
187 | + * @author zhangshirui | |
188 | + */ | |
189 | + private boolean checkRegisterInfo(UserRegisterResp resp, UserRegisterReq req){ | |
190 | + if(!userRPC.checkMobile(req.getMobile())){ | |
191 | + throw new ServiceException(ResultCode.BUSINESS_FAILED,ErrorMessage.USER_MOBILE_EXIST); | |
192 | + } | |
193 | + //验证万能验证码 | |
194 | + String passkey = configRPC.getSystemConfig(Constant.USER_REGISTER_PASS_KEY); | |
195 | + if (req.getVeriCode().equals(passkey)) { | |
196 | + return true; | |
197 | + } | |
198 | + | |
199 | + checkVeriCode(req.getVeriCode(), req.getMobile(),SendVeriCodeReq.MSG_TYPE_REGISTER); | |
200 | + | |
201 | + return true; | |
202 | + } | |
203 | + | |
204 | + /** | |
205 | + * 根据验证码和电话号码,验证收到的验证码 | |
206 | + * | |
207 | + * @param code | |
208 | + * @param mobile | |
209 | + * @return | |
210 | + * @createTime 2014年8月28日 下午5:44:48 | |
211 | + * @author zhangshirui | |
212 | + */ | |
213 | + private void checkVeriCode(String code, String mobile,Integer msgType) { | |
214 | + | |
215 | + String redisKey = redisUtil.makeKey(RedisKey.USER_AUTH_CODE + String.valueOf(msgType), mobile); | |
216 | + | |
217 | + String redisCode = redisUtil.getString(redisKey); | |
218 | + | |
219 | + if(Validator.isEmpty(code)){ | |
220 | + throw new ServiceException(ResultCode.BUSINESS_FAILED,ErrorMessage.USER_AUTH_CODE_EMPTY); | |
221 | + } | |
222 | + | |
223 | + //验证码为空 | |
224 | + if (Validator.isEmpty(redisCode)) { | |
225 | + throw new ServiceException(ResultCode.BUSINESS_FAILED,ErrorMessage.USER_AUTH_CODE_OVERTIME); | |
226 | + } | |
227 | + | |
228 | + //验证码不为空,并且和redis中的验证码相同 | |
229 | + if (!code.equals(redisCode)) { | |
230 | + throw new ServiceException(ResultCode.BUSINESS_FAILED,ErrorMessage.USER_AUTH_CODE_WRONG); | |
231 | + } | |
232 | + | |
161 | 233 | } |
162 | 234 | |
163 | 235 | @Override |
... | ... | @@ -217,7 +289,36 @@ public class UserServiceImpl implements UserService { |
217 | 289 | |
218 | 290 | @Override |
219 | 291 | public ModifyPwdResp modifyPwd(ModifyPwdReq req) { |
220 | - return null; | |
292 | + BuyerInfoOutput userInfo = userRPC.getUserByMobile(req.getAccountName()); | |
293 | + Long userId = userInfo.getId(); | |
294 | + | |
295 | + | |
296 | + Map<String,String> params = new HashMap<String, String>(); | |
297 | + params.put("password", req.getPassword()); | |
298 | + params.put("accountId", String.valueOf(userId)); | |
299 | + | |
300 | + | |
301 | + String result = passportRPC.modifyPwd(params); | |
302 | + | |
303 | + JSONObject jsonBody = JSONObject.parseObject(result); | |
304 | + int code = jsonBody.getIntValue("code"); | |
305 | + ModifyPwdResp resp = new ModifyPwdResp(); | |
306 | + resp.setMsg(jsonBody.getString("msg")); | |
307 | + | |
308 | + if(code != ResultCode.SUCCESS){ | |
309 | + //失败 | |
310 | + resp.setCode(ResultCode.BUSINESS_FAILED); | |
311 | + resp.setResultFlag(ModifyPwdResp.RESULT_FLAG_FAILED); | |
312 | + return resp; | |
313 | + }else { | |
314 | + //修改成功,退出所有账号信息 | |
315 | + String cookieRedisKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, String.valueOf(userId)); | |
316 | + redisUtil.deleteByKey(cookieRedisKey); | |
317 | + } | |
318 | + | |
319 | + logger.info("修改用户密码"+jsonBody.getString("msg")); | |
320 | + | |
321 | + return resp; | |
221 | 322 | } |
222 | 323 | |
223 | 324 | @Override | ... | ... |
mobsite-getway-service/src/main/java/com/diligrp/mobsite/getway/service/seller/SellerUserService.java
1 | 1 | package com.diligrp.mobsite.getway.service.seller; |
2 | 2 | |
3 | -import com.diligrp.mobsite.getway.domain.protocol.BaseResp; | |
4 | -import com.diligrp.mobsite.getway.domain.protocol.saler.user.*; | |
3 | +import com.diligrp.mobsite.getway.domain.protocol.login.*; | |
4 | +import com.diligrp.mobsite.getway.domain.protocol.register.CheckMobileReq; | |
5 | +import com.diligrp.mobsite.getway.domain.protocol.register.CheckMobileResp; | |
6 | +import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterReq; | |
7 | +import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterResp; | |
8 | +import com.diligrp.mobsite.getway.domain.protocol.saler.user.SellerLoginReq; | |
9 | +import com.diligrp.mobsite.getway.domain.protocol.saler.user.SellerLoginResp; | |
10 | +import com.diligrp.mobsite.getway.domain.protocol.user.*; | |
5 | 11 | |
6 | 12 | |
7 | 13 | /** |
... | ... | @@ -23,61 +29,22 @@ public interface SellerUserService { |
23 | 29 | */ |
24 | 30 | SellerLoginResp login(SellerLoginReq req) throws RuntimeException; |
25 | 31 | |
26 | - /** | |
27 | - *卖家申请开店 | |
28 | - * */ | |
29 | - @Deprecated | |
30 | - BaseResp sellerAplyShop(SellerApplyShopReq req) throws RuntimeException; | |
31 | - | |
32 | - /** | |
33 | - *卖家申请开店 | |
34 | - * */ | |
35 | - BaseResp sellerAplyShopNew(SellerApplyShopNewReq req); | |
36 | 32 | |
37 | - /** | |
38 | - *卖家修改店铺信息 | |
39 | - * */ | |
40 | - BaseResp sellerModifyShop(SellerModifyShopRequest req); | |
41 | - | |
42 | - /** | |
43 | - *获取店铺详情 | |
44 | - * */ | |
45 | - SellerShopResp getShopDetail(GetSellerShopReq req) throws RuntimeException; | |
46 | 33 | |
47 | - /*** | |
48 | - * 开启或关闭赊销功能 1开启 2 关闭 | |
49 | - * */ | |
50 | - BaseResp openOrCloseShopCredit(OpenOrCloseReq req) throws RuntimeException; | |
51 | 34 | |
52 | - /*** | |
53 | - * 增加vip用户 | |
54 | - * */ | |
55 | - BaseResp saveVipUser(VipUserReq req) throws RuntimeException; | |
35 | + SendVeriCodeResp sendVeriCode(SendVeriCodeReq req); | |
56 | 36 | |
57 | - /*** | |
58 | - * 删除vip用户 | |
59 | - * */ | |
60 | - BaseResp deleteVipUser(VipUserReq req) throws RuntimeException; | |
37 | + CheckVeriCodeResp checkVeriCode(CheckVeriCodeReq req); | |
61 | 38 | |
62 | - /*** | |
63 | - * 修改vip用户 | |
64 | - * */ | |
65 | - BaseResp updateVipUser(VipUserReq req) throws RuntimeException; | |
39 | + CheckMobileResp checkMobile(CheckMobileReq req); | |
66 | 40 | |
67 | - /*** | |
68 | - * 查询vip用户号码在店铺是否存在 | |
69 | - * */ | |
70 | - CheckVipExisitResp isExistsNumber(VipUserReq req) throws RuntimeException; | |
41 | + ModifyPwdResp modifyPwd(ModifyPwdReq req); | |
71 | 42 | |
72 | - /*** | |
73 | - * 获取赊账用户列表 | |
74 | - * */ | |
75 | - SellerShopVipListResp queryVipUser(VipUserQueryReq req) throws RuntimeException; | |
43 | + UserRegisterResp sellerRegister(UserRegisterReq req); | |
76 | 44 | |
77 | - /*** | |
78 | - * 开启或关闭vip用户 | |
79 | - * */ | |
80 | - OpenOrCloseVipUserResp closeOrOpenVipUser(CloseOrOpenVipUserReq req); | |
45 | + LogoutResp logout(LogoutReq req); | |
81 | 46 | |
47 | + UpdateUserInfoResp updateUserInfo(UpdateUserInfoReq req); | |
82 | 48 | |
49 | + GetUserInfoResp getUserIntroduction(GetUserInfoReq req); | |
83 | 50 | } | ... | ... |
mobsite-getway-service/src/main/java/com/diligrp/mobsite/getway/service/seller/impl/SellerUserServiceImpl.java
1 | 1 | package com.diligrp.mobsite.getway.service.seller.impl; |
2 | 2 | |
3 | -import com.diligrp.mobsite.getway.domain.protocol.BaseResp; | |
4 | -import com.diligrp.mobsite.getway.domain.protocol.saler.user.*; | |
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; | |
8 | +import com.diligrp.mobsite.getway.domain.protocol.login.*; | |
9 | +import com.diligrp.mobsite.getway.domain.protocol.register.CheckMobileReq; | |
10 | +import com.diligrp.mobsite.getway.domain.protocol.register.CheckMobileResp; | |
11 | +import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterReq; | |
12 | +import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterResp; | |
13 | +import com.diligrp.mobsite.getway.domain.protocol.saler.user.SellerLoginReq; | |
14 | +import com.diligrp.mobsite.getway.domain.protocol.saler.user.SellerLoginResp; | |
15 | +import com.diligrp.mobsite.getway.domain.protocol.user.*; | |
16 | +import com.diligrp.mobsite.getway.manager.common.RegisterNoMapperManager; | |
17 | +import com.diligrp.mobsite.getway.rpc.buyer.*; | |
18 | +import com.diligrp.mobsite.getway.rpc.seller.SellerRPC; | |
19 | +import com.diligrp.mobsite.getway.rpc.utils.UserRedisUtil; | |
20 | +import com.diligrp.mobsite.getway.service.common.utils.PassportUtils; | |
5 | 21 | import com.diligrp.mobsite.getway.service.seller.SellerUserService; |
22 | +import com.diligrp.website.util.redis.impl.RedisUtilImpl; | |
23 | +import com.diligrp.website.util.security.Validator; | |
24 | +import com.diligrp.website.web.interfaces.domain.output.DataDictionaryResp; | |
25 | +import org.slf4j.Logger; | |
26 | +import org.slf4j.LoggerFactory; | |
27 | +import org.springframework.beans.factory.annotation.Autowired; | |
6 | 28 | import org.springframework.stereotype.Service; |
7 | 29 | |
30 | +import javax.annotation.Resource; | |
31 | + | |
8 | 32 | |
9 | 33 | /** |
10 | 34 | * <B>Description</B> 卖家用户信息 <br /> |
... | ... | @@ -17,6 +41,29 @@ import org.springframework.stereotype.Service; |
17 | 41 | @Service |
18 | 42 | public class SellerUserServiceImpl implements SellerUserService { |
19 | 43 | |
44 | + @Resource | |
45 | + private SellerRPC sellerRPC; | |
46 | + @Resource | |
47 | + private GoodsRPC goodsRPC; | |
48 | + @Autowired | |
49 | + private RedisUtilImpl redisUtil; | |
50 | + @Autowired | |
51 | + private UserRedisUtil userRedisUtil; | |
52 | + | |
53 | + @Resource | |
54 | + private RegisterNoMapperManager registerNoMapperManager; | |
55 | + @Resource | |
56 | + private PassportRPC passportRPC; | |
57 | + @Resource | |
58 | + private ConfigRPC configRPC; | |
59 | + | |
60 | + @Resource | |
61 | + private ShopRPC shopRPC; | |
62 | + @Autowired | |
63 | + private MessageRPC messageRPC; | |
64 | + | |
65 | + | |
66 | + private static Logger logger = LoggerFactory.getLogger(SellerUserServiceImpl.class); | |
20 | 67 | |
21 | 68 | @Override |
22 | 69 | public SellerLoginResp login(SellerLoginReq req) throws RuntimeException { |
... | ... | @@ -24,57 +71,109 @@ public class SellerUserServiceImpl implements SellerUserService { |
24 | 71 | } |
25 | 72 | |
26 | 73 | @Override |
27 | - public BaseResp sellerAplyShop(SellerApplyShopReq req) throws RuntimeException { | |
28 | - return null; | |
74 | + public SendVeriCodeResp sendVeriCode(SendVeriCodeReq req) { | |
75 | + SendVeriCodeResp resp = new SendVeriCodeResp(); | |
76 | + | |
77 | + String mobile = req.getMobile(); | |
78 | + boolean existFlag = !sellerRPC.checkMobile(mobile); | |
79 | + | |
80 | + Integer msgType = req.getMsgType(); | |
81 | + String code = null; | |
82 | + String message = null; | |
83 | + | |
84 | + String redisKey = redisUtil.makeKey(RedisKey.USER_AUTH_CODE + String.valueOf(msgType), mobile); | |
85 | + String veriCode = redisUtil.getString(redisKey); | |
86 | + | |
87 | + if (Validator.isEmpty(veriCode)) { | |
88 | + //生成验证码 | |
89 | + veriCode = PassportUtils.generateMobileRandomNumber(); | |
90 | + redisUtil.setStringByExpire(redisKey, String.valueOf(veriCode), RedisKey.USER_SEND_VERICODE_EXPIRE_TIME); | |
91 | + } | |
92 | + | |
93 | + if (!Validator.isNull(msgType) && msgType != SendVeriCodeReq.MSG_TYPE_DEFAULT) { | |
94 | + if (msgType==SendVeriCodeReq.MSG_TYPE_REGISTER) { | |
95 | + //注册,电话号码已经存在 | |
96 | + if(existFlag){ | |
97 | + throw new ServiceException(ResultCode.BUSINESS_FAILED, ErrorMessage.USER_MOBILE_EXIST); | |
98 | + } | |
99 | + String passkey = configRPC.getSystemConfig(Constant.USER_REGISTER_PASS_KEY); | |
100 | + resp.setPassKey(passkey); | |
101 | + | |
102 | + messageRPC.sendSMSMsg(mobile, veriCode, Constant.SMS_CONTENT_ACCOUNT_REGISTRATION); | |
103 | + resp.setSendCode(SendVeriCodeResp.SEND_CODE_SUCCESS); | |
104 | + return resp; | |
105 | + }else if(msgType==SendVeriCodeReq.MSG_TYPE_RETRIEVE_PASSWORD) { | |
106 | + //找回密码,电话号码没有存在 | |
107 | + if (!existFlag) { | |
108 | + throw new ServiceException(ResultCode.BUSINESS_FAILED,ErrorMessage.USER_MOBILE_NOT_EXIST); | |
109 | + } | |
110 | + messageRPC.sendSMSMsg(mobile, veriCode,Constant.SMS_CONTENT_RETRIEVE_PASSWORD); | |
111 | + resp.setSendCode(SendVeriCodeResp.SEND_CODE_SUCCESS); | |
112 | + return resp; | |
113 | + }else if(msgType==SendVeriCodeReq.MSG_TYPE_MODIFY_NEW_MOBILE) { | |
114 | + //修改手机号,电话号码已经存在 | |
115 | + if (existFlag) { | |
116 | + throw new ServiceException(ResultCode.BUSINESS_FAILED,ErrorMessage.USER_MOBILE_EXIST); | |
117 | + } | |
118 | + code = Constant.SMS_CONTENT_MODIFY_OLD_PHONE; | |
119 | + }else if (msgType==SendVeriCodeReq.MSG_TYPE_CHECK_OLD_MOBILE) { | |
120 | + //验证旧的手机号,手机不存在 | |
121 | + if (!existFlag) { | |
122 | + throw new ServiceException(ResultCode.BUSINESS_FAILED,ErrorMessage.USER_MOBILE_NOT_EXIST); | |
123 | + } | |
124 | + code = Constant.SMS_CONTENT_MODIFY_OLD_PHONE; | |
125 | + } | |
126 | + DataDictionaryResp dataDic = configRPC.getMessageTemplate(Constant.DIC_SMS_CONTENT); | |
127 | + message = dataDic.getValueByCode(code).getRemark().replace("{code}", veriCode); | |
128 | + }else { | |
129 | + message = Constant.SMS_CONTENT_DEFAULT.replace("{code}", veriCode); | |
130 | + } | |
131 | + | |
132 | + messageRPC.sendSMS(mobile, message); | |
133 | + | |
134 | + resp.setSendCode(SendVeriCodeResp.SEND_CODE_SUCCESS); | |
135 | + | |
136 | + return resp; | |
29 | 137 | } |
30 | 138 | |
31 | 139 | @Override |
32 | - public BaseResp sellerAplyShopNew(SellerApplyShopNewReq req) { | |
140 | + public CheckVeriCodeResp checkVeriCode(CheckVeriCodeReq req) { | |
33 | 141 | return null; |
34 | 142 | } |
35 | 143 | |
36 | 144 | @Override |
37 | - public BaseResp sellerModifyShop(SellerModifyShopRequest req) { | |
38 | - return null; | |
39 | - } | |
145 | + public CheckMobileResp checkMobile(CheckMobileReq req) { | |
146 | + CheckMobileResp resp = new CheckMobileResp(); | |
40 | 147 | |
41 | - @Override | |
42 | - public SellerShopResp getShopDetail(GetSellerShopReq req) throws RuntimeException { | |
43 | - return null; | |
44 | - } | |
148 | + boolean flag = sellerRPC.checkMobile(req.getMobile()); | |
45 | 149 | |
46 | - @Override | |
47 | - public BaseResp openOrCloseShopCredit(OpenOrCloseReq req) throws RuntimeException { | |
48 | - return null; | |
49 | - } | |
150 | + resp.setCheckFlag(flag ? CheckMobileResp.CHECK_FLAG_OK : CheckMobileResp.CHECK_FLAG_ERROR); | |
50 | 151 | |
51 | - @Override | |
52 | - public BaseResp saveVipUser(VipUserReq req) throws RuntimeException { | |
53 | - return null; | |
152 | + return resp; | |
54 | 153 | } |
55 | 154 | |
56 | 155 | @Override |
57 | - public BaseResp deleteVipUser(VipUserReq req) throws RuntimeException { | |
156 | + public ModifyPwdResp modifyPwd(ModifyPwdReq req) { | |
58 | 157 | return null; |
59 | 158 | } |
60 | 159 | |
61 | 160 | @Override |
62 | - public BaseResp updateVipUser(VipUserReq req) throws RuntimeException { | |
161 | + public UserRegisterResp sellerRegister(UserRegisterReq req) { | |
63 | 162 | return null; |
64 | 163 | } |
65 | 164 | |
66 | 165 | @Override |
67 | - public CheckVipExisitResp isExistsNumber(VipUserReq req) throws RuntimeException { | |
166 | + public LogoutResp logout(LogoutReq req) { | |
68 | 167 | return null; |
69 | 168 | } |
70 | 169 | |
71 | 170 | @Override |
72 | - public SellerShopVipListResp queryVipUser(VipUserQueryReq req) throws RuntimeException { | |
171 | + public UpdateUserInfoResp updateUserInfo(UpdateUserInfoReq req) { | |
73 | 172 | return null; |
74 | 173 | } |
75 | 174 | |
76 | 175 | @Override |
77 | - public OpenOrCloseVipUserResp closeOrOpenVipUser(CloseOrOpenVipUserReq req) { | |
176 | + public GetUserInfoResp getUserIntroduction(GetUserInfoReq req) { | |
78 | 177 | return null; |
79 | 178 | } |
80 | 179 | } | ... | ... |
mobsite-getway-web/src/main/java/com/diligrp/mobsite/getway/web/api/buyer/user/UserController.java
... | ... | @@ -165,28 +165,28 @@ public class UserController extends BaseApiController { |
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
168 | - * 验证手机收到的验证码 | |
168 | + * 忘记密码:验证手机收到的验证码 | |
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 | - //} | |
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 | 190 | |
191 | 191 | |
192 | 192 | /** |
... | ... | @@ -194,7 +194,7 @@ public class UserController extends BaseApiController { |
194 | 194 | * @createTime 2014年8月24日 下午10:55:03 |
195 | 195 | * @author weili |
196 | 196 | */ |
197 | - @ApiOperation(value = "找回密码-修改用户密码", httpMethod = "POST" ,response = SendVeriCodeResp.class) | |
197 | + @ApiOperation(value = "找回密码-设置用户新密码", httpMethod = "POST" ,response = SendVeriCodeResp.class) | |
198 | 198 | @RequestMapping(value = "/modifyPwd",method = RequestMethod.POST) |
199 | 199 | @ResponseBody |
200 | 200 | public void modifyPwd(@RequestBody ModifyPwdReq temp){ | ... | ... |
mobsite-getway-web/src/main/java/com/diligrp/mobsite/getway/web/api/seller/user/SellerUserController.java
1 | 1 | package com.diligrp.mobsite.getway.web.api.seller.user; |
2 | 2 | |
3 | 3 | import com.diligrp.mobsite.getway.domain.except.ServiceException; |
4 | +import com.diligrp.mobsite.getway.domain.protocol.login.*; | |
5 | +import com.diligrp.mobsite.getway.domain.protocol.register.CheckMobileReq; | |
6 | +import com.diligrp.mobsite.getway.domain.protocol.register.CheckMobileResp; | |
7 | +import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterReq; | |
8 | +import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterResp; | |
4 | 9 | import com.diligrp.mobsite.getway.domain.protocol.saler.user.SellerLoginReq; |
5 | 10 | import com.diligrp.mobsite.getway.domain.protocol.saler.user.SellerLoginResp; |
11 | +import com.diligrp.mobsite.getway.domain.protocol.user.*; | |
6 | 12 | import com.diligrp.mobsite.getway.service.seller.SellerUserService; |
7 | 13 | import com.diligrp.mobsite.getway.web.api.base.BaseApiController; |
14 | +import com.diligrp.mobsite.getway.web.utils.BeanValidator; | |
15 | +import com.diligrp.mobsite.getway.web.utils.DiligrpEndpoint; | |
16 | +import com.diligrp.website.util.security.Validator; | |
8 | 17 | import io.swagger.annotations.Api; |
9 | 18 | import io.swagger.annotations.ApiOperation; |
10 | 19 | import org.apache.log4j.Logger; |
... | ... | @@ -59,4 +68,259 @@ public class SellerUserController extends BaseApiController { |
59 | 68 | } |
60 | 69 | |
61 | 70 | |
71 | + /** | |
72 | + * 加密用户登录(加密) | |
73 | + * @createTime 2014年8月24日 下午10:55:03 | |
74 | + * @author weili | |
75 | + */ | |
76 | + @ApiOperation(value = "卖家登录", httpMethod = "POST",response = SellerLoginResp.class) | |
77 | + @RequestMapping(value = "/sellerLogins",method = RequestMethod.POST) | |
78 | + @ResponseBody | |
79 | + public void sellerLogins(@RequestBody SellerLoginReq temp){ | |
80 | + SellerLoginReq req = super.getRequest(SellerLoginReq.class); | |
81 | + try { | |
82 | + BeanValidator.validator(req); | |
83 | + req.setPassword(decodeStr(req.getPassword())); | |
84 | + SellerLoginResp resp = sellerUserService.login(req); | |
85 | + super.sendSuccessResp(resp); | |
86 | + } catch (ServiceException e){ | |
87 | + log.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s", | |
88 | + e.getCode(), e.getMessage(), req.getUserId()), e); | |
89 | + super.sendError(e.getCode(), e.getMessage()); | |
90 | + } catch (Exception e) { | |
91 | + log.error("用户登录失败:", e); | |
92 | + super.sendError(e.getMessage()); | |
93 | + } | |
94 | + } | |
95 | + | |
96 | + | |
97 | + /** | |
98 | + * 验证手机号是否已经被注册 | |
99 | + * @createTime 2014年8月28日 下午3:41:02 | |
100 | + * @author zhangshirui | |
101 | + */ | |
102 | + @RequestMapping("/checkMobile") | |
103 | + @ResponseBody | |
104 | + @DiligrpEndpoint(req = CheckMobileReq.class, resp=CheckMobileResp.class,group = "手机端个人中心",desc = "验证指定手机号是否已被注册") | |
105 | + public void checkMobile(){ | |
106 | + CheckMobileReq req = super.getRequest(CheckMobileReq.class); | |
107 | + CheckMobileResp resp = null; | |
108 | + try { | |
109 | + if(!Validator.isNull(req) && !Validator.isNull(req.getMobile())){ | |
110 | + resp = sellerUserService.checkMobile(req); | |
111 | + } else { | |
112 | + resp = new CheckMobileResp(); | |
113 | + } | |
114 | + super.sendSuccessResp(resp); | |
115 | + } catch (ServiceException e){ | |
116 | + log.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s", | |
117 | + e.getCode(), e.getMessage(), req.getUserId()), e); | |
118 | + sendError(e.getCode(), e.getMessage()); | |
119 | + } catch (Exception e) { | |
120 | + log.error("验证手机失败:", e); | |
121 | + super.sendError(e.getMessage()); | |
122 | + } | |
123 | + } | |
124 | + | |
125 | + /** | |
126 | + * 发送验证码到手机 | |
127 | + * @createTime 2014年8月24日 下午10:55:03 | |
128 | + * @author weili | |
129 | + */ | |
130 | + @ApiOperation(value = "发送验证码到手机", httpMethod = "POST" , notes = "发送验证码到手机",response = SendVeriCodeResp.class) | |
131 | + @RequestMapping(value = "/sendAuthCode",method = RequestMethod.POST) | |
132 | + @ResponseBody | |
133 | + public void sendAuthCode(@RequestBody SendVeriCodeReq temp){ | |
134 | + SendVeriCodeReq req= super.getRequest(SendVeriCodeReq.class); | |
135 | + try { | |
136 | + BeanValidator.validator(req); | |
137 | + SendVeriCodeResp resp = sellerUserService.sendVeriCode(req); | |
138 | + super.sendSuccessResp(resp); | |
139 | + } catch (ServiceException e){ | |
140 | + log.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s", | |
141 | + e.getCode(), e.getMessage(), req.getUserId()), e); | |
142 | + sendError(e.getMessage()); | |
143 | + } catch (Exception e) { | |
144 | + log.error("发送验证码失败:", e); | |
145 | + super.sendError(e.getMessage()); | |
146 | + } | |
147 | + } | |
148 | + | |
149 | + /** | |
150 | + * 忘记密码:验证手机收到的验证码 | |
151 | + * @createTime 2014年8月24日 下午10:55:03 | |
152 | + * @author weili | |
153 | + */ | |
154 | + @ApiOperation(value = "忘记密码:验证手机号和验证码", httpMethod = "POST" , notes = "验证手机收到的验证码",response = CheckVeriCodeResp.class) | |
155 | + @RequestMapping(value = "/checkAuthCode",method = RequestMethod.POST) | |
156 | + @ResponseBody | |
157 | + public void checkAuthCode(@RequestBody CheckVeriCodeReq temp){ | |
158 | + CheckVeriCodeReq req= super.getRequest(CheckVeriCodeReq.class); | |
159 | + try { | |
160 | + BeanValidator.validator(req); | |
161 | + CheckVeriCodeResp resp = sellerUserService.checkVeriCode(req); | |
162 | + super.sendSuccessResp(resp); | |
163 | + } catch (ServiceException e){ | |
164 | + log.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s", | |
165 | + e.getCode(), e.getMessage(), req.getUserId()), e); | |
166 | + sendError(e.getCode(), e.getMessage()); | |
167 | + } catch (Exception e) { | |
168 | + log.error("验证手机收到的验证码:", e); | |
169 | + super.sendError(e.getMessage()); | |
170 | + } | |
171 | + } | |
172 | + | |
173 | + | |
174 | + /** | |
175 | + * 找回密码-修改用户密码 | |
176 | + * @createTime 2014年8月24日 下午10:55:03 | |
177 | + * @author weili | |
178 | + */ | |
179 | + @ApiOperation(value = "找回密码-设置用户新密码", httpMethod = "POST" ,response = SendVeriCodeResp.class) | |
180 | + @RequestMapping(value = "/modifyPwd",method = RequestMethod.POST) | |
181 | + @ResponseBody | |
182 | + public void modifyPwd(@RequestBody ModifyPwdReq temp){ | |
183 | + ModifyPwdReq req = super.getRequest(ModifyPwdReq.class); | |
184 | + ModifyPwdResp resp = null; | |
185 | + try { | |
186 | + BeanValidator.validator(req); | |
187 | + resp = sellerUserService.modifyPwd(req); | |
188 | + super.sendSuccessResp(resp); | |
189 | + } catch (ServiceException e){ | |
190 | + log.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s", | |
191 | + e.getCode(), e.getMessage(), req.getUserId()), e); | |
192 | + sendError(e.getCode(), e.getMessage()); | |
193 | + } catch (Exception e) { | |
194 | + log.error("修改密码:", e); | |
195 | + super.sendError(e.getMessage()); | |
196 | + } | |
197 | + | |
198 | + } | |
199 | + | |
200 | + /** | |
201 | + * 卖家注册 | |
202 | + * @createTime 2014年8月28日 下午3:41:02 | |
203 | + * @author weili | |
204 | + */ | |
205 | + @ApiOperation(value = "卖家注册", httpMethod = "POST" ,response = UserRegisterResp.class) | |
206 | + @RequestMapping(value = "/sellerRegister",method = RequestMethod.POST) | |
207 | + @ResponseBody | |
208 | + public void sellerRegister(@RequestBody UserRegisterReq temp){ | |
209 | + UserRegisterReq req = super.getRequest(UserRegisterReq.class); | |
210 | + try { | |
211 | + BeanValidator.validator(req); | |
212 | + UserRegisterResp resp = sellerUserService.sellerRegister(req); | |
213 | + super.sendSuccessResp(resp); | |
214 | + } catch (ServiceException e){ | |
215 | + log.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s", | |
216 | + e.getCode(), e.getMessage(), req.getUserId()), e); | |
217 | + sendError(e.getCode(), e.getMessage()); | |
218 | + } catch (Exception e) { | |
219 | + log.error("用户注册失败:", e); | |
220 | + super.sendError(e.getMessage()); | |
221 | + } | |
222 | + } | |
223 | + | |
224 | + /** | |
225 | + * 卖家注册(加密) | |
226 | + * @createTime 2014年8月28日 下午3:41:02 | |
227 | + * @author weili | |
228 | + */ | |
229 | + @ApiOperation(value = "卖家注册", httpMethod = "POST" ,response = UserRegisterResp.class) | |
230 | + @RequestMapping(value = "/sellerRegisters",method = RequestMethod.POST) | |
231 | + @ResponseBody | |
232 | + public void sellerRegisters(@RequestBody UserRegisterReq temp){ | |
233 | + UserRegisterReq req = super.getRequest(UserRegisterReq.class); | |
234 | + try { | |
235 | + BeanValidator.validator(req); | |
236 | + req.setPassword(decodeStr(req.getPassword())); | |
237 | + UserRegisterResp resp = sellerUserService.sellerRegister(req); | |
238 | + super.sendSuccessResp(resp); | |
239 | + } catch (ServiceException e){ | |
240 | + log.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s", | |
241 | + e.getCode(), e.getMessage(), req.getUserId()), e); | |
242 | + sendError(e.getCode(), e.getMessage()); | |
243 | + } catch (Exception e) { | |
244 | + log.error("用户注册失败:", e); | |
245 | + super.sendError(e.getMessage()); | |
246 | + } | |
247 | + } | |
248 | + | |
249 | + /** | |
250 | + * 退出操作 | |
251 | + * | |
252 | + * @createTime 2014年8月29日 上午9:30:10 | |
253 | + * @author weili | |
254 | + */ | |
255 | + @ApiOperation(value = "退出", httpMethod = "POST" ,response = LogoutResp.class) | |
256 | + @RequestMapping(value = "/logout",method = RequestMethod.POST) | |
257 | + @ResponseBody | |
258 | + public void logout(@RequestBody LogoutReq temp){ | |
259 | + LogoutReq req = super.getRequest(LogoutReq.class); | |
260 | + try { | |
261 | + if(Validator.isNull(req) || !Validator.isNumber(req.getUserId()+"")) { | |
262 | + throw new NullPointerException("参数传递错误"); | |
263 | + } | |
264 | + LogoutResp resp = sellerUserService.logout(req); | |
265 | + super.sendSuccessResp(resp); | |
266 | + } catch (ServiceException e){ | |
267 | + log.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s", | |
268 | + e.getCode(), e.getMessage(), req.getUserId()), e); | |
269 | + sendError(e.getCode(), e.getMessage()); | |
270 | + } | |
271 | + catch (Exception e) { | |
272 | + log.error("用户退出失败:", e); | |
273 | + super.sendError(e.getMessage()); | |
274 | + } | |
275 | + } | |
276 | + | |
277 | + /** | |
278 | + * 个人信息维护 | |
279 | + * @createTime 2016年8月24日 下午10:55:03 | |
280 | + * @author weili | |
281 | + */ | |
282 | + @ApiOperation(value = "个人信息维护", httpMethod = "POST" ,response = UpdateUserInfoResp.class) | |
283 | + @RequestMapping(value = "/updateUserInfo",method = RequestMethod.POST) | |
284 | + @ResponseBody | |
285 | + public void updateUserInfo(@RequestBody UpdateUserInfoReq temp){ | |
286 | + UpdateUserInfoReq req = super.getRequest(UpdateUserInfoReq.class); | |
287 | + try { | |
288 | + UpdateUserInfoResp resp = sellerUserService.updateUserInfo(req); | |
289 | + super.sendSuccessResp(resp); | |
290 | + } catch (ServiceException e){ | |
291 | + log.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s", | |
292 | + e.getCode(), e.getMessage(), req.getUserId()), e); | |
293 | + sendError(e.getCode(), e.getMessage()); | |
294 | + } catch (Exception e) { | |
295 | + log.error("个人信息维护:", e); | |
296 | + super.sendError(e.getMessage()); | |
297 | + } | |
298 | + | |
299 | + } | |
300 | + | |
301 | + | |
302 | + | |
303 | + | |
304 | + /** | |
305 | + * 查询用户信息 | |
306 | + * GetUserInfoReq | |
307 | + */ | |
308 | + @ApiOperation(value = "查询卖家用户信息", httpMethod = "POST" ,response = GetDepositCardAmountResp.class) | |
309 | + @RequestMapping(value = "/getsellerInfo",method = RequestMethod.POST) | |
310 | + @ResponseBody | |
311 | + public void getsellerInfo() { | |
312 | + GetUserInfoReq req = getRequest(GetUserInfoReq.class); | |
313 | + try { | |
314 | + GetUserInfoResp resp = sellerUserService.getUserIntroduction(req); | |
315 | + super.sendSuccessResp(resp); | |
316 | + } catch (ServiceException e){ | |
317 | + log.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s", | |
318 | + e.getCode(), e.getMessage(), req.getUserId()), e); | |
319 | + sendError(e.getCode(), e.getMessage()); | |
320 | + } catch (Exception e) { | |
321 | + log.error(String.format("ErrorMessage=%s,UserId=%s", e.getMessage(), req.getUserId()), e); | |
322 | + sendError(e.getMessage()); | |
323 | + } | |
324 | + } | |
325 | + | |
62 | 326 | } | ... | ... |