ソースを参照

--优化代码;

zzy.zhiyuan.foxmail 8 年 前
コミット
6ec4160267

+ 65 - 13
src/main/java/com/ekexiu/portal/dao/ProfessorDao.java

206
                    organization.setName(orgName);
206
                    organization.setName(orgName);
207
                    professor.setOrganization(organization);
207
                    professor.setOrganization(organization);
208
                    professor.setTitle(rs.getString(5));
208
                    professor.setTitle(rs.getString(5));
209
                    professor.setAuthentication(rs.getInt(6));
209
                    Integer auth = rs.getInt(6);
210
                    if(rs.wasNull()){
211
                    	auth = null;
212
                    }
213
                    professor.setAuthentication(auth);
210
                    professor.setAuthType(rs.getInt(7));
214
                    professor.setAuthType(rs.getInt(7));
211
                    professor.setAuthStatus(rs.getInt(8));
215
                    professor.setAuthStatus(rs.getInt(8));
212
                    professor.setId(rs.getString(9));
216
                    professor.setId(rs.getString(9));
240
            try{
244
            try{
241
                if(rs.next()){
245
                if(rs.next()){
242
                	Professor professor = new Professor();
246
                	Professor professor = new Professor();
243
                    professor.setAuthentication(rs.getInt(1));
247
                	Integer auth = rs.getInt(1);
248
                    if(rs.wasNull()){
249
                    	auth = null;
250
                    }
251
                    professor.setAuthentication(auth);
244
                    professor.setAuthType(rs.getInt(2));
252
                    professor.setAuthType(rs.getInt(2));
245
                    professor.setAuthStatus(rs.getInt(3));
253
                    professor.setAuthStatus(rs.getInt(3));
246
                    professor.setAuthStatusExpert(rs.getInt(4));
254
                    professor.setAuthStatusExpert(rs.getInt(4));
291
                    	title = null;
299
                    	title = null;
292
                	}
300
                	}
293
                    professor.setTitle(title);
301
                    professor.setTitle(title);
294
                    professor.setAuthentication(rs.getInt(4));
302
                    Integer auth = rs.getInt(4);
303
                    if(rs.wasNull()){
304
                    	auth = null;
305
                    }
306
                    professor.setAuthentication(auth);
295
                    professor.setAuthType(rs.getInt(5));
307
                    professor.setAuthType(rs.getInt(5));
296
                    professor.setAuthStatus(rs.getInt(6));
308
                    professor.setAuthStatus(rs.getInt(6));
297
                    professor.setId(rs.getString(7));
309
                    professor.setId(rs.getString(7));
363
                		title = null;
375
                		title = null;
364
                	}
376
                	}
365
                    professor.setTitle(title);
377
                    professor.setTitle(title);
366
                    professor.setAuthentication(rs.getInt(4));
378
                    Integer auth = rs.getInt(4);
379
                    if(rs.wasNull()){
380
                    	auth = null;
381
                    }
382
                    professor.setAuthentication(auth);
367
                    professor.setAuthType(rs.getInt(5));
383
                    professor.setAuthType(rs.getInt(5));
368
                    professor.setAuthStatus(rs.getInt(6));
384
                    professor.setAuthStatus(rs.getInt(6));
369
                    professor.setId(rs.getString(7));
385
                    professor.setId(rs.getString(7));
445
                    	title = null;
461
                    	title = null;
446
                    }
462
                    }
447
                    professor.setTitle(title);
463
                    professor.setTitle(title);
448
                    professor.setAuthentication(rs.getInt(8));
464
                    Integer auth = rs.getInt(8);
465
                    if(rs.wasNull()){
466
                    	auth = null;
467
                    }
468
                    professor.setAuthentication(auth);
449
                    professor.setAuthType(rs.getInt(9));
469
                    professor.setAuthType(rs.getInt(9));
450
                    professor.setAuthStatus(rs.getInt(10));
470
                    professor.setAuthStatus(rs.getInt(10));
451
                    professor.setId(rs.getString(11));
471
                    professor.setId(rs.getString(11));
536
                    organization.setName(orgName);
556
                    organization.setName(orgName);
537
                    professor.setOrganization(organization);
557
                    professor.setOrganization(organization);
538
                    professor.setTitle(rs.getString(9));
