|
@@ -18,6 +18,7 @@ import com.example.client.security.LoginUser; |
|
@@ -18,6 +18,7 @@ import com.example.client.security.LoginUser; |
18
|
import com.example.client.security.TokenService;
|
18
|
import com.example.client.security.TokenService;
|
19
|
import com.example.client.service.LonginService;
|
19
|
import com.example.client.service.LonginService;
|
20
|
import com.example.client.service.UserService;
|
20
|
import com.example.client.service.UserService;
|
|
|
21
|
+import com.example.client.utils.HttpUtils;
|
21
|
import com.example.client.utils.ip.IpUtils;
|
22
|
import com.example.client.utils.ip.IpUtils;
|
22
|
import com.example.client.utils.sign.Md5Utils;
|
23
|
import com.example.client.utils.sign.Md5Utils;
|
23
|
import com.example.client.utils.verification.PhoneUtils;
|
24
|
import com.example.client.utils.verification.PhoneUtils;
|
|
@@ -37,6 +38,12 @@ import java.util.concurrent.TimeUnit; |
|
@@ -37,6 +38,12 @@ import java.util.concurrent.TimeUnit; |
37
|
*/
|
38
|
*/
|
38
|
@Service
|
39
|
@Service
|
39
|
public class LonginServiceImpl implements LonginService {
|
40
|
public class LonginServiceImpl implements LonginService {
|
|
|
41
|
+ public static final String url = "https://api.weixin.qq.com/sns/oauth2/access_token";
|
|
|
42
|
+
|
|
|
43
|
+ public static final String APPID = "";
|
|
|
44
|
+
|
|
|
45
|
+ public static final String SECRET = "";
|
|
|
46
|
+
|
40
|
@Autowired
|
47
|
@Autowired
|
41
|
private RedisCache redisCache;
|
48
|
private RedisCache redisCache;
|
42
|
@Autowired
|
49
|
@Autowired
|
|
@@ -166,13 +173,14 @@ public class LonginServiceImpl implements LonginService { |
|
@@ -166,13 +173,14 @@ public class LonginServiceImpl implements LonginService { |
166
|
|
173
|
|
167
|
/**
|
174
|
/**
|
168
|
* 删除缓存
|
175
|
* 删除缓存
|
|
|
176
|
+ *
|
169
|
* @param key
|
177
|
* @param key
|
170
|
* @return
|
178
|
* @return
|
171
|
*/
|
179
|
*/
|
172
|
- public AjaxResult logOut(String key ) {
|
180
|
+ public AjaxResult logOut(String key) {
|
173
|
|
181
|
|
174
|
|
182
|
|
175
|
- String cacheObject = (String)redisCache.getCacheObject(key);
|
183
|
+ String cacheObject = (String) redisCache.getCacheObject(key);
|
176
|
//刪除等記錄
|
184
|
//刪除等記錄
|
177
|
redisCache.deleteObject(key);
|
185
|
redisCache.deleteObject(key);
|
178
|
//退出
|
186
|
//退出
|
|
@@ -181,6 +189,7 @@ public class LonginServiceImpl implements LonginService { |
|
@@ -181,6 +189,7 @@ public class LonginServiceImpl implements LonginService { |
181
|
|
189
|
|
182
|
return AjaxResult.success(true);
|
190
|
return AjaxResult.success(true);
|
183
|
}
|
191
|
}
|
|
|
192
|
+
|
184
|
@Override
|
193
|
@Override
|
185
|
public AjaxResult forget(UpdatePasswordDTO dto) {
|
194
|
public AjaxResult forget(UpdatePasswordDTO dto) {
|
186
|
|
195
|
|
|
@@ -222,9 +231,9 @@ public class LonginServiceImpl implements LonginService { |
|
@@ -222,9 +231,9 @@ public class LonginServiceImpl implements LonginService { |
222
|
|
231
|
|
223
|
CUserVo cUserVo = userService.queryById(userId);
|
232
|
CUserVo cUserVo = userService.queryById(userId);
|
224
|
|
233
|
|
225
|
- if(cUserVo==null){
|
|
|
226
|
- return AjaxResult.error("非法进入");
|
|
|
227
|
- }
|
234
|
+ if (cUserVo == null) {
|
|
|
235
|
+ return AjaxResult.error("非法进入");
|
|
|
236
|
+ }
|
228
|
CUserBo cUserBo = new CUserBo();
|
237
|
CUserBo cUserBo = new CUserBo();
|
229
|
cUserBo.setUserId(userId);
|
238
|
cUserBo.setUserId(userId);
|
230
|
//修改密码
|
239
|
//修改密码
|
|
@@ -236,7 +245,7 @@ public class LonginServiceImpl implements LonginService { |
|
@@ -236,7 +245,7 @@ public class LonginServiceImpl implements LonginService { |
236
|
//判断是否登录
|
245
|
//判断是否登录
|
237
|
Object cacheObject = redisCache.getCacheObject(key);
|
246
|
Object cacheObject = redisCache.getCacheObject(key);
|
238
|
//删除缓存 重新登录
|
247
|
//删除缓存 重新登录
|
239
|
- if(cacheObject != null ){
|
248
|
+ if (cacheObject != null) {
|
240
|
logOut(key);
|
249
|
logOut(key);
|
241
|
}
|
250
|
}
|
242
|
|
251
|
|
|
@@ -250,11 +259,11 @@ public class LonginServiceImpl implements LonginService { |
|
@@ -250,11 +259,11 @@ public class LonginServiceImpl implements LonginService { |
250
|
if (loginBo.getType() != null && loginBo.getType() == 1) {
|
259
|
if (loginBo.getType() != null && loginBo.getType() == 1) {
|
251
|
UserTrVo userTrVo = new UserTrVo();
|
260
|
UserTrVo userTrVo = new UserTrVo();
|
252
|
CUserVo cUserVo = userService.queryById(UserContext.currentUserId());
|
261
|
CUserVo cUserVo = userService.queryById(UserContext.currentUserId());
|
253
|
- if( user != null){
|
262
|
+ if (user != null) {
|
254
|
AjaxResult.error("这个微信号已经绑定了账号");
|
263
|
AjaxResult.error("这个微信号已经绑定了账号");
|
255
|
}
|
264
|
}
|
256
|
|
265
|
|
257
|
- if (cUserVo != null ) {
|
266
|
+ if (cUserVo != null) {
|
258
|
CUserBo cUserBo = new CUserBo();
|
267
|
CUserBo cUserBo = new CUserBo();
|
259
|
cUserBo.setUserId(UserContext.currentUserId());
|
268
|
cUserBo.setUserId(UserContext.currentUserId());
|
260
|
cUserBo.setOpenId(loginBo.getOpenId());
|
269
|
cUserBo.setOpenId(loginBo.getOpenId());
|
|
@@ -274,7 +283,7 @@ public class LonginServiceImpl implements LonginService { |
|
@@ -274,7 +283,7 @@ public class LonginServiceImpl implements LonginService { |
274
|
UserService.insert(cUser1);
|
283
|
UserService.insert(cUser1);
|
275
|
}*/
|
284
|
}*/
|
276
|
|
285
|
|
277
|
- if(user !=null){
|
286
|
+ if (user != null) {
|
278
|
LoginTokenVO vo = new LoginTokenVO();
|
287
|
LoginTokenVO vo = new LoginTokenVO();
|
279
|
//不返回密码
|
288
|
//不返回密码
|
280
|
user.setUserPassword(null);
|
289
|
user.setUserPassword(null);
|
|
@@ -302,18 +311,16 @@ public class LonginServiceImpl implements LonginService { |
|
@@ -302,18 +311,16 @@ public class LonginServiceImpl implements LonginService { |
302
|
CUserVo user = userService.queryById(userId);
|
311
|
CUserVo user = userService.queryById(userId);
|
303
|
|
312
|
|
304
|
|
313
|
|
305
|
-
|
|
|
306
|
-
|
|
|
307
|
//账号和密码来做key
|
314
|
//账号和密码来做key
|
308
|
String key = user.getAccount() + user.getUserPassword();
|
315
|
String key = user.getAccount() + user.getUserPassword();
|
309
|
|
316
|
|
310
|
- String cacheObject = (String)redisCache.getCacheObject(key);
|
317
|
+ String cacheObject = (String) redisCache.getCacheObject(key);
|
311
|
//
|
318
|
//
|
312
|
CUserBo cUserBo = new CUserBo();
|
319
|
CUserBo cUserBo = new CUserBo();
|
313
|
cUserBo.setUserId(UserContext.currentUserId());
|
320
|
cUserBo.setUserId(UserContext.currentUserId());
|
314
|
cUserBo.setOpenId(null);
|
321
|
cUserBo.setOpenId(null);
|
315
|
//解除微信绑定
|
322
|
//解除微信绑定
|
316
|
- userService.updateOpenId(userId);
|
323
|
+ userService.updateOpenId(userId);
|
317
|
userService.updateByBo(cUserBo);
|
324
|
userService.updateByBo(cUserBo);
|
318
|
|
325
|
|
319
|
//刪除等記錄
|
326
|
//刪除等記錄
|
|
@@ -327,6 +334,12 @@ public class LonginServiceImpl implements LonginService { |
|
@@ -327,6 +334,12 @@ public class LonginServiceImpl implements LonginService { |
327
|
|
334
|
|
328
|
@Override
|
335
|
@Override
|
329
|
public AjaxResult loginCode(LoginBo loginBo) {
|
336
|
public AjaxResult loginCode(LoginBo loginBo) {
|
330
|
- return null;
|
337
|
+
|
|
|
338
|
+ String param = "appid=" + APPID + "&secret=" + SECRET + "&code=" + loginBo.getOpenId() + "&grant_type=authorization_code";
|
|
|
339
|
+ String s = HttpUtils.mySendGet(url, param);
|
|
|
340
|
+
|
|
|
341
|
+ System.out.println("======================================================="+s);
|
|
|
342
|
+
|
|
|
343
|
+ return AjaxResult.success(s);
|
331
|
}
|
344
|
}
|
332
|
} |
345
|
} |