|
@ -29,6 +29,8 @@ import org.jfw.util.state.StateCode;
|
29
|
29
|
|
30
|
30
|
import com.ekexiu.portal.dao.OrgDao;
|
31
|
31
|
import com.ekexiu.portal.dao.OrgUserDao;
|
|
32
|
import com.ekexiu.portal.dao.PaperAuthorDao;
|
|
33
|
import com.ekexiu.portal.dao.PatentAuthorDao;
|
32
|
34
|
import com.ekexiu.portal.dao.ProfessorDao;
|
33
|
35
|
import com.ekexiu.portal.dao.UserDao;
|
34
|
36
|
import com.ekexiu.portal.dao.UserOpenIdDao;
|
|
@ -74,6 +76,11 @@ public class SysService {
|
74
|
76
|
@Autowrie
|
75
|
77
|
private UserOpenIdDao userOpenIdDao;
|
76
|
78
|
|
|
79
|
@Autowrie
|
|
80
|
private PatentAuthorDao patentAuthorDao;
|
|
81
|
@Autowrie
|
|
82
|
private PaperAuthorDao paperAuthorDao;
|
|
83
|
|
77
|
84
|
private String bindMailSubject;
|
78
|
85
|
|
79
|
86
|
private String bindMailReplaceKey;
|
|
@ -143,6 +150,22 @@ public class SysService {
|
143
|
150
|
private String retrieveOrgFailTempalte;
|
144
|
151
|
private String retrieveOrgFailSubject;
|
145
|
152
|
|
|
153
|
public PatentAuthorDao getPatentAuthorDao() {
|
|
154
|
return patentAuthorDao;
|
|
155
|
}
|
|
156
|
|
|
157
|
public void setPatentAuthorDao(PatentAuthorDao patentAuthorDao) {
|
|
158
|
this.patentAuthorDao = patentAuthorDao;
|
|
159
|
}
|
|
160
|
|
|
161
|
public PaperAuthorDao getPaperAuthorDao() {
|
|
162
|
return paperAuthorDao;
|
|
163
|
}
|
|
164
|
|
|
165
|
public void setPaperAuthorDao(PaperAuthorDao paperAuthorDao) {
|
|
166
|
this.paperAuthorDao = paperAuthorDao;
|
|
167
|
}
|
|
168
|
|
146
|
169
|
public String getRegMailReplaceKey() {
|
147
|
170
|
return regMailReplaceKey;
|
148
|
171
|
}
|
|
@ -753,7 +776,8 @@ public class SysService {
|
753
|
776
|
*/
|
754
|
777
|
@Post
|
755
|
778
|
@Path("/regmobile")
|
756
|
|
public String regMobile(@JdbcConn(true) Connection con, String state, String mobilePhone, String validateCode, String password, @Nullable String inviterId) throws SQLException, JfwBaseException {
|
|
779
|
public String regMobile(@JdbcConn(true) Connection con, String state, String mobilePhone, String validateCode, String password, @Nullable String inviterId)
|
|
780
|
throws SQLException, JfwBaseException {
|
757
|
781
|
@SuppressWarnings("unchecked")
|
758
|
782
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
|
759
|
783
|
if (sc == null || sc.getExpiredTime() < System.currentTimeMillis())
|
|
@ -833,7 +857,7 @@ public class SysService {
|
833
|
857
|
@Post
|
834
|
858
|
@Path("/mobileReg")
|
835
|
859
|
public String mobileReg(@JdbcConn(true) Connection con, String state, String mobilePhone, String validateCode, String password, @Nullable String inviterId,
|
836
|
|
String name, @Nullable String oauthType, @Nullable String openid, @Nullable String authCode) throws SQLException, JfwBaseException, IOException {
|
|
860
|
String name, @Nullable String oauthType, @Nullable String openid, @Nullable String authCode) throws SQLException, JfwBaseException, IOException {
|
837
|
861
|
@SuppressWarnings("unchecked")
|
838
|
862
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
|
839
|
863
|
if (sc == null || sc.getExpiredTime() < System.currentTimeMillis())
|
|
@ -868,6 +892,144 @@ public class SysService {
|
868
|
892
|
}
|
869
|
893
|
}
|
870
|
894
|
|
|
895
|
@Post
|
|
896
|
@Path("/regAndAssPatent")
|
|
897
|
public boolean assPatent(@JdbcConn(true) Connection con, String state, String phone, String vc, @Nullable String inviterId, String name, String patent)
|
|
898
|
throws SQLException, JfwBaseException, IOException {
|
|
899
|
@SuppressWarnings("unchecked")
|
|
900
|
StateCode<String, String> sc = (StateCode<String, String>)
|
|
901
|
JfwAppContext.getCachedObject(state);
|
|
902
|
if (sc == null || sc.getExpiredTime() < System.currentTimeMillis())
|
|
903
|
throw new JfwBaseException(-1, "验证超时");
|
|
904
|
if (!sc.getKey().equals(phone)) {
|
|
905
|
throw new JfwBaseException(-2, "手机号与验证手机不匹配");
|
|
906
|
}
|
|
907
|
if (!sc.getValue().equals(vc)) {
|
|
908
|
throw new JfwBaseException(-3, "验证码错误");
|
|
909
|
}
|
|
910
|
User user = null;
|
|
911
|
boolean exists = false;
|
|
912
|
String uid = StringUtil.buildUUID();
|
|
913
|
try {
|
|
914
|
try {
|
|
915
|
user = new User();
|
|
916
|
user.setId(uid);
|
|
917
|
String passwd = StringUtil.md5("123456");
|
|
918
|
user.setMobilePhone(phone);
|
|
919
|
user.setPasswd(passwd);
|
|
920
|
user.setUserType("0");
|
|
921
|
user.setInviterId(inviterId);
|
|
922
|
user.setActiveTime(DATE.format(new Date()));
|
|
923
|
this.userDao.insert(con, user);
|
|
924
|
} catch (SQLException e) {
|
|
925
|
if ("23505".equals(e.getSQLState())) {
|
|
926
|
con.rollback();
|
|
927
|
user = userDao.queryByEmailOrMobilePhone(con, phone);
|
|
928
|
if (user == null)
|
|
929
|
throw new RuntimeException("not fonud with query user by phone");
|
|
930
|
exists = true;
|
|
931
|
uid = user.getId();
|
|
932
|
} else {
|
|
933
|
throw e;
|
|
934
|
}
|
|
935
|
}
|
|
936
|
if (exists) {
|
|
937
|
Professor professor = this.professorDao.query(con, uid);
|
|
938
|
if (professor == null) {
|
|
939
|
professor = new Professor();
|
|
940
|
professor.setId(uid);
|
|
941
|
professor.setName(name);
|
|
942
|
professor.setPhone(phone);
|
|
943
|
this.professorService.insert(con, professor, null);
|
|
944
|
} else {
|
|
945
|
name = professor.getName();
|
|
946
|
}
|
|
947
|
} else {
|
|
948
|
Professor professor = new Professor();
|
|
949
|
professor.setId(uid);
|
|
950
|
professor.setName(name);
|
|
951
|
professor.setPhone(phone);
|
|
952
|
this.professorService.insert(con, professor, null);
|
|
953
|
if (inviterId != null) {
|
|
954
|
this.growthLogService.invite(con, inviterId, uid);
|
|
955
|
}
|
|
956
|
}
|
|
957
|
return this.patentAuthorDao.update(con, patent, uid, name) > 0;
|
|
958
|
|
|
959
|
} finally {
|
|
960
|
JfwAppContext.removeCachedObject(state);
|
|
961
|
}
|
|
962
|
}
|
|
963
|
|
|
964
|
@Post
|
|
965
|
@Path("/regAndAssPaper")
|
|
966
|
public boolean assPaper(@JdbcConn(true) Connection con, String state, String phone, String vc, @Nullable String inviterId, String name, String paper)
|
|
967
|
throws SQLException, JfwBaseException, IOException {
|
|
968
|
@SuppressWarnings("unchecked")
|
|
969
|
StateCode<String, String> sc = (StateCode<String, String>)
|
|
970
|
JfwAppContext.getCachedObject(state);
|
|
971
|
if (sc == null || sc.getExpiredTime() < System.currentTimeMillis())
|
|
972
|
throw new JfwBaseException(-1, "验证超时");
|
|
973
|
if (!sc.getKey().equals(phone)) {
|
|
974
|
throw new JfwBaseException(-2, "手机号与验证手机不匹配");
|
|
975
|
}
|
|
976
|
if (!sc.getValue().equals(vc)) {
|
|
977
|
throw new JfwBaseException(-3, "验证码错误");
|
|
978
|
}
|
|
979
|
User user = null;
|
|
980
|
boolean exists = false;
|
|
981
|
String uid = StringUtil.buildUUID();
|
|
982
|
try {
|
|
983
|
try {
|
|
984
|
user = new User();
|
|
985
|
user.setId(uid);
|
|
986
|
String passwd = StringUtil.md5("123456");
|
|
987
|
user.setMobilePhone(phone);
|
|
988
|
user.setPasswd(passwd);
|
|
989
|
user.setUserType("0");
|
|
990
|
user.setInviterId(inviterId);
|
|
991
|
user.setActiveTime(DATE.format(new Date()));
|
|
992
|
this.userDao.insert(con, user);
|
|
993
|
} catch (SQLException e) {
|
|
994
|
if ("23505".equals(e.getSQLState())) {
|
|
995
|
con.rollback();
|
|
996
|
user = userDao.queryByEmailOrMobilePhone(con, phone);
|
|
997
|
if (user == null)
|
|
998
|
throw new RuntimeException("not fonud with query user by phone");
|
|
999
|
exists = true;
|
|
1000
|
uid = user.getId();
|
|
1001
|
} else {
|
|
1002
|
throw e;
|
|
1003
|
}
|
|
1004
|
}
|
|
1005
|
if (exists) {
|
|
1006
|
Professor professor = this.professorDao.query(con, uid);
|
|
1007
|
if (professor == null) {
|
|
1008
|
professor = new Professor();
|
|
1009
|
professor.setId(uid);
|
|
1010
|
professor.setName(name);
|
|
1011
|
professor.setPhone(phone);
|
|
1012
|
this.professorService.insert(con, professor, null);
|
|
1013
|
} else {
|
|
1014
|
name = professor.getName();
|
|
1015
|
}
|
|
1016
|
} else {
|
|
1017
|
Professor professor = new Professor();
|
|
1018
|
professor.setId(uid);
|
|
1019
|
professor.setName(name);
|
|
1020
|
professor.setPhone(phone);
|
|
1021
|
this.professorService.insert(con, professor, null);
|
|
1022
|
if (inviterId != null) {
|
|
1023
|
this.growthLogService.invite(con, inviterId, uid);
|
|
1024
|
}
|
|
1025
|
}
|
|
1026
|
return this.paperAuthorDao.update(con, paper, uid, name) > 0;
|
|
1027
|
|
|
1028
|
} finally {
|
|
1029
|
JfwAppContext.removeCachedObject(state);
|
|
1030
|
}
|
|
1031
|
}
|
|
1032
|
|
871
|
1033
|
/**
|
872
|
1034
|
* 邮箱验证并注册
|
873
|
1035
|
*
|
|
@ -1288,7 +1450,7 @@ public class SysService {
|
1288
|
1450
|
}
|
1289
|
1451
|
|
1290
|
1452
|
@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
|
1291
|
|
"userEmail=result.getEmail()==null?\"\":result.getEmail()","authentication=result.getAuthentication()==null?\"\":result.getAuthentication()",
|
|
1453
|
"userEmail=result.getEmail()==null?\"\":result.getEmail()", "authentication=result.getAuthentication()==null?\"\":result.getAuthentication()",
|
1292
|
1454
|
"userAuth=String.valueOf(result.isAuth())", "userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
|
1293
|
1455
|
@Post
|
1294
|
1456
|
@Path("/invitelogin")
|
|
@ -1308,14 +1470,14 @@ public class SysService {
|
1308
|
1470
|
ret.setEmail(user.getEmail());
|
1309
|
1471
|
if (professor != null) {
|
1310
|
1472
|
ret.setName(professor.getName());
|
1311
|
|
ret.setAuthentication(professor.getAuthentication()+"");
|
|
1473
|
ret.setAuthentication(professor.getAuthentication() + "");
|
1312
|
1474
|
}
|
1313
|
1475
|
ret.setAuth(!DEFAULT_PASS_WORD.equals(user.getPasswd()));
|
1314
|
1476
|
return ret;
|
1315
|
1477
|
}
|
1316
|
1478
|
|
1317
|
1479
|
@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
|
1318
|
|
"userEmail=result.getEmail()==null?\"\":result.getEmail()","authentication=result.getAuthentication()==null?\"\":result.getAuthentication()",
|
|
1480
|
"userEmail=result.getEmail()==null?\"\":result.getEmail()", "authentication=result.getAuthentication()==null?\"\":result.getAuthentication()",
|
1319
|
1481
|
"userAuth=String.valueOf(result.isAuth())", "userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
|
1320
|
1482
|
@Post
|
1321
|
1483
|
@Path("/slogin")
|
|
@ -1331,16 +1493,16 @@ public class SysService {
|
1331
|
1493
|
ret.setMobilePhone(mobile);
|
1332
|
1494
|
ret.setType(user.getUserType());
|
1333
|
1495
|
ret.setEmail(user.getEmail());
|
1334
|
|
if(professor != null){
|
|
1496
|
if (professor != null) {
|
1335
|
1497
|
ret.setName(professor.getName());
|
1336
|
|
ret.setAuthentication(professor.getAuthentication()+"");
|
|
1498
|
ret.setAuthentication(professor.getAuthentication() + "");
|
1337
|
1499
|
}
|
1338
|
1500
|
ret.setAuth(!DEFAULT_PASS_WORD.equals(user.getPasswd()));
|
1339
|
1501
|
return ret;
|
1340
|
1502
|
}
|
1341
|
1503
|
|
1342
|
1504
|
@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
|
1343
|
|
"userEmail=result.getEmail()==null?\"\":result.getEmail()","authentication=result.getAuthentication()==null?\"\":result.getAuthentication()",
|
|
1505
|
"userEmail=result.getEmail()==null?\"\":result.getEmail()", "authentication=result.getAuthentication()==null?\"\":result.getAuthentication()",
|
1344
|
1506
|
"userAuth=String.valueOf(result.isAuth())", "userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
|
1345
|
1507
|
@Post
|
1346
|
1508
|
@Path("/login")
|
|
@ -1358,7 +1520,7 @@ public class SysService {
|
1358
|
1520
|
Professor pf = this.professorDao.query(con, user.getId());
|
1359
|
1521
|
if (null != pf) {
|
1360
|
1522
|
ret.setName(pf.getName());
|
1361
|
|
ret.setAuthentication(pf.getAuthentication()+"");
|
|
1523
|
ret.setAuthentication(pf.getAuthentication() + "");
|
1362
|
1524
|
}
|
1363
|
1525
|
ret.setMobilePhone(user.getMobilePhone());
|
1364
|
1526
|
ret.setType(user.getUserType());
|
|
@ -1368,7 +1530,7 @@ public class SysService {
|
1368
|
1530
|
}
|
1369
|
1531
|
|
1370
|
1532
|
@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
|
1371
|
|
"userEmail=result.getEmail()==null?\"\":result.getEmail()","authentication=result.getAuthentication()==null?\"\":result.getAuthentication()",
|
|
1533
|
"userEmail=result.getEmail()==null?\"\":result.getEmail()", "authentication=result.getAuthentication()==null?\"\":result.getAuthentication()",
|
1372
|
1534
|
"userAuth=String.valueOf(result.isAuth())", "userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
|
1373
|
1535
|
@Post
|
1374
|
1536
|
@Path("/mobileLogin")
|
|
@ -1394,7 +1556,7 @@ public class SysService {
|
1394
|
1556
|
Professor professor = this.professorDao.query(con, user.getId());
|
1395
|
1557
|
if (null != professor) {
|
1396
|
1558
|
ret.setName(professor.getName());
|
1397
|
|
ret.setAuthentication(professor.getAuthentication()+"");
|
|
1559
|
ret.setAuthentication(professor.getAuthentication() + "");
|
1398
|
1560
|
}
|
1399
|
1561
|
ret.setMobilePhone(user.getMobilePhone());
|
1400
|
1562
|
ret.setType(user.getUserType());
|
|
@ -1406,8 +1568,8 @@ public class SysService {
|
1406
|
1568
|
}
|
1407
|
1569
|
}
|
1408
|
1570
|
|
1409
|
|
@SetCookie(checkResultNull = true, path = "/", value = { "orgId=result.getId()", "orgType=result.getType()",
|
1410
|
|
"orgAuth=String.valueOf(result.isAuth())","orgEmail=result.getEmail()==null?\"\":result.getEmail()",
|
|
1571
|
@SetCookie(checkResultNull = true, path = "/", value = { "orgId=result.getId()", "orgType=result.getType()", "orgAuth=String.valueOf(result.isAuth())",
|
|
1572
|
"orgEmail=result.getEmail()==null?\"\":result.getEmail()",
|
1411
|
1573
|
"orgName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
|
1412
|
1574
|
@Post
|
1413
|
1575
|
@Path("/orgLogin")
|