ソースを参照

--优化代码;

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

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

@ -206,7 +206,11 @@ public abstract class ProfessorDao {
206 206
                    organization.setName(orgName);
207 207
                    professor.setOrganization(organization);
208 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 214
                    professor.setAuthType(rs.getInt(7));
211 215
                    professor.setAuthStatus(rs.getInt(8));
212 216
                    professor.setId(rs.getString(9));
@ -240,7 +244,11 @@ public abstract class ProfessorDao {
240 244
            try{
241 245
                if(rs.next()){
242 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 252
                    professor.setAuthType(rs.getInt(2));
245 253
                    professor.setAuthStatus(rs.getInt(3));
246 254
                    professor.setAuthStatusExpert(rs.getInt(4));
@ -291,7 +299,11 @@ public abstract class ProfessorDao {
291 299
                    	title = null;
292 300
                	}
293 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 307
                    professor.setAuthType(rs.getInt(5));
296 308
                    professor.setAuthStatus(rs.getInt(6));
297 309
                    professor.setId(rs.getString(7));
@ -363,7 +375,11 @@ public abstract class ProfessorDao {
363 375
                		title = null;
364 376
                	}
365 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 383
                    professor.setAuthType(rs.getInt(5));
368 384
                    professor.setAuthStatus(rs.getInt(6));
369 385
                    professor.setId(rs.getString(7));
@ -445,7 +461,11 @@ public abstract class ProfessorDao {
445 461
                    	title = null;
446 462
                    }
447 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 469
                    professor.setAuthType(rs.getInt(9));
450 470
                    professor.setAuthStatus(rs.getInt(10));
451 471
                    professor.setId(rs.getString(11));
@ -536,7 +556,11 @@ public abstract class ProfessorDao {
536 556
                    organization.setName(orgName);
537 557
                    professor.setOrganization(organization);
538 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 564
                    professor.setAuthType(rs.getInt(11));
541 565
                    professor.setAuthStatus(rs.getInt(12));
542 566
                    professor.setId(rs.getString(13));
@ -649,7 +673,11 @@ public abstract class ProfessorDao {
649 673
                    	title = null;
650 674
                	}
651 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 681
                    professor.setAuthType(rs.getInt(5));
654 682
                    professor.setAuthStatus(rs.getInt(6));
655 683
                    professor.setId(rs.getString(7));
@ -707,7 +735,11 @@ public abstract class ProfessorDao {
707 735
                    	title = null;
708 736
                	}
709 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 743
                    professor.setAuthType(rs.getInt(5));
712 744
                    professor.setAuthStatus(rs.getInt(6));
713 745
                    professor.setId(rs.getString(7));
@ -915,7 +947,11 @@ public abstract class ProfessorDao {
915 947
                    	title = null;
916 948
                    }
917 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 955
                    professor.setAuthType(rs.getInt(5));
920 956
                    professor.setAuthStatus(rs.getInt(6));
921 957
                    professor.setId(rs.getString(7));
@ -1126,7 +1162,11 @@ public abstract class ProfessorDao {
1126 1162
                    	title = null;
1127 1163
                    }
1128 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 1170
                    professor.setAuthType(rs.getInt(5));
1131 1171
                    professor.setAuthStatus(rs.getInt(6));
1132 1172
                    professor.setId(rs.getString(7));
@ -1346,7 +1386,11 @@ public abstract class ProfessorDao {
1346 1386
						title = null;
1347 1387
					}
1348 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 1394
					professor.setAuthType(rs.getInt(9));
1351 1395
					professor.setAuthStatus(rs.getInt(10));
1352 1396
					professor.setId(rs.getString(11));
@ -1546,7 +1590,11 @@ public abstract class ProfessorDao {
1546 1590
						title = null;
1547 1591
					}
1548 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 1598
					professor.setId(rs.getString(10));
1551 1599
					professor.setName(rs.getString(11));
1552 1600
					String descp = rs.getString(12);
@ -1751,7 +1799,11 @@ public abstract class ProfessorDao {
1751 1799
						title = null;
1752 1800
					}
1753 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 1807
					userInfo.setAuthType(rs.getInt(9));
1756 1808
					userInfo.setAuthStatus(rs.getInt(10));
1757 1809
					userInfo.setId(rs.getString(11));

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

@ -19,6 +19,7 @@ import org.jfw.util.state.StateCode;
19 19
import com.ekexiu.portal.dao.ProfessorDao;
20 20
import com.ekexiu.portal.dao.UserDao;
21 21
import com.ekexiu.portal.dao.UserOpenIdDao;
22
import com.ekexiu.portal.po.Professor;
22 23
import com.ekexiu.portal.po.User;
23 24
import com.ekexiu.portal.po.UserOpenId;
24 25
import com.ekexiu.portal.pojo.SessionUser;
@ -125,8 +126,9 @@ public class OAuthService {
125 126
		JfwAppContext.removeCachedObject(authCode);
126 127
		SessionUser ret = new SessionUser();
127 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 133
		ret.setMobilePhone(user.getMobilePhone());
132 134
		ret.setType(user.getUserType());
@ -150,8 +152,9 @@ public class OAuthService {
150 152
			if (user != null) {
151 153
				SessionUser ret = new SessionUser();
152 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 159
				ret.setMobilePhone(user.getMobilePhone());
157 160
				ret.setType(user.getUserType());

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

@ -861,7 +861,6 @@ public class SysService {
861 861
			Professor professor = new Professor();
862 862
			professor.setId(user.getId());
863 863
			professor.setName(name);
864
			professor.setAuthentication(-1);
865 864
			this.professorService.insert(con, professor, null);
866 865
			return user.getId();
867 866
		} finally {
@ -940,7 +939,6 @@ public class SysService {
940 939
			Professor professor = new Professor();
941 940
			professor.setId(user.getId());
942 941
			professor.setName(sc.getDescp());
943
			professor.setAuthentication(-1);
944 942
			this.professorService.insert(con, professor, null);
945 943
			con.commit();
946 944
		} catch (SQLException e) {
@ -1290,8 +1288,8 @@ public class SysService {
1290 1288
	}
1291 1289
1292 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 1293
	@Post
1296 1294
	@Path("/invitelogin")
1297 1295
	public SessionUser inviteLogin(@JdbcConn Connection con, String key, String code) throws SQLException {
@ -1302,20 +1300,23 @@ public class SysService {
1302 1300
		if (!user.getInviteCode().equals(code)) {
1303 1301
			return null;
1304 1302
		}
1305
		Professor professor = this.professorDao.query(con, user.getId());
1303
		Professor professor = this.professorDao.queryOne(con, user.getId());
1306 1304
		SessionUser ret = new SessionUser();
1307 1305
		ret.setId(user.getId());
1308 1306
		ret.setMobilePhone(user.getMobilePhone());
1309 1307
		ret.setType(user.getUserType());
1310 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 1313
		ret.setAuth(!DEFAULT_PASS_WORD.equals(user.getPasswd()));
1313 1314
		return ret;
1314 1315
	}
1315 1316
1316 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 1320
	@Post
1320 1321
	@Path("/slogin")
1321 1322
	public SessionUser sLogin(@JdbcConn Connection con, String code, String mobile) throws SQLException {
@ -1324,20 +1325,23 @@ public class SysService {
1324 1325
			return null;
1325 1326
		if (!mobile.equals(user.getMobilePhone()))
1326 1327
			return null;
1327
		Professor professor = this.professorDao.query(con, code);
1328
		Professor professor = this.professorDao.queryOne(con, code);
1328 1329
		SessionUser ret = new SessionUser();
1329 1330
		ret.setId(code);
1330 1331
		ret.setMobilePhone(mobile);
1331 1332
		ret.setType(user.getUserType());
1332 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 1338
		ret.setAuth(!DEFAULT_PASS_WORD.equals(user.getPasswd()));
1335 1339
		return ret;
1336 1340
	}
1337 1341
1338 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 1345
	@Post
1342 1346
	@Path("/login")
1343 1347
	public SessionUser login(@JdbcConn Connection con, String lk, String pw) throws SQLException, JfwBaseException {
@ -1354,6 +1358,7 @@ public class SysService {
1354 1358
		Professor pf = this.professorDao.query(con, user.getId());
1355 1359
		if (null != pf) {
1356 1360
			ret.setName(pf.getName());
1361
			ret.setAuthentication(pf.getAuthentication()+"");
1357 1362
		}
1358 1363
		ret.setMobilePhone(user.getMobilePhone());
1359 1364
		ret.setType(user.getUserType());
@ -1363,8 +1368,8 @@ public class SysService {
1363 1368
	}
1364 1369
1365 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 1373
	@Post
1369 1374
	@Path("/mobileLogin")
1370 1375
	public SessionUser mobileLogin(@JdbcConn Connection con, String state, String mobilePhone, String validateCode) throws SQLException, JfwBaseException {
@ -1389,6 +1394,7 @@ public class SysService {
1389 1394
			Professor professor = this.professorDao.query(con, user.getId());
1390 1395
			if (null != professor) {
1391 1396
				ret.setName(professor.getName());
1397
				ret.setAuthentication(professor.getAuthentication()+"");
1392 1398
			}
1393 1399
			ret.setMobilePhone(user.getMobilePhone());
1394 1400
			ret.setType(user.getUserType());
@ -1400,8 +1406,8 @@ public class SysService {
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 1411
			"orgName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
1406 1412
	@Post
1407 1413
	@Path("/orgLogin")