Browse Source

--update SQL;

zzy.zhiyuan.foxmail 7 years ago
parent
commit
5d3bf012c2

+ 4 - 2
src/main/java/com/ekexiu/portal/dao/ArticleDao.java

840
        if(firstPage){
840
        if(firstPage){
841
        	queryResult.setPageNo(1);
841
        	queryResult.setPageNo(1);
842
        	sql = "(SELECT ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,CREATE_TIME,ORG_ID,PROFESSOR_ID FROM ARTICLE WHERE STATUS = '1')"
842
        	sql = "(SELECT ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,CREATE_TIME,ORG_ID,PROFESSOR_ID FROM ARTICLE WHERE STATUS = '1')"
843
                	+ " UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,NULL,'3',CREATE_TIME,NULL,PROFESSOR_ID FROM RESOURCE WHERE STATUS = '1')";
843
                + " UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,NULL,CASE WHEN RESOURCE_TYPE = '1' THEN '3' WHEN RESOURCE_TYPE = '2' THEN '4' ELSE NULL END,"
844
                + " CREATE_TIME,ORG_ID,PROFESSOR_ID FROM RESOURCE WHERE STATUS = '1')";
844
            sql = sql + " ORDER BY CREATE_TIME DESC ";
845
            sql = sql + " ORDER BY CREATE_TIME DESC ";
845
            sql = sql + " LIMIT " + pageSize;
846
            sql = sql + " LIMIT " + pageSize;
846
        }else{
847
        }else{
855
            --pageNo;
856
            --pageNo;
856
            int offset = (pageNo * pageSize);
857
            int offset = (pageNo * pageSize);
857
            sql = "(SELECT ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,CREATE_TIME,ORG_ID,PROFESSOR_ID FROM ARTICLE WHERE STATUS = '1')"
858
            sql = "(SELECT ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,CREATE_TIME,ORG_ID,PROFESSOR_ID FROM ARTICLE WHERE STATUS = '1')"
858
                	+ " UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,NULL,'3',CREATE_TIME,NULL,PROFESSOR_ID FROM RESOURCE WHERE STATUS = '1')";
859
                + " UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,NULL,CASE WHEN RESOURCE_TYPE = '1' THEN '3' WHEN RESOURCE_TYPE = '2' THEN '4' ELSE NULL END,"
860
                + " CREATE_TIME,ORG_ID,PROFESSOR_ID FROM RESOURCE WHERE STATUS = '1')";
859
            sql = sql + " ORDER BY CREATE_TIME DESC ";
861
            sql = sql + " ORDER BY CREATE_TIME DESC ";
860
            sql = sql + " LIMIT " + pageSize+ " OFFSET " + offset;
862
            sql = sql + " LIMIT " + pageSize+ " OFFSET " + offset;
861
        }
863
        }

+ 25 - 9
src/main/java/com/ekexiu/portal/dao/ProfessorDao.java

1069
		boolean hasKey = null != key;
1069
		boolean hasKey = null != key;
1070
		if (hasKey) {
1070
		if (hasKey) {
1071
			sql.append(" WHERE (( P.ID IN (SELECT PROFESSOR_ID FROM RESEARCH_AREA WHERE CAPTION LIKE ?)) "
1071
			sql.append(" WHERE (( P.ID IN (SELECT PROFESSOR_ID FROM RESEARCH_AREA WHERE CAPTION LIKE ?)) "
1072
					+ " OR (ORG_ID IN(SELECT ORGANIZATION.ID FROM ORGANIZATION WHERE ORGANIZATION.NAME LIKE ?)) "
1073
					+ " OR ( P.NAME LIKE ?) OR (P.SUBJECT LIKE ?) OR (P.INDUSTRY LIKE ?) OR (P.PROVINCE LIKE ?) OR (P.ADDRESS LIKE ?) "
1074
					+ " OR P.ID IN (SELECT PROFESSOR_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?))");
1072
				+ " OR (ORG_ID IN(SELECT ORGANIZATION.ID FROM ORGANIZATION WHERE ORGANIZATION.NAME LIKE ?)) "
1073
				+ " OR ( P.NAME LIKE ?) OR (P.SUBJECT LIKE ?) OR (P.INDUSTRY LIKE ?) OR (P.PROVINCE LIKE ?) OR (P.ADDRESS LIKE ?) "
1074
				+ " OR P.ID IN (SELECT PROFESSOR_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?) "
1075
				+ " OR P.ID IN (SELECT PROFESSOR_ID FROM ARTICLE WHERE ARTICLE_TITLE LIKE ?) "
1076
				+ " OR (P.ID IN (SELECT PROFESSOR_ID FROM PATENT WHERE NAME LIKE ?)) OR (P.DEPARTMENT LIKE ?))");
1075
		}
1077
		}
1076
		boolean hasSubject = null != subject;
1078
		boolean hasSubject = null != subject;
1077
		boolean hasIndustry = null != industry;
1079
		boolean hasIndustry = null != industry;
1112
				ps.setString(paramIndex++, key);
1114
				ps.setString(paramIndex++, key);
1113
				ps.setString(paramIndex++, key);
1115
				ps.setString(paramIndex++, key);