558
                    professor.setTitle(rs.getString(9));
539
                    professor.setAuthentication(rs.getInt(10));
559
                    Integer auth = rs.getInt(10);
560
                    if(rs.wasNull()){
561
                    	auth = null;
562
                    }
563
                    professor.setAuthentication(auth);
540
                    professor.setAuthType(rs.getInt(11));
564
                    professor.setAuthType(rs.getInt(11));
541
                    professor.setAuthStatus(rs.getInt(12));
565
                    professor.setAuthStatus(rs.getInt(12));
542
                    professor.setId(rs.getString(13));
566
                    professor.setId(rs.getString(13));
649
                    	title = null;
673
                    	title = null;
650
                	}
674
                	}
651
                    professor.setTitle(title);
675
                    professor.setTitle(title);
652
                    professor.setAuthentication(rs.getInt(4));
676
                    Integer auth = rs.getInt(4);
677
                    if(rs.wasNull()){
678
                    	auth = null;
679
                    }
680
                    professor.setAuthentication(auth);
653
                    professor.setAuthType(rs.getInt(5));
681
                    professor.setAuthType(rs.getInt(5));
654
                    professor.setAuthStatus(rs.getInt(6));
682
                    professor.setAuthStatus(rs.getInt(6));
655
                    professor.setId(rs.getString(7));
683
                    professor.setId(rs.getString(7));
707
                    	title = null;
735
                    	title = null;
708
                	}
736
                	}
709
                    professor.setTitle(title);
737
                    professor.setTitle(title);
710
                    professor.setAuthentication(rs.getInt(4));
738
                    Integer auth = rs.getInt(4);
739
                    if(rs.wasNull()){
740
                    	auth = null;
741
                    }
742
                    professor.setAuthentication(auth);
711
                    professor.setAuthType(rs.getInt(5));
743
                    professor.setAuthType(rs.getInt(5));
712
                    professor.setAuthStatus(rs.getInt(6));
744
                    professor.setAuthStatus(rs.getInt(6));
713
                    professor.setId(rs.getString(7));
745
                    professor.setId(rs.getString(7));
915
                    	title = null;
947
                    	title = null;
916
                    }
948
                    }
917
                    professor.setTitle(title);
949
                    professor.setTitle(title);
918
                    professor.setAuthentication(rs.getInt(4));
950
                    Integer auth = rs.getInt(4);
951
                    if(rs.wasNull()){
952
                    	auth = null;
953
                    }
954
                    professor.setAuthentication(auth);
919
                    professor.setAuthType(rs.getInt(5));
955
                    professor.setAuthType(rs.getInt(5));
920
                    professor.setAuthStatus(rs.getInt(6));
956
                    professor.setAuthStatus(rs.getInt(6));
921
                    professor.setId(rs.getString(7));
957
                    professor.setId(rs.getString(7));
1126
                    	title = null;
1162
                    	title = null;
1127
                    }
1163
                    }
1128
                    professor.setTitle(title);
1164
                    professor.setTitle(title);
1129
                    professor.setAuthentication(rs.getInt(4));
1165
                    Integer auth = rs.getInt(4);
1166
                    if(rs.wasNull()){
1167
                    	auth = null;
1168
                    }
1169
                    professor.setAuthentication(auth);
1130
                    professor.setAuthType(rs.getInt(5));
1170
                    professor.setAuthType(rs.getInt(5));
1131
                    professor.setAuthStatus(rs.getInt(6));
1171
                    professor.setAuthStatus(rs.getInt(6));
1132
                    professor.setId(rs.getString(7));
1172
                    professor.setId(rs.getString(7));
1346
						title = null;
1386
						title = null;
1347
					}
1387
					}
1348
					professor.setTitle(title);
1388
					professor.setTitle(title);
1349
					professor.setAuthentication(rs.getInt(8));
1389
					Integer auth = rs.getInt(8);
1390
                    if(rs.wasNull()){
1391
                    	auth = null;
1392
                    }
1393
                    professor.setAuthentication(auth);
1350
					professor.setAuthType(rs.getInt(9));
1394
					professor.setAuthType(rs.getInt(9));
1351
					professor.setAuthStatus(rs.getInt(10));
1395
					professor.setAuthStatus(rs.getInt(10));
1352
					professor.setId(rs.getString(11));
