|
@ -109,6 +109,11 @@ public class SysService {
|
109
|
109
|
private String inviteReplaceCode = "invitCodeKey";
|
110
|
110
|
private String inviteMailSubject = "[ 科袖网 ]特邀科研专家邀请函";
|
111
|
111
|
private String inviteMailContentTempalte;
|
|
112
|
|
|
113
|
private String inviteStaffReplaceKey = "stateCode";
|
|
114
|
private String inviteStaffMailTempalte;
|
|
115
|
private String inviteStaffOrgKey = "orgKey";
|
|
116
|
private String inviteStaffSubject = "[ 科袖网 ]企业员工邀请函";
|
112
|
117
|
|
113
|
118
|
public String getRegMailReplaceKey() {
|
114
|
119
|
return regMailReplaceKey;
|
|
@ -478,6 +483,38 @@ public class SysService {
|
478
|
483
|
this.timeLimitWithOrgRegMail = timeLimitWithOrgRegMail;
|
479
|
484
|
}
|
480
|
485
|
|
|
486
|
public String getInviteStaffReplaceKey() {
|
|
487
|
return inviteStaffReplaceKey;
|
|
488
|
}
|
|
489
|
|
|
490
|
public void setInviteStaffReplaceKey(String inviteStaffReplaceKey) {
|
|
491
|
this.inviteStaffReplaceKey = inviteStaffReplaceKey;
|
|
492
|
}
|
|
493
|
|
|
494
|
public String getInviteStaffMailTempalte() {
|
|
495
|
return inviteStaffMailTempalte;
|
|
496
|
}
|
|
497
|
|
|
498
|
public void setInviteStaffMailTempalte(String inviteStaffMailTempalte) {
|
|
499
|
this.inviteStaffMailTempalte = inviteStaffMailTempalte;
|
|
500
|
}
|
|
501
|
|
|
502
|
public String getInviteStaffOrgKey() {
|
|
503
|
return inviteStaffOrgKey;
|
|
504
|
}
|
|
505
|
|
|
506
|
public void setInviteStaffOrgKey(String inviteStaffOrgKey) {
|
|
507
|
this.inviteStaffOrgKey = inviteStaffOrgKey;
|
|
508
|
}
|
|
509
|
|
|
510
|
public String getInviteStaffSubject() {
|
|
511
|
return inviteStaffSubject;
|
|
512
|
}
|
|
513
|
|
|
514
|
public void setInviteStaffSubject(String inviteStaffSubject) {
|
|
515
|
this.inviteStaffSubject = inviteStaffSubject;
|
|
516
|
}
|
|
517
|
|
481
|
518
|
/**
|
482
|
519
|
* 验证注册时填写的手机号和邮箱是否已经注册过
|
483
|
520
|
*
|
|
@ -791,6 +828,91 @@ public class SysService {
|
791
|
828
|
this.mailservice.sendSimpleMail(user.getEmail(), mailContent, null, this.inviteMailSubject);
|
792
|
829
|
return "send success !";
|
793
|
830
|
}
|
|
831
|
|
|
832
|
@Post
|
|
833
|
@Path("/inviteStaff/{key}")
|
|
834
|
public Map<String, String> inviteStaff(@JdbcConn Connection con,@PathVar String key)throws SQLException, JfwBaseException{
|
|
835
|
@SuppressWarnings("unchecked")
|
|
836
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(key);
|
|
837
|
if(sc == null){
|
|
838
|
throw new JfwBaseException(-1, "验证链接已失效");
|
|
839
|
}
|
|
840
|
Organization org = this.orgDao.query(con, sc.getKey());
|
|
841
|
if(org == null){
|
|
842
|
throw new JfwBaseException(-2, "不存在的企业");
|
|
843
|
}
|
|
844
|
Map<String, String> map = new HashMap<String, String>();
|
|
845
|
map.put("orgId", org.getId());
|
|
846
|
map.put("orgName", org.getName());
|
|
847
|
map.put("email", sc.getValue());
|
|
848
|
return map;
|
|
849
|
|
|
850
|
}
|
|
851
|
|
|
852
|
@Post
|
|
853
|
@Path("/regInviteStaff")
|
|
854
|
@SuppressWarnings("unchecked")
|
|
855
|
public String regInviteStaff(@JdbcConn(true) Connection con,String key,String state,String phone,String validateCode,String name,String passwd)throws SQLException, JfwBaseException{
|
|
856
|
StateCode<String, String> stateCode = (StateCode<String, String>) JfwAppContext.getCachedObject(key);
|
|
857
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
|
|
858
|
if (stateCode == null) {
|
|
859
|
throw new JfwBaseException(-1, "邮箱验证链接已失效");
|
|
860
|
}
|
|
861
|
if (sc == null || sc.getExpiredTime() < System.currentTimeMillis()) {
|
|
862
|
throw new JfwBaseException(-2, "短信验证超时");
|
|
863
|
}
|
|
864
|
if (!sc.getKey().equals(phone)) {
|
|
865
|
throw new JfwBaseException(-3, "手机号与验证手机不匹配");
|
|
866
|
}
|
|
867
|
if (!sc.getValue().equals(validateCode)) {
|
|
868
|
throw new JfwBaseException(-4, "手机验证码错误");
|
|
869
|
}
|
|
870
|
try {
|
|
871
|
String id = StringUtil.buildUUID();
|
|
872
|
User user = new User();
|
|
873
|
user.setId(id);
|
|
874
|
user.setMobilePhone(phone);
|
|
875
|
user.setEmail(stateCode.getValue());
|
|
876
|
user.setPasswd(StringUtil.md5(passwd));
|
|
877
|
user.setUserType("0");
|
|
878
|
user.setActiveTime(DATE.format(new Date()));
|
|
879
|
Professor professor = new Professor();
|
|
880
|
professor.setId(id);
|
|
881
|
professor.setName(name);
|
|
882
|
professor.setOrgId(stateCode.getKey());
|
|
883
|
this.userDao.insert(con, user);
|
|
884
|
this.professorDao.insert(con, professor);
|
|
885
|
return id;
|
|
886
|
} finally {
|
|
887
|
JfwAppContext.removeCachedObject(key);
|
|
888
|
JfwAppContext.removeCachedObject(state);
|
|
889
|
}
|
|
890
|
}
|
|
891
|
|
|
892
|
@Get
|
|
893
|
@Path("/inviteStaffMail")
|
|
894
|
public boolean inviteStaffMail(@JdbcConn(false) Connection con,String orgId,String mail) throws SQLException, JfwBaseException {
|
|
895
|
Organization org = this.orgDao.query(con, orgId);
|
|
896
|
if(org == null){
|
|
897
|
throw new JfwBaseException(-1, "系统没有该企业");
|
|
898
|
}
|
|
899
|
StateCode<String, String> sc = new StateCode<String, String>();
|
|
900
|
final String key = JfwAppContext.cacheObjectAndGenKey(sc);
|
|
901
|
Map<String, String> map = new HashMap<>();
|
|
902
|
map.put(this.inviteStaffReplaceKey, key);
|
|
903
|
String mailContent = this.inviteStaffMailTempalte;
|
|
904
|
mailContent = mailContent.replaceAll(this.inviteStaffOrgKey, org.getName());
|
|
905
|
try {
|
|
906
|
this.mailservice.sendSimpleMail(mail, mailContent, map, this.inviteStaffSubject);
|
|
907
|
} catch (MessagingException e) {
|
|
908
|
JfwAppContext.removeCachedObject(key);
|
|
909
|
throw new JfwBaseException(10011, "send mail to " + mail + " error", e);
|
|
910
|
}
|
|
911
|
sc.setKey(orgId);
|
|
912
|
sc.setValue(mail);
|
|
913
|
sc.setCode(org.getName());
|
|
914
|
return true;
|
|
915
|
}
|
794
|
916
|
|
795
|
917
|
@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
|
796
|
918
|
"userAuth=String.valueOf(result.isAuth())", "userEmail=result.getEmail()==null?\"\":result.getEmail()",
|