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,7 +840,8 @@ public abstract class ArticleDao {
840 840
        if(firstPage){
841 841
        	queryResult.setPageNo(1);
842 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 845
            sql = sql + " ORDER BY CREATE_TIME DESC ";
845 846
            sql = sql + " LIMIT " + pageSize;
846 847
        }else{
@ -855,7 +856,8 @@ public abstract class ArticleDao {
855 856
            --pageNo;
856 857
            int offset = (pageNo * pageSize);
857 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 861
            sql = sql + " ORDER BY CREATE_TIME DESC ";
860 862
            sql = sql + " LIMIT " + pageSize+ " OFFSET " + offset;
861 863
        }

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

@ -1069,9 +1069,11 @@ public abstract class ProfessorDao {
1069 1069
		boolean hasKey = null != key;
1070 1070
		if (hasKey) {
1071 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 1078
		boolean hasSubject = null != subject;
1077 1079
		boolean hasIndustry = null != industry;
@ -1112,6 +1114,9 @@ public abstract class ProfessorDao {
1112 1114
				ps.setString(paramIndex++, key);
1113 1115
				ps.setString(paramIndex++, key);
1114 1116
				ps.setString(paramIndex++, key);
1117
				ps.setString(paramIndex++, key);
1118
				ps.setString(paramIndex++, key);
1119
				ps.setString(paramIndex++, key);
1115 1120
			}
1116 1121
			if (hasSubject) {
1117 1122
				ps.setString(paramIndex++, subject);
@ -1193,6 +1198,9 @@ public abstract class ProfessorDao {
1193 1198
				ps.setString(paramIndex++, key);
1194 1199
				ps.setString(paramIndex++, key);
1195 1200
				ps.setString(paramIndex++, key);
1201
				ps.setString(paramIndex++, key);
1202
				ps.setString(paramIndex++, key);
1203
				ps.setString(paramIndex++, key);
1196 1204
			}
1197 1205
			if (hasSubject) {
1198 1206
				ps.setString(paramIndex++, subject);
@ -1282,9 +1290,11 @@ public abstract class ProfessorDao {
1282 1290
		boolean hasKey = null != key;
1283 1291
		if (hasKey) {
1284 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 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 1299
		boolean hasSubject = null != subject;
1290 1300
		boolean hasIndustry = null != industry;
@ -1321,6 +1331,9 @@ public abstract class ProfessorDao {
1321 1331
				ps.setString(paramIndex++, key);
1322 1332
				ps.setString(paramIndex++, key);
1323 1333
				ps.setString(paramIndex++, key);
1334
				ps.setString(paramIndex++, key);
1335
				ps.setString(paramIndex++, key);
1336
				ps.setString(paramIndex++, key);
1324 1337
			}
1325 1338
			if (hasSubject) {
1326 1339
				ps.setString(paramIndex++, subject);
@ -1361,9 +1374,9 @@ public abstract class ProfessorDao {
1361 1374
		if (1 == pageNo) {
1362 1375
			queryResult.setPageNo(1);
1363 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 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 1380
			if (whereSql.length() > 0) {
1368 1381
				sql.append(whereSql);
1369 1382
			}
@ -1381,9 +1394,9 @@ public abstract class ProfessorDao {
1381 1394
			--pageNo;
1382 1395
			int offset = (pageNo * pageSize);
1383 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 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 1400
			if (whereSql.length() > 0) {
1388 1401
				sql.append(whereSql);
1389 1402
			}
@ -1400,6 +1413,9 @@ public abstract class ProfessorDao {
1400 1413
				ps.setString(paramIndex++, key);
1401 1414
				ps.setString(paramIndex++, key);
1402 1415
				ps.setString(paramIndex++, key);
1416
				ps.setString(paramIndex++, key);
1417
				ps.setString(paramIndex++, key);
1418
				ps.setString(paramIndex++, key);
1403 1419
			}
1404 1420
			if (hasSubject) {
1405 1421
				ps.setString(paramIndex++, subject);

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

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

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

@ -13,6 +13,7 @@ import org.jfw.apt.web.annotation.param.JdbcConn;
13 13
import org.jfw.util.PageQueryResult;
14 14

15 15
import com.ekexiu.portal.dao.ArticleDao;
16
import com.ekexiu.portal.dao.ImageDao;
16 17
import com.ekexiu.portal.dao.OrgDao;
17 18
import com.ekexiu.portal.dao.ProfessorDao;
18 19
import com.ekexiu.portal.dao.ResearchAreaDao;
@ -39,6 +40,8 @@ public class WatchService {
39 40
	private ArticleDao articleDao;
40 41
	@Autowrie
41 42
	private OrgDao orgDao;
43
	@Autowrie
44
	private ImageDao imageDao;
42 45
	
43 46
	public WatchDao getWatchDao() {
44 47
		return watchDao;
@ -82,6 +85,12 @@ public class WatchService {
82 85
	public void setOrgDao(OrgDao orgDao) {
83 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 95
	@Post
87 96
	@Path
@ -120,9 +129,14 @@ public class WatchService {
120 129
			}
121 130
		}else if(2 == watchType){
122 131
			for (Watch watch : watchs) {
123
				Resource resource = this.resourceDao.queryBaseInfo(con, watch.getWatchObject());
132
				Resource resource = this.resourceDao.queryOne(con, watch.getWatchObject());
124 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 141
				watch.setResource(resource);
128 142
			}