Browse Source

添加邮箱验证重新发送邮件的接口。

zzy.zhiyuan.foxmail 8 years ago
parent
commit
8c3d24a892
1 changed files with 33 additions and 29 deletions
  1. 33 29
      src/main/java/com/ekexiu/portal/service/SysService.java

+ 33 - 29
src/main/java/com/ekexiu/portal/service/SysService.java

@ -368,17 +368,14 @@ public class SysService {
368 368
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
369 369
				.getCachedObject(key);
370 370
		if (sc == null) {
371
			System.out.println("a");
372 371
			this.userDao.delete(con, userId);
373 372
			return null;
374 373
		}
375 374
		if (sc.getExpiredTime() < System.currentTimeMillis()) {
376
			System.out.println("b");
377 375
			this.userDao.delete(con, userId);
378 376
			return null;
379 377
		}
380 378
		try {
381
			System.out.println("c");
382 379
			User user = userDao.queryByEmailOrMobilePhone(con, mail);
383 380
			if (null == user)
384 381
				return null;
@ -421,35 +418,42 @@ public class SysService {
421 418
			user1.setPasswd(passwd);
422 419
			user1.setUserType(0 + "");
423 420
			this.userDao.insert(con, user1);
424
			StateCode<String, String> sc = new StateCode<String, String>();
425
			final String key = JfwAppContext.cacheObjectAndGenKey(sc);
426
427
			Map<String, String> map = new HashMap<String, String>();
428
			map.put(this.regMailReplaceKey, key);
429
			try {
430
				mailservice.sendSimpleMail(mail,
431
						this.regMailReplaceContentTempalte, map,
432
						this.bindMailSubject);
433
				long ct = System.currentTimeMillis();
434
				long et = ct + this.timeLimitWithRegMail + 10000;
435
				sc.setBuildTime(ct);
436
				sc.setExpiredTime(et);
437
				JfwAppContext.getScheduledExecutorService().schedule(
438
						new Runnable() {
439
							@Override
440
							public void run() {
441
								JfwAppContext.removeCachedObject(key);
442
							}
443
						}, this.timeLimitWithRegMail + 20000,
444
						TimeUnit.MILLISECONDS);
445
			} catch (Exception e) {
446
				JfwAppContext.removeCachedObject(key);
447
				throw new JfwBaseException(10011, "send mail to " + mail
448
						+ " error", e);
449
			}
421
			this.sendMailReg(con, mail);
450 422
		}
451 423
		return user1.getId();
452 424
	}
425
	
426
	@Get
427
	@Path("/resendMail")
428
	public boolean sendMailReg(@JdbcConn(false) Connection con, String mail) throws JfwBaseException {
429
		StateCode<String, String> sc = new StateCode<String, String>();
430
		final String key = JfwAppContext.cacheObjectAndGenKey(sc);
431
432
		Map<String, String> map = new HashMap<String, String>();
433
		map.put(this.regMailReplaceKey, key);
434
		try {
435
			mailservice.sendSimpleMail(mail,
436
					this.regMailReplaceContentTempalte, map,
437
					this.bindMailSubject);
438
			long ct = System.currentTimeMillis();
439
			long et = ct + this.timeLimitWithRegMail + 10000;
440
			sc.setBuildTime(ct);
441
			sc.setExpiredTime(et);
442
			JfwAppContext.getScheduledExecutorService().schedule(
443
					new Runnable() {
444
						@Override
445
						public void run() {
446
							JfwAppContext.removeCachedObject(key);
447
						}
448
					}, this.timeLimitWithRegMail + 20000,
449
					TimeUnit.MILLISECONDS);
450
		} catch (Exception e) {
451
			JfwAppContext.removeCachedObject(key);
452
			throw new JfwBaseException(10011, "send mail to " + mail
453
					+ " error", e);
454
		}
455
		return true;
456
	}
453 457
454 458
	@SetCookie(checkResultNull = true, path = "/", value = {
455 459
			"userid=result.getId()", "userMobilePhone=result.getMobilePhone()",