1396
					professor.setId(rs.getString(11));
1546
						title = null;
1590
						title = null;
1547
					}
1591
					}
1548
					professor.setTitle(title);
1592
					professor.setTitle(title);
1549
					professor.setAuthentication(rs.getInt(9));
1593
					Integer auth = rs.getInt(9);
1594
                    if(rs.wasNull()){
1595
                    	auth = null;
1596
                    }
1597
                    professor.setAuthentication(auth);
1550
					professor.setId(rs.getString(10));
1598
					professor.setId(rs.getString(10));
1551
					professor.setName(rs.getString(11));
1599
					professor.setName(rs.getString(11));
1552
					String descp = rs.getString(12);
1600
					String descp = rs.getString(12);
1751
						title = null;
1799
						title = null;
1752
					}
1800
					}
1753
					userInfo.setTitle(title);
1801
					userInfo.setTitle(title);
1754
					userInfo.setAuthentication(rs.getInt(8));
1802
					Integer auth = rs.getInt(8);
1803
					if(rs.wasNull()){
1804
						auth = null;
1805
					}
1806
					userInfo.setAuthentication(auth);
1755
					userInfo.setAuthType(rs.getInt(9));
1807
					userInfo.setAuthType(rs.getInt(9));
1756
					userInfo.setAuthStatus(rs.getInt(10));
1808
					userInfo.setAuthStatus(rs.getInt(10));
1757
					userInfo.setId(rs.getString(11));
1809
					userInfo.setId(rs.getString(11));

+ 7 - 4
src/main/java/com/ekexiu/portal/oauth/OAuthService.java

19
import com.ekexiu.portal.dao.ProfessorDao;
19
import com.ekexiu.portal.dao.ProfessorDao;
20
import com.ekexiu.portal.dao.UserDao;
20
import com.ekexiu.portal.dao.UserDao;
21
import com.ekexiu.portal.dao.UserOpenIdDao;
21
import com.ekexiu.portal.dao.UserOpenIdDao;
22
import com.ekexiu.portal.po.Professor;
22
import com.ekexiu.portal.po.User;
23
import com.ekexiu.portal.po.User;
23
import com.ekexiu.portal.po.UserOpenId;
24
import com.ekexiu.portal.po.UserOpenId;
24
import com.ekexiu.portal.pojo.SessionUser;
25
import com.ekexiu.portal.pojo.SessionUser;
125
		JfwAppContext.removeCachedObject(authCode);
126
		JfwAppContext.removeCachedObject(authCode);
126
		SessionUser ret = new SessionUser();
127
		SessionUser ret = new SessionUser();
127
		ret.setId(user.getId());
128
		ret.setId(user.getId());
128
		if (null != this.professorDao.query(con, user.getId())) {
129
			ret.setName(this.professorDao.query(con, user.getId()).getName());
129
		Professor professor = this.professorDao.queryOne(con, user.getId());
130
		if (null != professor) {
131
			ret.setName(professor.getName());
130
		}
132
		}
131
		ret.setMobilePhone(user.getMobilePhone());
133
		ret.setMobilePhone(user.getMobilePhone());
132
		ret.setType(user.getUserType());
134
		ret.setType(user.getUserType());
150
			if (user != null) {
152
			if (user != null) {
151
				SessionUser ret = new SessionUser();
153
				SessionUser ret = new SessionUser();
152
				ret.setId(user.getId());
154
				ret.setId(user.getId());
153
				if (null != this.professorDao.query(con, user.getId())) {
154
					ret.setName(this.professorDao.query(con, user.getId()).getName());
155
				Professor professor = this.professorDao.queryOne(con, user.getId());
156
				if (null != professor) {
157
					ret.setName(professor.getName());
155
				}
158
				}
156
				ret.setMobilePhone(user.getMobilePhone());
159
				ret.setMobilePhone(user.getMobilePhone());
157
				ret.setType(user.getUserType());
160
				ret.setType(user.getUserType());

+ 22 - 16
src/main/java/com/ekexiu/portal/service/SysService.java

861
			Professor professor = new Professor();
861
			Professor professor = new Professor();
862
			professor.setId(user.getId());
862
			professor.setId(user.getId());
863
			professor.setName(name);
863
			professor.setName(name);
864
			professor.setAuthentication(-1);
865
			this.professorService.insert(con, professor, null);
864
			this.professorService.insert(con, professor, null);
866
			return user.getId();
865
			return user.getId();
867
		} finally {
866
		} finally {
940
			Professor professor = new Professor();
939
			Professor professor = new Professor();
941
			professor.setId(user.getId());
940
			professor.setId(user.getId());
942
			professor.setName(sc.getDescp());
941
			professor.setName(sc.getDescp());
943
			professor.setAuthentication(-1);
944
			this.professorService.insert(con, professor, null);
942
			this.professorService.insert(con, professor, null);
945
			con.commit();
943
			con.commit();
946
		} catch (SQLException e) {
944
		} catch (SQLException e) {
1290
	}
1288
	}
