Browse Source

--add changeOrgPw();add reqBindOrgMail();add bindOrgMail();

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

+ 55 - 0
src/main/java/com/ekexiu/portal/service/SysService.java

@ -867,6 +867,12 @@ public class SysService {
867 867
			return this.userDao.updatePasswd(con, StringUtil.md5(npw), id, StringUtil.md5(onw)) > 0;
868 868
		}
869 869
	}
870
	
871
	@Post
872
	@Path("/cpOrg")
873
	public boolean changeOrgPw(@JdbcConn(true) Connection con, String id, String npw, String onw) throws SQLException {
874
		return this.orgUserDao.updatePw(con, id, StringUtil.md5(npw), StringUtil.md5(onw)) > 0;
875
	}
870 876
871 877
	@Get
872 878
	@Path("/reqBindMail")
@ -920,6 +926,55 @@ public class SysService {
920 926
			JfwAppContext.removeCachedObject(key);
921 927
		}
922 928
	}
929
	
930
	@Get
931
	@Path("/reqBindOrgMail")
932
	public boolean reqBindOrgMail(@JdbcConn(false) Connection con, String id, String mail) throws JfwBaseException, SQLException {
933
		OrgUser orgUser = this.orgUserDao.queryOne(con, id);
934
		if (null == orgUser)
935
			return false;
936
937
		StateCode<String, String> sc = new StateCode<String, String>();
938
		sc.setKey(id);
939
		sc.setValue(mail);
940
		final String key = JfwAppContext.cacheObjectAndGenKey(sc);
941
942
		Map<String, String> map = new HashMap<String, String>();
943
		map.put(this.bindMailReplaceKey, key);
944
		try {
945
			mailservice.sendSimpleMail(mail, this.bindMailReplaceContentTempalte, map, this.bindMailSubject);
946
			long ct = System.currentTimeMillis();
947
			long et = ct + this.timeLimitWithBindMail + 10000;
948
			sc.setBuildTime(ct);
949
			sc.setExpiredTime(et);
950
			JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
951
				@Override
952
				public void run() {
953
					JfwAppContext.removeCachedObject(key);
954
				}
955
			}, this.timeLimitWithBindMail + 20000, TimeUnit.MILLISECONDS);
956
		} catch (Exception e) {
957
			JfwAppContext.removeCachedObject(key);
958
			throw new JfwBaseException(10011, "send mail to " + mail + " error", e);
959
		}
960
		return true;
961
	}
962
	
963
	@Get
964
	@Path("/bindOrgMail/{key}")
965
	public boolean bindOrgMail(@JdbcConn(true) Connection con, @PathVar String key) throws SQLException, JfwBaseException {
966
		@SuppressWarnings("unchecked")
967
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(key);
968
		if (sc == null)
969
			return false;
970
		if (sc.getExpiredTime() < System.currentTimeMillis())
971
			return false;
972
		try {
973
			return this.orgUserDao.updateEmail(con, sc.getKey(), sc.getValue()) > 0;
974
		} finally {
975
			JfwAppContext.removeCachedObject(key);
976
		}
977
	}
923 978
924 979
	@Get
925 980
	@Path("/vcWithBind")