1114
				ps.setString(paramIndex++, key);
1116
				ps.setString(paramIndex++, key);
1117
				ps.setString(paramIndex++, key);
1118
				ps.setString(paramIndex++, key);
1119
				ps.setString(paramIndex++, key);
1115
			}
1120
			}
1116
			if (hasSubject) {
1121
			if (hasSubject) {
1117
				ps.setString(paramIndex++, subject);
1122
				ps.setString(paramIndex++, subject);
1193
				ps.setString(paramIndex++, key);
1198
				ps.setString(paramIndex++, key);
1194
				ps.setString(paramIndex++, key);
1199
				ps.setString(paramIndex++, key);
1195
				ps.setString(paramIndex++, key);
1200
				ps.setString(paramIndex++, key);
1201
				ps.setString(paramIndex++, key);
1202
				ps.setString(paramIndex++, key);
1203
				ps.setString(paramIndex++, key);
1196
			}
1204
			}
1197
			if (hasSubject) {
1205
			if (hasSubject) {
1198
				ps.setString(paramIndex++, subject);
1206
				ps.setString(paramIndex++, subject);
1282
		boolean hasKey = null != key;
1290
		boolean hasKey = null != key;
1283
		if (hasKey) {
1291
		if (hasKey) {
1284
			sql.append(" WHERE ((P.ID IN (SELECT PROFESSOR_ID FROM RESEARCH_AREA WHERE CAPTION LIKE ?)) "
1292
			sql.append(" WHERE ((P.ID IN (SELECT PROFESSOR_ID FROM RESEARCH_AREA WHERE CAPTION LIKE ?)) "
1285
					+ " OR (ORG_ID IN(SELECT organization.ID FROM ORGANIZATION WHERE organization.NAME LIKE ?)) "
1293
					+ " OR (ORG_ID IN(SELECT ORGANIZATION.ID FROM ORGANIZATION WHERE ORGANIZATION.NAME LIKE ?)) "
1286
					+ " OR (P.NAME LIKE ?) OR (P.SUBJECT LIKE ?) OR (P.INDUSTRY LIKE ?) OR (P.ADDRESS LIKE ?)"
1294
					+ " OR (P.NAME LIKE ?) OR (P.SUBJECT LIKE ?) OR (P.INDUSTRY LIKE ?) OR (P.ADDRESS LIKE ?)"
1287
					+ " OR (P.ID IN (SELECT PROFESSOR_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?)) )");
1295
					+ " OR (P.ID IN (SELECT PROFESSOR_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?)) "
1296
					+ " OR (P.ID IN (SELECT PROFESSOR_ID FROM ARTICLE WHERE ARTICLE_TITLE LIKE ?)) "
1297
					+ " OR (P.ID IN (SELECT PROFESSOR_ID FROM PATENT WHERE NAME LIKE ?)) OR (P.DEPARTMENT LIKE ?) )");
1288
		}
1298
		}
1289
		boolean hasSubject = null != subject;
1299
		boolean hasSubject = null != subject;
1290
		boolean hasIndustry = null != industry;
1300
		boolean hasIndustry = null != industry;
1321
				ps.setString(paramIndex++, key);
1331
				ps.setString(paramIndex++, key);
1322
				ps.setString(paramIndex++, key);
1332
				ps.setString(paramIndex++, key);
1323
				ps.setString(paramIndex++, key);
1333
				ps.setString(paramIndex++, key);
1334
				ps.setString(paramIndex++, key);
1335
				ps.setString(paramIndex++, key);
1336
				ps.setString(paramIndex++, key);
1324
			}
1337
			}