1291
1289
1292
	@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
1290
	@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
1293
			"userAuth=String.valueOf(result.isAuth())", "userEmail=result.getEmail()==null?\"\":result.getEmail()",
1294
			"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
1291
			"userEmail=result.getEmail()==null?\"\":result.getEmail()","authentication=result.getAuthentication()==null?\"\":result.getAuthentication()",
1292
			"userAuth=String.valueOf(result.isAuth())", "userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
1295
	@Post
1293
	@Post
1296
	@Path("/invitelogin")
1294
	@Path("/invitelogin")
1297
	public SessionUser inviteLogin(@JdbcConn Connection con, String key, String code) throws SQLException {
1295
	public SessionUser inviteLogin(@JdbcConn Connection con, String key, String code) throws SQLException {
1302
		if (!user.getInviteCode().equals(code)) {
1300
		if (!user.getInviteCode().equals(code)) {
1303
			return null;
1301
			return null;
1304
		}
1302
		}
1305
		Professor professor = this.professorDao.query(con, user.getId());
1303
		Professor professor = this.professorDao.queryOne(con, user.getId());
1306
		SessionUser ret = new SessionUser();
1304
		SessionUser ret = new SessionUser();
1307
		ret.setId(user.getId());
1305
		ret.setId(user.getId());
1308
		ret.setMobilePhone(user.getMobilePhone());
1306
		ret.setMobilePhone(user.getMobilePhone());
1309
		ret.setType(user.getUserType());
1307
		ret.setType(user.getUserType());
1310
		ret.setEmail(user.getEmail());
1308
		ret.setEmail(user.getEmail());
1311
		ret.setName(professor.getName());
1309
		if (professor != null) {
1310
			ret.setName(professor.getName());
1311
			ret.setAuthentication(professor.getAuthentication()+"");
1312
		}
1312
		ret.setAuth(!DEFAULT_PASS_WORD.equals(user.getPasswd()));
1313
		ret.setAuth(!DEFAULT_PASS_WORD.equals(user.getPasswd()));
1313
		return ret;
1314
		return ret;
1314
	}
1315
	}
1315
1316
1316
	@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
1317
	@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
1317
			"userAuth=String.valueOf(result.isAuth())", "userEmail=result.getEmail()==null?\"\":result.getEmail()",
1318
			"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
1318
			"userEmail=result.getEmail()==null?\"\":result.getEmail()","authentication=result.getAuthentication()==null?\"\":result.getAuthentication()",
1319
			"userAuth=String.valueOf(result.isAuth())", "userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
1319
	@Post
1320
	@Post
1320
	@Path("/slogin")
1321
	@Path("/slogin")
1321
	public SessionUser sLogin(@JdbcConn Connection con, String code, String mobile) throws SQLException {
1322
	public SessionUser sLogin(@JdbcConn Connection con, String code, String mobile) throws SQLException {
1324
			return null;
1325
			return null;
1325
		if (!mobile.equals(user.getMobilePhone()))
1326
		if (!mobile.equals(user.getMobilePhone()))
1326
			return null;
1327
			return null;
1327
		Professor professor = this.professorDao.query(con, code);
1328
		Professor professor = this.professorDao.queryOne(con, code);
1328
		SessionUser ret = new SessionUser();
1329
		SessionUser ret = new SessionUser();
1329
		ret.setId(code);
1330
		ret.setId(code);
1330
		ret.setMobilePhone(mobile);
1331
		ret.setMobilePhone(mobile);
1331
		ret.setType(user.getUserType());
1332
		ret.setType(user.getUserType());
1332
		ret.setEmail(user.getEmail());
1333
		ret.setEmail(user.getEmail());
1333
		ret.setName(professor.getName());
1334
		if(professor != null){
1335
			ret.setName(professor.getName());
1336
			ret.setAuthentication(professor.getAuthentication()+"");
1337
		}
1334
		ret.setAuth(!DEFAULT_PASS_WORD.equals(user.getPasswd()));
1338
		ret.setAuth(!DEFAULT_PASS_WORD.equals(user.getPasswd()));
1335
		return ret;
1339
		return ret;
1336
	}
1340
	}
