|
@ -108,6 +108,10 @@ public class SysService {
|
108
|
108
|
private String regMobilePhoneReplaceKey;
|
109
|
109
|
private String regMobilePhoneContentTemplate;
|
110
|
110
|
private long timeLimitWithRegMobilePhone = 3 * 60 * 1000;
|
|
111
|
|
|
112
|
private String loginMobilePhoneReplaceKey;
|
|
113
|
private String loginMobilePhoneContentTemplate;
|
|
114
|
private long timeLimitWithLoginMobilePhone = 3 * 60 * 1000;
|
111
|
115
|
|
112
|
116
|
private String phoneContentTemplate;
|
113
|
117
|
private String phoneReplaceKey = "mobileCode";
|
|
@ -175,6 +179,30 @@ public class SysService {
|
175
|
179
|
this.timeLimitWithRegMobilePhone = timeLimitWithRegMobilePhone;
|
176
|
180
|
}
|
177
|
181
|
|
|
182
|
public String getLoginMobilePhoneReplaceKey() {
|
|
183
|
return loginMobilePhoneReplaceKey;
|
|
184
|
}
|
|
185
|
|
|
186
|
public void setLoginMobilePhoneReplaceKey(String loginMobilePhoneReplaceKey) {
|
|
187
|
this.loginMobilePhoneReplaceKey = loginMobilePhoneReplaceKey;
|
|
188
|
}
|
|
189
|
|
|
190
|
public String getLoginMobilePhoneContentTemplate() {
|
|
191
|
return loginMobilePhoneContentTemplate;
|
|
192
|
}
|
|
193
|
|
|
194
|
public void setLoginMobilePhoneContentTemplate(String loginMobilePhoneContentTemplate) {
|
|
195
|
this.loginMobilePhoneContentTemplate = loginMobilePhoneContentTemplate;
|
|
196
|
}
|
|
197
|
|
|
198
|
public long getTimeLimitWithLoginMobilePhone() {
|
|
199
|
return timeLimitWithLoginMobilePhone;
|
|
200
|
}
|
|
201
|
|
|
202
|
public void setTimeLimitWithLoginMobilePhone(long timeLimitWithLoginMobilePhone) {
|
|
203
|
this.timeLimitWithLoginMobilePhone = timeLimitWithLoginMobilePhone;
|
|
204
|
}
|
|
205
|
|
178
|
206
|
public String getMailRetrievePasswordSubject() {
|
179
|
207
|
return mailRetrievePasswordSubject;
|
180
|
208
|
}
|
|
@ -1331,10 +1359,8 @@ public class SysService {
|
1331
|
1359
|
|
1332
|
1360
|
/**
|
1333
|
1361
|
* 发送手机验证码
|
1334
|
|
*
|
1335
|
1362
|
* @param con
|
1336
|
|
* @param mobilePhone
|
1337
|
|
* 验证的手机号
|
|
1363
|
* @param mobilePhone 验证的手机号
|
1338
|
1364
|
* @return
|
1339
|
1365
|
* @throws JfwBaseException
|
1340
|
1366
|
* @throws SQLException
|
|
@ -1346,15 +1372,11 @@ public class SysService {
|
1346
|
1372
|
if (null != user) {
|
1347
|
1373
|
return null;
|
1348
|
1374
|
}
|
1349
|
|
|
1350
|
1375
|
StateCode<String, String> sc = new StateCode<String, String>();
|
1351
|
|
|
1352
|
1376
|
final String key = JfwAppContext.cacheObjectAndGenKey(sc);
|
1353
|
|
|
1354
|
1377
|
try {
|
1355
|
1378
|
Random rd = new Random();
|
1356
|
1379
|
int vi = rd.nextInt(10000);
|
1357
|
|
|
1358
|
1380
|
String vc = String.format("%04d", vi);
|
1359
|
1381
|
sc.setKey(mobilePhone);
|
1360
|
1382
|
sc.setValue(vc);
|
|
@ -1375,6 +1397,39 @@ public class SysService {
|
1375
|
1397
|
}
|
1376
|
1398
|
return key;
|
1377
|
1399
|
}
|
|
1400
|
|
|
1401
|
@Get
|
|
1402
|
@Path("/sendMobileForLogin")
|
|
1403
|
public String sendMobileForLogin(@JdbcConn(false) Connection con, String mobilePhone) throws JfwBaseException, SQLException {
|
|
1404
|
User user = this.userDao.queryByEmailOrMobilePhone(con, mobilePhone);
|
|
1405
|
if (null == user) {
|
|
1406
|
return null;
|
|
1407
|
}
|
|
1408
|
StateCode<String, String> sc = new StateCode<String, String>();
|
|
1409
|
final String key = JfwAppContext.cacheObjectAndGenKey(sc);
|
|
1410
|
try {
|
|
1411
|
Random rd = new Random();
|
|
1412
|
int vi = rd.nextInt(10000);
|
|
1413
|
String vc = String.format("%04d", vi);
|
|
1414
|
sc.setKey(mobilePhone);
|
|
1415
|
sc.setValue(vc);
|
|
1416
|
this.mobilePhoneServcie.sendMessage(mobilePhone, this.loginMobilePhoneContentTemplate, this.loginMobilePhoneReplaceKey, vc);
|
|
1417
|
long ct = System.currentTimeMillis();
|
|
1418
|
long et = ct + this.timeLimitWithLoginMobilePhone + 5000;
|
|
1419
|
sc.setBuildTime(ct);
|
|
1420
|
sc.setExpiredTime(et);
|
|
1421
|
JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
|
|
1422
|
@Override
|
|
1423
|
public void run() {
|
|
1424
|
JfwAppContext.removeCachedObject(key);
|
|
1425
|
}
|
|
1426
|
}, this.timeLimitWithLoginMobilePhone + 10000, TimeUnit.MILLISECONDS);
|
|
1427
|
} catch (Exception e) {
|
|
1428
|
JfwAppContext.removeCachedObject(key);
|
|
1429
|
throw new JfwBaseException(10012, "send mobile phone message to " + mobilePhone + " error", e);
|
|
1430
|
}
|
|
1431
|
return key;
|
|
1432
|
}
|
1378
|
1433
|
|
1379
|
1434
|
@Post
|
1380
|
1435
|
@Path("/bindMobilePhone")
|