1325
			if (hasSubject) {
1338
			if (hasSubject) {
1326
				ps.setString(paramIndex++, subject);
1339
				ps.setString(paramIndex++, subject);
1361
		if (1 == pageNo) {
1374
		if (1 == pageNo) {
1362
			queryResult.setPageNo(1);
1375
			queryResult.setPageNo(1);
1363
			sql = new StringBuilder();
1376
			sql = new StringBuilder();
1364
			sql.append("SELECT OFFICE,P.SUBJECT,P.INDUSTRY,P.ADDRESS,DEPARTMENT,organization.NAME,TITLE,"
1377
			sql.append("SELECT OFFICE,P.SUBJECT,P.INDUSTRY,P.ADDRESS,DEPARTMENT,ORGANIZATION.NAME,TITLE,"
1365
					+ " AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,STAR_LEVEL,CONSULT_COUNT,P.ORG_AUTH "
1378
					+ " AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,STAR_LEVEL,CONSULT_COUNT,P.ORG_AUTH "
1366
					+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON ORG_ID=organization.ID ");
1379
					+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON ORG_ID=ORGANIZATION.ID ");
1367
			if (whereSql.length() > 0) {
1380
			if (whereSql.length() > 0) {
1368
				sql.append(whereSql);
1381
				sql.append(whereSql);
1369
			}
1382
			}
1381
			--pageNo;
1394
			--pageNo;
1382
			int offset = (pageNo * pageSize);
1395
			int offset = (pageNo * pageSize);
1383
			sql = new StringBuilder();
1396
			sql = new StringBuilder();
1384
			sql.append("SELECT OFFICE,P.SUBJECT,P.INDUSTRY,P.ADDRESS,DEPARTMENT,organization.NAME,TITLE,"
1397
			sql.append("SELECT OFFICE,P.SUBJECT,P.INDUSTRY,P.ADDRESS,DEPARTMENT,ORGANIZATION.NAME,TITLE,"
1385
					+ " AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,STAR_LEVEL,CONSULT_COUNT,P.ORG_AUTH "
1398
					+ " AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,STAR_LEVEL,CONSULT_COUNT,P.ORG_AUTH "
1386
					+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON ORG_ID=organization.ID ");
1399
					+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON ORG_ID=ORGANIZATION.ID ");
1387
			if (whereSql.length() > 0) {
1400
			if (whereSql.length() > 0) {
1388
				sql.append(whereSql);
1401
				sql.append(whereSql);
1389
			}
1402
			}
1400
				ps.setString(paramIndex++, key);
1413
				ps.setString(paramIndex++, key);
1401
				ps.setString(paramIndex++, key);
1414
				ps.setString(paramIndex++, key);
1402
				ps.setString(paramIndex++, key);
1415
				ps.setString(paramIndex++, key);
1416
				ps.setString(paramIndex++, key);
1417
				ps.setString(paramIndex++, key);
1418
				ps.setString(paramIndex++, key);
1403
			}
1419
			}
1404
			if (hasSubject) {
1420
			if (hasSubject) {
1405
				ps.setString(paramIndex++, subject);
1421
				ps.setString(paramIndex++, subject);

+ 1 - 1
src/main/java/com/ekexiu/portal/service/ArticleService.java

643
		List<Article> articles = queryResult.getData();
643
		List<Article> articles = queryResult.getData();
644
		if(!articles.isEmpty()){
644
		if(!articles.isEmpty()){
645
			for (Article article : articles) {
645
			for (Article article : articles) {
646
				if("1".equals(article.getArticleTitle())){
646
				if("1".equals(article.getArticleType())){
647
					EditProfessor professor = this.professorDao.queryBaseInfo(con, article.getProfessorId());
647
					EditProfessor professor = this.professorDao.queryBaseInfo(con, article.getProfessorId());
648
					if(professor != null){
648
					if(professor != null){
649
						professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
649
						professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));

+ 16 - 2
src/main/java/com/ekexiu/portal/service/WatchService.java

13
import org.jfw.util.PageQueryResult;
13
import org.jfw.util.PageQueryResult;
14

14

15
import com.ekexiu.portal.dao.ArticleDao;
15
import com.ekexiu.portal.dao.ArticleDao;
16
import com.ekexiu.portal.dao.ImageDao;
16
import com.ekexiu.portal.dao.OrgDao;
17
import com.ekexiu.portal.dao.OrgDao;
17
import com.ekexiu.portal.dao.ProfessorDao;
18
import com.ekexiu.portal.dao.ProfessorDao;
18
import com.ekexiu.portal.dao.ResearchAreaDao;
19
import com.ekexiu.portal.dao.ResearchAreaDao;
39
	private ArticleDao articleDao;
40
	private ArticleDao articleDao;
40
	@Autowrie
41
	@Autowrie
41
	private OrgDao orgDao;
42
	private OrgDao orgDao;
43
	@Autowrie
44
	private ImageDao imageDao;
42
	
45
	
43
	public WatchDao getWatchDao() {
46
	public WatchDao getWatchDao() {
44
		return watchDao;
47
		return watchDao;
82
	public void setOrgDao(OrgDao orgDao) {
85
	public void setOrgDao(OrgDao orgDao) {
83
		this.orgDao = orgDao;
86
		this.orgDao = orgDao;
84
	}
87
	}
88
	public ImageDao getImageDao() {
89
		return imageDao;
90
	}
91
	public void setImageDao(ImageDao imageDao) {
92
		this.imageDao = imageDao;
93
	}
85
	
94
	
86
	@Post
95
	@Post
87
	@Path
96
	@Path
120
			}
129
			}
121
		}else if(2 == watchType){
130
		}else if(2 == watchType){
122
			for (Watch watch : watchs) {
131
			for (Watch watch : watchs) {
123
				Resource resource = this.resourceDao.queryBaseInfo(con, watch.getWatchObject());
132
				Resource resource = this.resourceDao.queryOne(con, watch.getWatchObject());
124
				if(resource != null) {
133
				if(resource != null) {
125
					resource.setEditProfessor(this.professorDao.queryBaseInfo(con, resource.getProfessorId()));
134
					resource.setImages(this.imageDao.queryRes(con, resource.getResourceId()));
135
					if("1".equals(resource.getResourceType())){
136
						resource.setEditProfessor(this.professorDao.queryBaseInfo(con, resource.getProfessorId()));
137
					}else if("2".equals(resource.getResourceType())){
138
						resource.setOrganization(this.orgDao.queryEditOrg(con, resource.getOrgId()));
139
					}
126
				}
140
				}
127
				watch.setResource(resource);
141
				watch.setResource(resource);
128
			}
142
			}