1337
1341
1338
	@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
1342
	@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
1339
			"userAuth=String.valueOf(result.isAuth())", "userEmail=result.getEmail()==null?\"\":result.getEmail()",
1340
			"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
1343
			"userEmail=result.getEmail()==null?\"\":result.getEmail()","authentication=result.getAuthentication()==null?\"\":result.getAuthentication()",
1344
			"userAuth=String.valueOf(result.isAuth())", "userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
1341
	@Post
1345
	@Post
1342
	@Path("/login")
1346
	@Path("/login")
1343
	public SessionUser login(@JdbcConn Connection con, String lk, String pw) throws SQLException, JfwBaseException {
1347
	public SessionUser login(@JdbcConn Connection con, String lk, String pw) throws SQLException, JfwBaseException {
1354
		Professor pf = this.professorDao.query(con, user.getId());
1358
		Professor pf = this.professorDao.query(con, user.getId());
1355
		if (null != pf) {
1359
		if (null != pf) {
1356
			ret.setName(pf.getName());
1360
			ret.setName(pf.getName());
1361
			ret.setAuthentication(pf.getAuthentication()+"");
1357
		}
1362
		}
1358
		ret.setMobilePhone(user.getMobilePhone());
1363
		ret.setMobilePhone(user.getMobilePhone());
1359
		ret.setType(user.getUserType());
1364
		ret.setType(user.getUserType());
1363
	}
1368
	}
1364
1369
1365
	@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
1370
	@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
1366
			"userAuth=String.valueOf(result.isAuth())", "userEmail=result.getEmail()==null?\"\":result.getEmail()",
1367
			"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
1371
			"userEmail=result.getEmail()==null?\"\":result.getEmail()","authentication=result.getAuthentication()==null?\"\":result.getAuthentication()",
1372
			"userAuth=String.valueOf(result.isAuth())", "userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
1368
	@Post
1373
	@Post
1369
	@Path("/mobileLogin")
1374
	@Path("/mobileLogin")
1370
	public SessionUser mobileLogin(@JdbcConn Connection con, String state, String mobilePhone, String validateCode) throws SQLException, JfwBaseException {
1375
	public SessionUser mobileLogin(@JdbcConn Connection con, String state, String mobilePhone, String validateCode) throws SQLException, JfwBaseException {
1389
			Professor professor = this.professorDao.query(con, user.getId());
1394
			Professor professor = this.professorDao.query(con, user.getId());
1390
			if (null != professor) {
1395
			if (null != professor) {
1391
				ret.setName(professor.getName());
1396
				ret.setName(professor.getName());
1397
				ret.setAuthentication(professor.getAuthentication()+"");
1392
			}
1398
			}
1393
			ret.setMobilePhone(user.getMobilePhone());
1399
			ret.setMobilePhone(user.getMobilePhone());
1394
			ret.setType(user.getUserType());
1400
			ret.setType(user.getUserType());
1400
		}
1406
		}
1401
	}
1407
	}
1402
1408
1403
	@SetCookie(checkResultNull = true, path = "/", value = { "orgId=result.getId()", "orgType=result.getType()", "orgAuth=String.valueOf(result.isAuth())",
1404
			"orgEmail=result.getEmail()==null?\"\":result.getEmail()",
1409
	@SetCookie(checkResultNull = true, path = "/", value = { "orgId=result.getId()", "orgType=result.getType()",
1410
			"orgAuth=String.valueOf(result.isAuth())","orgEmail=result.getEmail()==null?\"\":result.getEmail()",
1405
			"orgName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
1411
			"orgName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
1406
	@Post
1412
	@Post
1407
	@Path("/orgLogin")
1413
	@Path("/orgLogin")