|
@ -56,11 +56,15 @@ public class SysService {
|
56
|
56
|
@Autowrie
|
57
|
57
|
private ProfessorDao professorDao;
|
58
|
58
|
@Autowrie
|
|
59
|
private ProfessorService professorService;
|
|
60
|
@Autowrie
|
59
|
61
|
private MailService mailservice;
|
60
|
62
|
@Autowrie
|
61
|
63
|
private MobilePhoneService mobilePhoneServcie;
|
62
|
64
|
@Autowrie
|
63
|
65
|
private GrowthLogService growthLogService;
|
|
66
|
@Autowrie
|
|
67
|
private GrowthRuleService rule;
|
64
|
68
|
|
65
|
69
|
private String bindMailSubject;
|
66
|
70
|
|
|
@ -227,6 +231,14 @@ public class SysService {
|
227
|
231
|
this.growthLogService = growthLogService;
|
228
|
232
|
}
|
229
|
233
|
|
|
234
|
public GrowthRuleService getRule() {
|
|
235
|
return rule;
|
|
236
|
}
|
|
237
|
|
|
238
|
public void setRule(GrowthRuleService rule) {
|
|
239
|
this.rule = rule;
|
|
240
|
}
|
|
241
|
|
230
|
242
|
public String getPhoneRetrievePasswordReplaceKey() {
|
231
|
243
|
return phoneRetrievePasswordReplaceKey;
|
232
|
244
|
}
|
|
@ -515,6 +527,14 @@ public class SysService {
|
515
|
527
|
this.professorDao = professorDao;
|
516
|
528
|
}
|
517
|
529
|
|
|
530
|
public ProfessorService getProfessorService() {
|
|
531
|
return professorService;
|
|
532
|
}
|
|
533
|
|
|
534
|
public void setProfessorService(ProfessorService professorService) {
|
|
535
|
this.professorService = professorService;
|
|
536
|
}
|
|
537
|
|
518
|
538
|
public MailService getMailservice() {
|
519
|
539
|
return mailservice;
|
520
|
540
|
}
|
|
@ -739,6 +759,43 @@ public class SysService {
|
739
|
759
|
JfwAppContext.removeCachedObject(state);
|
740
|
760
|
}
|
741
|
761
|
}
|
|
762
|
|
|
763
|
@Post
|
|
764
|
@Path("/mobileReg")
|
|
765
|
public String mobileReg(@JdbcConn(true) Connection con, String state, String mobilePhone, String validateCode,
|
|
766
|
String password, @Nullable String inviterId, String name)throws SQLException, JfwBaseException, IOException {
|
|
767
|
@SuppressWarnings("unchecked")
|
|
768
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
|
|
769
|
if (sc == null || sc.getExpiredTime() < System.currentTimeMillis())
|
|
770
|
throw new JfwBaseException(-1, "验证超时");
|
|
771
|
try {
|
|
772
|
if (!sc.getKey().equals(mobilePhone)) {
|
|
773
|
throw new JfwBaseException(-2, "手机号与验证手机不匹配");
|
|
774
|
}
|
|
775
|
if (!sc.getValue().equals(validateCode)) {
|
|
776
|
throw new JfwBaseException(-3, "验证码错误");
|
|
777
|
}
|
|
778
|
User user = new User();
|
|
779
|
user.setId(StringUtil.buildUUID());
|
|
780
|
String passwd = StringUtil.md5(password);
|
|
781
|
user.setMobilePhone(mobilePhone);
|
|
782
|
user.setPasswd(passwd);
|
|
783
|
user.setUserType("0");
|
|
784
|
user.setInviterId(inviterId);
|
|
785
|
user.setActiveTime(DATE.format(new Date()));
|
|
786
|
this.userDao.insert(con, user);
|
|
787
|
if(inviterId != null){
|
|
788
|
this.growthLogService.invite(con, inviterId, user.getId());
|
|
789
|
}
|
|
790
|
Professor professor = new Professor();
|
|
791
|
professor.setId(user.getId());
|
|
792
|
professor.setName(name);
|
|
793
|
this.professorService.insert(con, professor, null);
|
|
794
|
return user.getId();
|
|
795
|
} finally {
|
|
796
|
JfwAppContext.removeCachedObject(state);
|
|
797
|
}
|
|
798
|
}
|
742
|
799
|
|
743
|
800
|
/**
|
744
|
801
|
* 邮箱验证并注册
|
|
@ -786,6 +843,46 @@ public class SysService {
|
786
|
843
|
JfwAppContext.removeCachedObject(key);
|
787
|
844
|
}
|
788
|
845
|
}
|
|
846
|
|
|
847
|
@Get
|
|
848
|
@Path("/mailReg")
|
|
849
|
public void emailReg(@JdbcConn(false) Connection con, String key) throws SQLException, JfwBaseException, IOException {
|
|
850
|
@SuppressWarnings("unchecked")
|
|
851
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(key);
|
|
852
|
if (sc == null || sc.getExpiredTime() < System.currentTimeMillis()) {
|
|
853
|
throw new JfwBaseException(-1, "验证链接已失效");
|
|
854
|
}
|
|
855
|
try {
|
|
856
|
User user = new User();
|
|
857
|
user.setEmail(sc.getCode());
|
|
858
|
user.setId(StringUtil.buildUUID());
|
|
859
|
user.setSendMailStatus(0);
|
|
860
|
user.setPasswd(StringUtil.md5(sc.getKey()));
|
|
861
|
user.setUserType("0");
|
|
862
|
user.setInviterId(sc.getValue());
|
|
863
|
user.setActiveTime(DATE.format(new Date()));
|
|
864
|
this.userDao.insert(con, user);
|
|
865
|
if(sc.getValue() != null){
|
|
866
|
this.growthLogService.invite(con, sc.getValue(), user.getId());
|
|
867
|
}
|
|
868
|
Professor professor = new Professor();
|
|
869
|
professor.setId(user.getId());
|
|
870
|
professor.setName(sc.getDescp());
|
|
871
|
this.professorService.insert(con, professor, null);
|
|
872
|
con.commit();
|
|
873
|
} catch (SQLException e) {
|
|
874
|
try {
|
|
875
|
con.rollback();
|
|
876
|
} catch (Exception ee) {
|
|
877
|
}
|
|
878
|
if ("23505".equals(e.getSQLState())) {
|
|
879
|
throw new JfwBaseException(-3, "邮箱[" + sc.getCode() + "]已被注册过了");
|
|
880
|
}
|
|
881
|
throw e;
|
|
882
|
} finally {
|
|
883
|
JfwAppContext.removeCachedObject(key);
|
|
884
|
}
|
|
885
|
}
|
789
|
886
|
|
790
|
887
|
/**
|
791
|
888
|
* 发送邮箱注册验证邮件
|
|
@ -830,6 +927,39 @@ public class SysService {
|
830
|
927
|
}
|
831
|
928
|
}
|
832
|
929
|
|
|
930
|
@Post
|
|
931
|
@Path("/emailReg")
|
|
932
|
public void emailReg(@JdbcConn(false) Connection con,String mail,String password,@Nullable String inviterId,String name)throws JfwBaseException, SQLException {
|
|
933
|
User user = this.userDao.queryByEmailOrMobilePhone(con, mail);
|
|
934
|
if (null != user) {
|
|
935
|
throw new JfwBaseException(-1, "邮箱[" + mail + "]已被注册过了");
|
|
936
|
} else {
|
|
937
|
|
|
938
|
StateCode<String, String> sc = new StateCode<String, String>();
|
|
939
|
final String key = JfwAppContext.cacheObjectAndGenKey(sc);
|
|
940
|
Map<String, String> map = new HashMap<>();
|
|
941
|
map.put(this.regMailReplaceKey, key);
|
|
942
|
try {
|
|
943
|
this.mailservice.sendSimpleMail(mail, this.regMailReplaceContentTempalte, map, this.regMailSubject);
|
|
944
|
} catch (MessagingException e) {
|
|
945
|
JfwAppContext.removeCachedObject(key);
|
|
946
|
throw new JfwBaseException(-2, "给邮箱[" + mail + "]发邮件错误", e);
|
|
947
|
}
|
|
948
|
sc.setCode(mail);
|
|
949
|
sc.setKey(password);
|
|
950
|
sc.setValue(inviterId);
|
|
951
|
sc.setDescp(name);
|
|
952
|
sc.setBuildTime(System.currentTimeMillis());
|
|
953
|
sc.setExpiredTime(sc.getBuildTime() + this.timeLimitWithRegMail);
|
|
954
|
JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
|
|
955
|
@Override
|
|
956
|
public void run() {
|
|
957
|
JfwAppContext.removeCachedObject(key);
|
|
958
|
}
|
|
959
|
}, this.timeLimitWithRegMail, TimeUnit.MILLISECONDS);
|
|
960
|
}
|
|
961
|
}
|
|
962
|
|
833
|
963
|
/**
|
834
|
964
|
* 验证企业邮箱并注册企业账号
|
835
|
965
|
* @param con
|
|
@ -995,12 +1125,27 @@ public class SysService {
|
995
|
1125
|
user.setPasswd(StringUtil.md5(passwd));
|
996
|
1126
|
user.setUserType("0");
|
997
|
1127
|
user.setActiveTime(DATE.format(new Date()));
|
|
1128
|
this.userDao.insert(con, user);
|
998
|
1129
|
Professor professor = new Professor();
|
999
|
1130
|
professor.setId(id);
|
1000
|
1131
|
professor.setName(name);
|
1001
|
1132
|
professor.setOrgId(stateCode.getKey());
|
1002
|
1133
|
professor.setOrgAuth("1");
|
1003
|
|
this.userDao.insert(con, user);
|
|
1134
|
professor.setPhone(user.getMobilePhone());
|
|
1135
|
professor.setEmail(user.getEmail());
|
|
1136
|
int value = 0;
|
|
1137
|
if(user.getMobilePhone() != null && user.getMobilePhone().trim().length() == 11){
|
|
1138
|
professor.setPhone(user.getMobilePhone());
|
|
1139
|
value = value + this.rule.getBindMobile();
|
|
1140
|
this.growthLogService.firstBindMobile(con, professor.getId());
|
|
1141
|
}
|
|
1142
|
if(user.getEmail() != null && !"".equals(user.getEmail())){
|
|
1143
|
professor.setEmail(user.getEmail());
|
|
1144
|
value = value + this.rule.getBindEmail();
|
|
1145
|
this.growthLogService.firstBindEmail(con, professor.getId());
|
|
1146
|
}
|
|
1147
|
professor.setScoreValue(value);
|
|
1148
|
professor.setGrowthValue(value);
|
1004
|
1149
|
this.professorDao.insert(con, professor);
|
1005
|
1150
|
SessionUser ret = new SessionUser();
|
1006
|
1151
|
ret.setMobilePhone(phone);
|