Browse Source

Merge remote-tracking branch 'origin/dev' into test

jiapeng 7 years ago
parent
commit
8a0005fbde
43 changed files with 2481 additions and 547 deletions
  1. 23 0
      src/main/java/com/ekexiu/portal/dao/ArtKeyWordDao.java
  2. 114 83
      src/main/java/com/ekexiu/portal/dao/ArticleDao.java
  3. 29 0
      src/main/java/com/ekexiu/portal/dao/ArticleOrgDao.java
  4. 7 9
      src/main/java/com/ekexiu/portal/dao/ArticleProDao.java
  5. 9 10
      src/main/java/com/ekexiu/portal/dao/ArticleResDao.java
  6. 3 3
      src/main/java/com/ekexiu/portal/dao/LeaveWordDao.java
  7. 227 0
      src/main/java/com/ekexiu/portal/dao/OrgDao.java
  8. 23 0
      src/main/java/com/ekexiu/portal/dao/OrgKeyWordDao.java
  9. 23 0
      src/main/java/com/ekexiu/portal/dao/PapKeyWordDao.java
  10. 43 0
      src/main/java/com/ekexiu/portal/dao/PaperAgreeDao.java
  11. 23 0
      src/main/java/com/ekexiu/portal/dao/PatKeyWordDao.java
  12. 42 0
      src/main/java/com/ekexiu/portal/dao/PatentAgreeDao.java
  13. 71 11
      src/main/java/com/ekexiu/portal/dao/PpaperDao.java
  14. 84 15
      src/main/java/com/ekexiu/portal/dao/PpatentDao.java
  15. 25 0
      src/main/java/com/ekexiu/portal/dao/ProKeyWordDao.java
  16. 30 1
      src/main/java/com/ekexiu/portal/dao/ProfessorDao.java
  17. 23 0
      src/main/java/com/ekexiu/portal/dao/ResKeyWordDao.java
  18. 26 0
      src/main/java/com/ekexiu/portal/dao/ResourceDao.java
  19. 12 1
      src/main/java/com/ekexiu/portal/job/ArticleTaskJobEntry.java
  20. 59 25
      src/main/java/com/ekexiu/portal/job/HotKeyJobEntry.java
  21. 26 0
      src/main/java/com/ekexiu/portal/po/ArtKeyWord.java
  22. 45 0
      src/main/java/com/ekexiu/portal/po/ArticleOrg.java
  23. 14 5
      src/main/java/com/ekexiu/portal/po/LeaveWord.java
  24. 26 0
      src/main/java/com/ekexiu/portal/po/OrgKeyWord.java
  25. 26 0
      src/main/java/com/ekexiu/portal/po/PapKeyWord.java
  26. 37 0
      src/main/java/com/ekexiu/portal/po/PaperAgree.java
  27. 26 0
      src/main/java/com/ekexiu/portal/po/PatKeyWord.java
  28. 37 0
      src/main/java/com/ekexiu/portal/po/PatentAgree.java
  29. 28 0
      src/main/java/com/ekexiu/portal/po/ProKeyWord.java
  30. 9 1
      src/main/java/com/ekexiu/portal/po/Professor.java
  31. 26 0
      src/main/java/com/ekexiu/portal/po/ResKeyWord.java
  32. 329 172
      src/main/java/com/ekexiu/portal/service/ArticleService.java
  33. 198 0
      src/main/java/com/ekexiu/portal/service/KeyWordService.java
  34. 86 4
      src/main/java/com/ekexiu/portal/service/LeaveWordService.java
  35. 76 2
      src/main/java/com/ekexiu/portal/service/OrgService.java
  36. 75 0
      src/main/java/com/ekexiu/portal/service/PpaperService.java
  37. 73 0
      src/main/java/com/ekexiu/portal/service/PpatentServcie.java
  38. 255 130
      src/main/java/com/ekexiu/portal/service/ProfessorService.java
  39. 125 72
      src/main/java/com/ekexiu/portal/service/ResourceService.java
  40. 65 0
      src/main/resources/database.sql
  41. 1 1
      src/main/resources/project-test-dev.properties
  42. 1 1
      src/main/resources/project-test.properties
  43. 1 1
      src/main/resources/project.properties

+ 23 - 0
src/main/java/com/ekexiu/portal/dao/ArtKeyWordDao.java

@ -0,0 +1,23 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.orm.annotation.dao.Batch;
7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
10
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
11

12
import com.ekexiu.portal.po.ArtKeyWord;
13

14
@DAO
15
public interface ArtKeyWordDao {
16
	@Insert
17
	@Batch
18
	int[] insert(Connection con,ArtKeyWord[] okws)throws SQLException;
19
	
20
	@DeleteWith
21
	@From(ArtKeyWord.class)
22
	int delete(Connection con,String id)throws SQLException;
23
}

+ 114 - 83
src/main/java/com/ekexiu/portal/dao/ArticleDao.java

@ -23,6 +23,7 @@ import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
23 23
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
24 24
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
25 25
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
26
import org.jfw.apt.orm.annotation.dao.param.In;
26 27
import org.jfw.apt.orm.annotation.dao.param.LessThan;
27 28
import org.jfw.apt.orm.annotation.dao.param.Like;
28 29
import org.jfw.apt.orm.annotation.dao.param.Set;
@ -296,101 +297,131 @@ public abstract class ArticleDao {
296 297
		}
297 298
	}
298 299
	
299
	public List<Article> queryLimit(Connection con,String[] keys,String articleId,int rows) throws SQLException{
300
		int index = 1;
301
		boolean hasKeys = null != keys;
302
		boolean hasArticleId = null != articleId;
303
		StringBuilder sql = new StringBuilder();
304
		sql.append("SELECT ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,ARTICLE_CONTENT,SUBJECT,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME,SHARE_ID FROM ARTICLE");
305
		sql.append(" WHERE STATUS = '1'");
306
		if(hasArticleId){
307
			sql.append(" AND ARTICLE_ID != ?");
308
		}
309
		if(hasKeys){
310
			for (int i = 0; i < keys.length; i++) {
311
        		if(i == 0){
312
        			sql.append(" AND (SUBJECT LIKE ?");
313
        		}else{
314
        			sql.append(" OR SUBJECT LIKE ?");
315
        		}
316
			}
317
        	sql.append(")");
318
		}
319
		sql.append(" ORDER BY PUBLISH_TIME DESC");
320
        sql.append(" LIMIT ").append(rows);
321
		PreparedStatement ps = con.prepareStatement(sql.toString());
300
	public String[] queryArticleIdWithSameKeyWord(Connection con,String id,int rows)throws SQLException{
301
		List<String> ret = new ArrayList<String>();
302
		String sql = "select id,count(1) sort from art_key_word where kw in (select kw from art_key_word where id=?) and id <>? group by id order by sort desc limit ?";
303
		PreparedStatement ps = con.prepareStatement(sql);
322 304
		try{
323
			if(hasArticleId){
324
				ps.setString(index++, articleId);
325
			}
326
			if(hasKeys){
327
        		for (String key : keys) {
328
        			ps.setString(index++, "%"+key+"%");
329
				}
330
        	}
305
			ps.setString(1, id);
306
			ps.setString(2, id);
307
			ps.setInt(3, rows);
331 308
			ResultSet rs = ps.executeQuery();
332 309
			try{
333
				List<Article> articles = new ArrayList<Article>();
334 310
				while(rs.next()){
335
					Article article = new Article();
336
					article.setArticleId(rs.getString(1));
337
                    String proId = rs.getString(2);
338
                    if(rs.wasNull()){
339
                    	proId = null;
340
                    }
341
                    article.setProfessorId(proId);
342
                    article.setArticleTitle(rs.getString(3));
343
                    String articleContent = rs.getString(4);
344
                    if(rs.wasNull()){
345
                    	articleContent = null;
346
                    }
347
                    article.setArticleContent(articleContent);
348
                    String subject = rs.getString(5);
349
                    if(rs.wasNull()){
350
                    	subject = null;
351
                    }
352
                    article.setSubject(subject);
353
                    String publishTime = rs.getString(6);
354
                    if(rs.wasNull()){
355
                    	publishTime = null;
356
                    }
357
                    article.setPublishTime(publishTime);
358
                    String articleImg = rs.getString(7);
359
                    if(rs.wasNull()){
360
                    	articleImg = null;
361
                    }
362
                    article.setArticleImg(articleImg);
363
                    String org = rs.getString(8);
364
                    if(rs.wasNull()){
365
                    	org = null;
366
                    }
367
                    article.setOrgId(org);
368
                    String articleType = rs.getString(9);
369
                    if(rs.wasNull()){
370
                    	articleType = null;
371
                    }
372
                    article.setArticleType(articleType);
373
                    article.setArticleAgree(rs.getInt(10));
374
                    article.setPageViews(rs.getInt(11));
375
                    String status = rs.getString(12);
376
                    if(rs.wasNull()){
377
                    	status = null;
378
                    }
379
                    article.setStatus(status);
380
                    article.setCreateTime(rs.getString(13));
381
                    article.setModifyTime(rs.getString(14));
382
                    article.setShareId(rs.getLong(15));
383
					articles.add(article);
311
					ret.add(rs.getString(1));
384 312
				}
385
				return articles;
386 313
			}finally{
387 314
				try{rs.close();}catch(Exception e1){}
388 315
			}
389 316
		}finally{
390
			try{ps.close();}catch(Exception e2) {}
317
			try{ps.close();}catch(Exception e2){}
391 318
		}
319
		return ret.isEmpty()?null:ret.toArray(new String[ret.size()]);		
392 320
	}
321
	@SelectList
322
	public abstract List<Article> query(Connection con,@In String[] articleId) throws SQLException;
323
	
324
	@LimitSelect
325
	@Where("STATUS ='1'")
326
	@OrderBy("ORDER BY PAGE_VIEWS DESC")
327
	public abstract List<Article> limitQueryPublish(Connection con,@In String[] articleId,int rows) throws SQLException;
393 328
	
329

330
//	public List<Article> queryLimit(Connection con,String[] keys,String articleId,int rows) throws SQLException{
331
//		int index = 1;
332
//		boolean hasKeys = null != keys;
333
//		boolean hasArticleId = null != articleId;
334
//		StringBuilder sql = new StringBuilder();
335
//		sql.append("SELECT ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,ARTICLE_CONTENT,SUBJECT,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME,SHARE_ID FROM ARTICLE");
336
//		sql.append(" WHERE STATUS = '1'");
337
//		if(hasArticleId){
338
//			sql.append(" AND ARTICLE_ID != ?");
339
//		}
340
//		if(hasKeys){
341
//			for (int i = 0; i < keys.length; i++) {
342
//        		if(i == 0){
343
//        			sql.append(" AND (SUBJECT LIKE ?");
344
//        		}else{
345
//        			sql.append(" OR SUBJECT LIKE ?");
346
//        		}
347
//			}
348
//        	sql.append(")");
349
//		}
350
//		sql.append(" ORDER BY PUBLISH_TIME DESC");
351
//        sql.append(" LIMIT ").append(rows);
352
//		PreparedStatement ps = con.prepareStatement(sql.toString());
353
//		try{
354
//			if(hasArticleId){
355
//				ps.setString(index++, articleId);
356
//			}
357
//			if(hasKeys){
358
//        		for (String key : keys) {
359
//        			ps.setString(index++, "%"+key+"%");
360
//				}
361
//        	}
362
//			ResultSet rs = ps.executeQuery();
363
//			try{
364
//				List<Article> articles = new ArrayList<Article>();
365
//				while(rs.next()){
366
//					Article article = new Article();
367
//					article.setArticleId(rs.getString(1));
368
//                    String proId = rs.getString(2);
369
//                    if(rs.wasNull()){
370
//                    	proId = null;
371
//                    }
372
//                    article.setProfessorId(proId);
373
//                    article.setArticleTitle(rs.getString(3));
374
//                    String articleContent = rs.getString(4);
375
//                    if(rs.wasNull()){
376
//                    	articleContent = null;
377
//                    }
378
//                    article.setArticleContent(articleContent);
379
//                    String subject = rs.getString(5);
380
//                    if(rs.wasNull()){
381
//                    	subject = null;
382
//                    }
383
//                    article.setSubject(subject);
384
//                    String publishTime = rs.getString(6);
385
//                    if(rs.wasNull()){
386
//                    	publishTime = null;
387
//                    }
388
//                    article.setPublishTime(publishTime);
389
//                    String articleImg = rs.getString(7);
390
//                    if(rs.wasNull()){
391
//                    	articleImg = null;
392
//                    }
393
//                    article.setArticleImg(articleImg);
394
//                    String org = rs.getString(8);
395
//                    if(rs.wasNull()){
396
//                    	org = null;
397
//                    }
398
//                    article.setOrgId(org);
399
//                    String articleType = rs.getString(9);
400
//                    if(rs.wasNull()){
401
//                    	articleType = null;
402
//                    }
403
//                    article.setArticleType(articleType);
404
//                    article.setArticleAgree(rs.getInt(10));
405
//                    article.setPageViews(rs.getInt(11));
406
//                    String status = rs.getString(12);
407
//                    if(rs.wasNull()){
408
//                    	status = null;
409
//                    }
410
//                    article.setStatus(status);
411
//                    article.setCreateTime(rs.getString(13));
412
//                    article.setModifyTime(rs.getString(14));
413
//                    article.setShareId(rs.getLong(15));
414
//					articles.add(article);
415
//				}
416
//				return articles;
417
//			}finally{
418
//				try{rs.close();}catch(Exception e1){}
419
//			}
420
//		}finally{
421
//			try{ps.close();}catch(Exception e2) {}
422
//		}
423
//	}
424
//	
394 425
	@PageSelect
395 426
	@OrderBy("ORDER BY PUBLISH_TIME DESC")
396 427
	@Where("STATUS = '1'")

+ 29 - 0
src/main/java/com/ekexiu/portal/dao/ArticleOrgDao.java

@ -0,0 +1,29 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.List;
6

7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
10
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
11
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
12

13
import com.ekexiu.portal.po.ArticleOrg;
14

15
@DAO
16
public interface ArticleOrgDao {
17
	
18
	@Insert
19
	int insert(Connection con,ArticleOrg org) throws SQLException;
20
	@SelectList
21
	List<ArticleOrg> query(Connection con, String articleId) throws SQLException;
22
	@DeleteWith
23
	@From(ArticleOrg.class)
24
	int delete(Connection con, String articleId) throws SQLException;
25
	
26
	@SelectList
27
	List<ArticleOrg> queryByOrgId(Connection con,String orgId) throws SQLException;
28
	
29
}

+ 7 - 9
src/main/java/com/ekexiu/portal/dao/ArticleProDao.java

@ -4,15 +4,11 @@ import java.sql.Connection;
4 4
import java.sql.SQLException;
5 5
import java.util.List;
6 6

7
import org.jfw.apt.annotation.DefaultValue;
8
import org.jfw.apt.orm.annotation.dao.Column;
9 7
import org.jfw.apt.orm.annotation.dao.DAO;
10 8
import org.jfw.apt.orm.annotation.dao.method.From;
11 9
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
12 10
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
13
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
14 11
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
15
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
16 12

17 13
import com.ekexiu.portal.po.ArticlePro;
18 14

@ -21,11 +17,11 @@ public abstract class ArticleProDao {
21 17
	@Insert
22 18
	public abstract int insert(Connection con, ArticlePro articlePro) throws SQLException;
23 19

24
	@QueryVal
25
	@From(ArticlePro.class)
26
	@Column(handlerClass = IntHandler.class, value = "COUNT(1)")
27
	@DefaultValue("0")
28
	public abstract int queryByArticleId(Connection con, String articleId) throws SQLException;
20
//	@QueryVal
21
//	@From(ArticlePro.class)
22
//	@Column(handlerClass = IntHandler.class, value = "COUNT(1)")
23
//	@DefaultValue("0")
24
//	public abstract int queryByArticleId(Connection con, String articleId) throws SQLException;
29 25

30 26
	@SelectList
31 27
	public abstract List<ArticlePro> query(Connection con, String articleId) throws SQLException;
@ -33,5 +29,7 @@ public abstract class ArticleProDao {
33 29
	@DeleteWith
34 30
	@From(ArticlePro.class)
35 31
	public abstract int delete(Connection con, String articleId) throws SQLException;
32
	@SelectList
33
	public abstract List<ArticlePro> queryByProfessorId(Connection con,String professorId) throws SQLException;
36 34

37 35
}

+ 9 - 10
src/main/java/com/ekexiu/portal/dao/ArticleResDao.java

@ -7,16 +7,12 @@ import java.sql.SQLException;
7 7
import java.util.ArrayList;
8 8
import java.util.List;
9 9

10
import org.jfw.apt.annotation.DefaultValue;
11
import org.jfw.apt.orm.annotation.dao.Column;
12 10
import org.jfw.apt.orm.annotation.dao.DAO;
13 11
import org.jfw.apt.orm.annotation.dao.method.From;
14 12
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
15 13
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
16
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
17
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
14
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
18 15

19
import com.ekexiu.portal.po.ArticlePro;
20 16
import com.ekexiu.portal.po.ArticleRes;
21 17

22 18
@DAO
@ -24,11 +20,11 @@ public abstract class ArticleResDao {
24 20
	@Insert
25 21
	public abstract int insert(Connection con, ArticleRes articleRes) throws SQLException;
26 22

27
	@QueryVal
28
	@From(ArticlePro.class)
29
	@Column(handlerClass = IntHandler.class, value = "COUNT(1)")
30
	@DefaultValue("0")
31
	public abstract int queryByArticleId(Connection con, String articleId) throws SQLException;
23
//	@QueryVal
24
//	@From(ArticlePro.class)
25
//	@Column(handlerClass = IntHandler.class, value = "COUNT(1)")
26
//	@DefaultValue("0")
27
//	public abstract int queryByArticleId(Connection con, String articleId) throws SQLException;
32 28

33 29
	public List<ArticleRes> query(Connection con, String articleId) throws SQLException{
34 30
        int index = 1;
@ -85,4 +81,7 @@ public abstract class ArticleResDao {
85 81
	@From(ArticleRes.class)
86 82
	public abstract int delete(Connection con, String articleId) throws SQLException;
87 83

84
	
85
	@SelectList
86
	public abstract List<ArticleRes> queryByResourceId(Connection con,String resourceId) throws SQLException;
88 87
}

+ 3 - 3
src/main/java/com/ekexiu/portal/dao/LeaveWordDao.java

@ -27,15 +27,15 @@ public abstract class LeaveWordDao {
27 27
	@From(LeaveWord.class)
28 28
	@Column(handlerClass=IntHandler.class,value={"COUNT(1)"})
29 29
	@DefaultValue("0")
30
	public abstract int queryCount(Connection con,String articleId)throws SQLException;
30
	public abstract int queryCount(Connection con,String objId,String category)throws SQLException;
31 31

32 32
	@LimitSelect
33 33
	@OrderBy("ORDER BY CREATE_TIME DESC,ORDER_KEY DESC")
34
	public abstract List<LeaveWord> query(Connection con,String articleId,@LessThan String createTime,@LessThan long orderKey,int rows) throws SQLException; 
34
	public abstract List<LeaveWord> query(Connection con,String objId,String category,@LessThan String createTime,@LessThan long orderKey,int rows) throws SQLException; 
35 35
	
36 36
	@DeleteWith
37 37
	@From(LeaveWord.class)
38
	public abstract int deleteArticle(Connection con,String articleId)throws SQLException;
38
	public abstract int deleteArticle(Connection con,String objId,String category)throws SQLException;
39 39
	
40 40
	@DeleteWith
41 41
	@From(LeaveWord.class)

+ 227 - 0
src/main/java/com/ekexiu/portal/dao/OrgDao.java

@ -1,7 +1,10 @@
1 1
package com.ekexiu.portal.dao;
2 2
3 3
import java.sql.Connection;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
4 6
import java.sql.SQLException;
7
import java.util.ArrayList;
5 8
import java.util.List;
6 9
7 10
import org.jfw.apt.annotation.Nullable;
@ -214,6 +217,194 @@ public abstract class OrgDao {
214 217
					"(ID IN (SELECT ORG_ID FROM RESOURCE WHERE RESOURCE_TYPE='2' AND RESOURCE_NAME LIKE ?) AND IS_JOIN ='1')",
215 218
					"(ID IN (SELECT ORG_ID FROM ARTICLE WHERE ARTICLE_TYPE='2' AND ARTICLE_TITLE LIKE ?) AND IS_JOIN ='1')" }) String kw,
216 219
			int pageSize, int pageNo) throws SQLException;
220
	
221
	
222
	public PageQueryResult<EditOrganization> queryByKwAndIndustryAndAddr(Connection con,String kw,String industry,String addr,int pageSize,int pageNo)throws SQLException{
223
		  int _m_1 = 0;
224
	        org.jfw.util.PageQueryResult<com.ekexiu.portal.pojo.EditOrganization> _result = new org.jfw.util.PageQueryResult<com.ekexiu.portal.pojo.EditOrganization>();
225
	        int _m_2 = 1;
226
	        String sql = null;
227
	        sql = "  WHERE INDUSTRY LIKE ? AND ADDR LIKE ? AND ((ID IN (SELECT ORG_ID FROM ARTICLE WHERE ARTICLE_TYPE='2' AND ARTICLE_TITLE LIKE ?) AND IS_JOIN ='1') OR (ID IN (SELECT ORG_ID FROM RESOURCE WHERE RESOURCE_TYPE='2' AND RESOURCE_NAME LIKE ?) AND IS_JOIN ='1') OR (industry LIKE ?  AND IS_JOIN ='1') OR (SUBJECT LIKE ? AND IS_JOIN ='1') OR (DESCP LIKE ?  AND IS_JOIN ='1') OR (FOR_SHORT LIKE ? AND IS_JOIN ='1') OR (NAME LIKE ? AND IS_JOIN ='1'))";
228
	        String _m_3 = sql;
229
	        sql = "SELECT COUNT(1) FROM ORGANIZATION";
230
	        sql = sql + _m_3;
231
	        java.sql.PreparedStatement ps = con.prepareStatement(sql);
232
	        try{
233
	            ps.setString(_m_2++,industry);	
234
	            ps.setString(_m_2++,addr);	        	
235
	            ps.setString(_m_2++,kw);
236
	            ps.setString(_m_2++,kw);
237
	            ps.setString(_m_2++,kw);
238
	            ps.setString(_m_2++,kw);
239
	            ps.setString(_m_2++,kw);
240
	            ps.setString(_m_2++,kw);
241
	            ps.setString(_m_2++,kw);
242
	            _result.setPageSize(pageSize);
243
	            java.sql.ResultSet _pageRs = ps.executeQuery();
244
	            try{
245
	                _pageRs.next();
246
	                _m_1 = _pageRs.getInt(1);
247
	            }finally{
248
	                try{_pageRs.close();}catch(Exception _m_4){}
249
	            }
250
	        }finally{
251
	            try{ps.close();}catch(Exception _m_5){}
252
	        }
253
	        _result.setTotal(_m_1);
254
	        if(0== _m_1){
255
	            _result.setPageNo(1);
256
	            _result.setData(java.util.Collections.<com.ekexiu.portal.pojo.EditOrganization>emptyList());
257
	            return _result;
258
	        }
259
	        _m_2 = 1;
260
	        boolean _m_6 = (1 == pageNo);
261
	        if(_m_6){
262
	            _result.setPageNo(1);
263
	            sql = "SELECT FOR_SHORT,ORG_URL,FOUND_TIME,PROVINCE,CITY,SUBJECT,INDUSTRY,ORG_SIZE,QUALIFICATION,IS_JOIN,AUTH_STATUS,ADDR,EMAIL,CONTACT_NUM,FIELD_OF_CUSTOMER,FIELD_OF_SUPPLIER,SORT_NUM,PAGE_VIEWS,SHARE_ID,ORG_ATTR,ID,NAME,ORG_TYPE,CREATE_TIME,MODIFY_TIME,DESCP FROM ORGANIZATION";
264
	            sql = sql + _m_3;
265
	            sql = sql + " ORDER BY SORT_NUM DESC,MODIFY_TIME DESC";
266
	            sql = sql + " LIMIT " + pageSize;
267
	        }else{
268
	            int _m_7 = _m_1 / pageSize;
269
	            if(_m_1 % pageSize != 0){
270
	                ++_m_7;
271
	            }
272
	            if(pageNo > _m_7){
273
	                pageNo = _m_7;
274
	            }
275
	            _result.setPageNo(pageNo);
276
	            --pageNo;
277
	            int _m_8 = (pageNo * pageSize);
278
	            sql = "SELECT FOR_SHORT,ORG_URL,FOUND_TIME,PROVINCE,CITY,SUBJECT,INDUSTRY,ORG_SIZE,QUALIFICATION,IS_JOIN,AUTH_STATUS,ADDR,EMAIL,CONTACT_NUM,FIELD_OF_CUSTOMER,FIELD_OF_SUPPLIER,SORT_NUM,PAGE_VIEWS,SHARE_ID,ORG_ATTR,ID,NAME,ORG_TYPE,CREATE_TIME,MODIFY_TIME,DESCP FROM ORGANIZATION";
279
	            sql = sql + _m_3;
280
	            sql = sql + " ORDER BY SORT_NUM DESC,MODIFY_TIME DESC";
281
	            sql = sql + " LIMIT " + pageSize+ " OFFSET "+_m_8;
282
	        }
283
	        ps = con.prepareStatement(sql);
284
	        try{
285
	            ps.setString(_m_2++,industry);	
286
	            ps.setString(_m_2++,addr);	   
287
	            ps.setString(_m_2++,kw);
288
	            ps.setString(_m_2++,kw);
289
	            ps.setString(_m_2++,kw);
290
	            ps.setString(_m_2++,kw);
291
	            ps.setString(_m_2++,kw);
292
	            ps.setString(_m_2++,kw);
293
	            ps.setString(_m_2++,kw);
294
	            java.sql.ResultSet rs = ps.executeQuery();
295
	            try{
296
	                java.util.List<com.ekexiu.portal.pojo.EditOrganization> _m_9 = new java.util.ArrayList<com.ekexiu.portal.pojo.EditOrganization>();
297
	                _result.setData(_m_9);
298
	                int _m_10 = 0;
299
	                while((_m_10<pageSize) && rs.next()){
300
	                    ++_m_10;
301
	                    com.ekexiu.portal.pojo.EditOrganization _obj =  new com.ekexiu.portal.pojo.EditOrganization();
302
	                    java.lang.String _m_11 = rs.getString(1);
303
	                    if(rs.wasNull()){
304
	                        _m_11 = null;
305
	                    }
306
	                    _obj.setForShort(_m_11);
307
	                    java.lang.String _m_12 = rs.getString(2);
308
	                    if(rs.wasNull()){
309
	                        _m_12 = null;
310
	                    }
311
	                    _obj.setOrgUrl(_m_12);
312
	                    java.lang.String _m_13 = rs.getString(3);
313
	                    if(rs.wasNull()){
314
	                        _m_13 = null;
315
	                    }
316
	                    _obj.setFoundTime(_m_13);
317
	                    java.lang.String _m_14 = rs.getString(4);
318
	                    if(rs.wasNull()){
319
	                        _m_14 = null;
320
	                    }
321
	                    _obj.setProvince(_m_14);
322
	                    java.lang.String _m_15 = rs.getString(5);
323
	                    if(rs.wasNull()){
324
	                        _m_15 = null;
325
	                    }
326
	                    _obj.setCity(_m_15);
327
	                    java.lang.String _m_16 = rs.getString(6);
328
	                    if(rs.wasNull()){
329
	                        _m_16 = null;
330
	                    }
331
	                    _obj.setSubject(_m_16);
332
	                    java.lang.String _m_17 = rs.getString(7);
333
	                    if(rs.wasNull()){
334
	                        _m_17 = null;
335
	                    }
336
	                    _obj.setIndustry(_m_17);
337
	                    java.lang.String _m_18 = rs.getString(8);
338
	                    if(rs.wasNull()){
339
	                        _m_18 = null;
340
	                    }
341
	                    _obj.setOrgSize(_m_18);
342
	                    java.lang.String _m_19 = rs.getString(9);
343
	                    if(rs.wasNull()){
344
	                        _m_19 = null;
345
	                    }
346
	                    _obj.setQualification(_m_19);
347
	                    _obj.setIsJoin(rs.getString(10));
348
	                    _obj.setAuthStatus(rs.getString(11));
349
	                    java.lang.String _m_20 = rs.getString(12);
350
	                    if(rs.wasNull()){
351
	                        _m_20 = null;
352
	                    }
353
	                    _obj.setAddr(_m_20);
354
	                    java.lang.String _m_21 = rs.getString(13);
355
	                    if(rs.wasNull()){
356
	                        _m_21 = null;
357
	                    }
358
	                    _obj.setEmail(_m_21);
359
	                    java.lang.String _m_22 = rs.getString(14);
360
	                    if(rs.wasNull()){
361
	                        _m_22 = null;
362
	                    }
363
	                    _obj.setContactNum(_m_22);
364
	                    java.lang.String _m_23 = rs.getString(15);
365
	                    if(rs.wasNull()){
366
	                        _m_23 = null;
367
	                    }
368
	                    _obj.setFieldOfCustomer(_m_23);
369
	                    java.lang.String _m_24 = rs.getString(16);
370
	                    if(rs.wasNull()){
371
	                        _m_24 = null;
372
	                    }
373
	                    _obj.setFieldOfSupplier(_m_24);
374
	                    _obj.setSortNum(rs.getLong(17));
375
	                    _obj.setPageViews(rs.getLong(18));
376
	                    _obj.setShareId(rs.getLong(19));
377
	                    java.lang.String _m_25 = rs.getString(20);
378
	                    if(rs.wasNull()){
379
	                        _m_25 = null;
380
	                    }
381
	                    _obj.setOrgAttr(_m_25);
382
	                    _obj.setId(rs.getString(21));
383
	                    _obj.setName(rs.getString(22));
384
	                    java.lang.String _m_26 = rs.getString(23);
385
	                    if(rs.wasNull()){
386
	                        _m_26 = null;
387
	                    }
388
	                    _obj.setOrgType(_m_26);
389
	                    _obj.setCreateTime(rs.getString(24));
390
	                    _obj.setModifyTime(rs.getString(25));
391
	                    java.lang.String _m_27 = rs.getString(26);
392
	                    if(rs.wasNull()){
393
	                        _m_27 = null;
394
	                    }
395
	                    _obj.setDescp(_m_27);
396
	                    _m_9.add(_obj);
397
	                }
398
	                return _result;
399
	            }finally{
400
	                try{rs.close();}catch(Exception _m_28){}
401
	            }
402
	        }finally{
403
	            try{ps.close();}catch(Exception _m_29){}
404
	        }
405
	    }
406
	
407
	
217 408
218 409
	@PageQuery
219 410
	@From(Organization.class)
@ -222,9 +413,45 @@ public abstract class OrgDao {
222 413
	@Where("IS_JOIN ='1'")
223 414
	public abstract PageQueryResult<EditOrganization> query(Connection con, int pageSize, int pageNo) throws SQLException;
224 415
	
416
	
417
	@PageQuery
418
	@From(Organization.class)
419
	@OrderBy("ORDER BY SORT_NUM DESC,MODIFY_TIME DESC")
420
	@Select(Organization.class)
421
	@Where("IS_JOIN ='1'")
422
	public abstract PageQueryResult<EditOrganization> queryByIndustryAndAddr(Connection con,@Like String industry,@Like String addr,  int pageSize, int pageNo) throws SQLException;
423
	
225 424
	@QueryList
226 425
	@From(Organization.class)
227 426
	@Select(Organization.class)
228 427
	public abstract List<EditOrganization> query(Connection con,@In String[] id) throws SQLException;
428
	
429
	@LimitQuery
430
	@Select(Organization.class)
431
	@From(Organization.class)
432
	@OrderBy(" ORDER BY SORT_NUM DESC,PAGE_VIEWS DESC,SHARE_ID ASC")
433
	@Or
434
	public abstract List<EditOrganization> relateQuery(Connection con,@Nullable @SqlColumn(value={"(IS_JOIN='1' AND NAME LIKE ?)","(IS_JOIN='1' AND FOR_SHORT LIKE ?)"},handlerClass=StringHandler.class) String kw,int rows)throws SQLException;
229 435
436
	public String[] queryOrgIdWithSameKeyWord(Connection con,String id,int rows)throws SQLException{
437
		List<String> ret = new ArrayList<String>();
438
		String sql = "select id,count(1) sort from org_key_word where kw in (select kw from org_key_word where id=?) and id <>? group by id order by sort desc limit ?";
439
		PreparedStatement ps = con.prepareStatement(sql);
440
		try{
441
			ps.setString(1, id);
442
			ps.setString(2, id);
443
			ps.setInt(3, rows);
444
			ResultSet rs = ps.executeQuery();
445
			try{
446
				while(rs.next()){
447
					ret.add(rs.getString(1));
448
				}
449
			}finally{
450
				try{rs.close();}catch(Exception e1){}
451
			}
452
		}finally{
453
			try{ps.close();}catch(Exception e2){}
454
		}
455
		return ret.isEmpty()?null:ret.toArray(new String[ret.size()]);		
456
	}
230 457
}

+ 23 - 0
src/main/java/com/ekexiu/portal/dao/OrgKeyWordDao.java

@ -0,0 +1,23 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.orm.annotation.dao.Batch;
7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
10
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
11

12
import com.ekexiu.portal.po.OrgKeyWord;
13

14
@DAO
15
public interface OrgKeyWordDao {
16
	@Insert
17
	@Batch
18
	int[] insert(Connection con,OrgKeyWord[] okws)throws SQLException;
19
	
20
	@DeleteWith
21
	@From(OrgKeyWord.class)
22
	int delete(Connection con,String id)throws SQLException;
23
}

+ 23 - 0
src/main/java/com/ekexiu/portal/dao/PapKeyWordDao.java

@ -0,0 +1,23 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.orm.annotation.dao.Batch;
7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
10
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
11

12
import com.ekexiu.portal.po.PapKeyWord;
13

14
@DAO
15
public interface PapKeyWordDao {
16
	@Insert
17
	@Batch
18
	int[] insert(Connection con,PapKeyWord[] okws)throws SQLException;
19
	
20
	@DeleteWith
21
	@From(PapKeyWord.class)
22
	int delete(Connection con,String id)throws SQLException;
23
}

+ 43 - 0
src/main/java/com/ekexiu/portal/dao/PaperAgreeDao.java

@ -0,0 +1,43 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.annotation.DefaultValue;
7
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.orm.annotation.dao.Column;
9
import org.jfw.apt.orm.annotation.dao.DAO;
10
import org.jfw.apt.orm.annotation.dao.method.From;
11
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
12
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
13
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
14
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
15
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
16

17
import com.ekexiu.portal.po.PaperAgree;
18

19
@DAO
20
public interface PaperAgreeDao {
21
	@Insert
22
	int insert(Connection con,PaperAgree pa) throws SQLException;
23
	
24
//	@DeleteWith
25
//	@From(PaperAgree.class)
26
//	int delete(Connection con,String opId,String paperId) throws SQLException;
27
	
28
	@DeleteWith
29
	@From(PaperAgree.class)
30
	int delete(Connection con,String paperId) throws SQLException;
31
	
32
	@Nullable
33
	@SelectOne
34
	PaperAgree query(Connection con,String opId,String paperId) throws SQLException;
35
	
36
	
37
	@QueryVal
38
	@From(PaperAgree.class)
39
	@Column(handlerClass = IntHandler.class, value = "COUNT(1)")
40
	@DefaultValue("0")
41
	int query(Connection con,String paperId) throws SQLException;
42

43
}

+ 23 - 0
src/main/java/com/ekexiu/portal/dao/PatKeyWordDao.java

@ -0,0 +1,23 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.orm.annotation.dao.Batch;
7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
10
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
11

12
import com.ekexiu.portal.po.PatKeyWord;
13

14
@DAO
15
public interface PatKeyWordDao {
16
	@Insert
17
	@Batch
18
	int[] insert(Connection con,PatKeyWord[] okws)throws SQLException;
19
	
20
	@DeleteWith
21
	@From(PatKeyWord.class)
22
	int delete(Connection con,String id)throws SQLException;
23
}

+ 42 - 0
src/main/java/com/ekexiu/portal/dao/PatentAgreeDao.java

@ -0,0 +1,42 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.annotation.DefaultValue;
7
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.orm.annotation.dao.Column;
9
import org.jfw.apt.orm.annotation.dao.DAO;
10
import org.jfw.apt.orm.annotation.dao.method.From;
11
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
12
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
13
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
14
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
15
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
16

17
import com.ekexiu.portal.po.PatentAgree;
18

19
@DAO
20
public interface PatentAgreeDao {
21
	@Insert
22
	int insert(Connection con,PatentAgree pa) throws SQLException;
23
	
24
//	@DeleteWith
25
//	@From(PatentAgree.class)
26
//	int delete(Connection con,String opId,String patentId) throws SQLException;
27
	
28
	@DeleteWith
29
	@From(PatentAgree.class)
30
	int delete(Connection con,String patentId) throws SQLException;
31
	
32
	@Nullable
33
	@SelectOne
34
	PatentAgree query(Connection con,String opId,String patentId) throws SQLException;
35
	
36
	
37
	@QueryVal
38
	@From(PatentAgree.class)
39
	@Column(handlerClass = IntHandler.class, value = "COUNT(1)")
40
	@DefaultValue("0")
41
	int query(Connection con,String patentId) throws SQLException;
42
}

+ 71 - 11
src/main/java/com/ekexiu/portal/dao/PpaperDao.java

@ -1,7 +1,10 @@
1 1
package com.ekexiu.portal.dao;
2 2

3 3
import java.sql.Connection;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
4 6
import java.sql.SQLException;
7
import java.util.ArrayList;
5 8
import java.util.List;
6 9

7 10
import org.jfw.apt.annotation.Nullable;
@ -27,28 +30,28 @@ import com.ekexiu.portal.po.Ppaper;
27 30
import com.ekexiu.portal.pojo.AssedPaper;
28 31

29 32
@DAO
30
public interface PpaperDao {
33
public abstract class PpaperDao {
31 34

32 35
	@SelectOne
33 36
	@Nullable
34
	Ppaper query(Connection con, String id) throws SQLException;
37
	public abstract	Ppaper query(Connection con, String id) throws SQLException;
35 38

36 39
	@SelectList
37
	List<Ppaper> query(Connection con, @In String[] id) throws SQLException;
40
	public abstract List<Ppaper> query(Connection con, @In String[] id) throws SQLException;
38 41

39 42
	@UpdateWith
40 43
	@From(Ppaper.class)
41
	int update(Connection con, String id, @Set @Nullable String keywords) throws SQLException;
44
	public abstract int update(Connection con, String id, @Set @Nullable String keywords) throws SQLException;
42 45

43 46
	@PageQuery
44 47
	@OrderBy(" ORDER BY ASS_TIME DESC,ID ASC")
45
	PageQueryResult<AssedPaper> pageQueryWithProfessor(Connection con,
48
	public abstract PageQueryResult<AssedPaper> pageQueryWithProfessor(Connection con,
46 49
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "A.PROFESSOR_ID=?" })  String professorId,
47 50
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "P.NAME LIKE ?" }) String name, int pageSize, int pageNo) throws SQLException;
48 51

49 52
	@PageQuery
50 53
	@OrderBy(" ORDER BY ASS_TIME DESC,ID ASC")
51
	PageQueryResult<AssedPaper> pageQueryWithAuthor(Connection con,
54
	public abstract PageQueryResult<AssedPaper> pageQueryWithAuthor(Connection con,
52 55
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "A.NAME=?" }) String author,
53 56
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "((A.PROFESSOR_ID=?)  OR  (A.PROFESSOR_ID='################################'))" }) String id,
54 57
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "P.NAME LIKE ?" }) String name, int pageSize, int pageNo) throws SQLException;
@ -56,20 +59,77 @@ public interface PpaperDao {
56 59
	@From(Ppaper.class)
57 60
	@UpdateWith
58 61
	@SetSentence("PAGE_VIEWS = PAGE_VIEWS + 1")
59
	 int incPageViews(Connection con,String id)throws SQLException;
62
	public abstract int incPageViews(Connection con,String id)throws SQLException;
60 63
	
61 64
	@PageSelect
62 65
	@OrderBy(" ORDER BY SORT_NUM DESC,CREATE_TIME DESC,ID DESC")
63
	PageQueryResult<Ppaper> query(Connection con,int pageSize,int pageNo) throws SQLException;
66
	public abstract PageQueryResult<Ppaper> query(Connection con,int pageSize,int pageNo) throws SQLException;
64 67
	
65 68
	@PageSelect
66 69
	@OrderBy(" ORDER BY SORT_NUM DESC,CREATE_TIME DESC,ID DESC")
67 70
	@Or
68
	PageQueryResult<Ppaper> query(Connection con,@Alias({"name","authors","keywords"}) @Like String cnt,int pageSize,int pageNo) throws SQLException;
71
	public abstract PageQueryResult<Ppaper> query(Connection con,@Alias({"name","authors","keywords"}) @Like String cnt,int pageSize,int pageNo) throws SQLException;
69 72
	
70 73
	
71 74
	@SelectOne
72 75
	@Nullable
73
	Ppaper query(Connection con,long shareId)throws SQLException;
74

76
	public abstract Ppaper query(Connection con,long shareId)throws SQLException;
77
	
78
	public String[] queryPaperIdWithSameKeyWord(Connection con,String id,int rows)throws SQLException{
79
		List<String> ret = new ArrayList<String>();
80
		String sql = "select id,count(1) sort from pap_key_word where kw in (select kw from pap_key_word where id=?) and id <>? group by id order by sort desc limit ?";
81
		PreparedStatement ps = con.prepareStatement(sql);
82
		try{
83
			ps.setString(1, id);
84
			ps.setString(2, id);
85
			ps.setInt(3, rows);
86
			ResultSet rs = ps.executeQuery();
87
			try{
88
				while(rs.next()){
89
					ret.add(rs.getString(1));
90
				}
91
			}finally{
92
				try{rs.close();}catch(Exception e1){}
93
			}
94
		}finally{
95
			try{ps.close();}catch(Exception e2){}
96
		}
97
		return ret.isEmpty()?null:ret.toArray(new String[ret.size()]);		
98
	}
99
	
100
	public String[] queryPatentIdWithKeyWord(Connection con, String[] kws, int rows) throws SQLException {
101
		List<String> ret = new ArrayList<String>();
102
		StringBuilder sql = new StringBuilder();
103
		sql.append("select id,count(1) sort from pap_key_word where kw in (");
104
		for (int i = 0; i < kws.length; ++i) {
105
			sql.append("?,");
106
		}
107
		sql.delete(sql.length() - 1, sql.length());
108
		sql.append(") group by id order by sort desc limit ?");
109
		PreparedStatement ps = con.prepareStatement(sql.toString());
110
		try {
111
			int idx = 1;
112
			for (String kw : kws) {
113
				ps.setString(idx++, kw);
114
			}
115
			ps.setInt(idx++, rows);
116
			ResultSet rs = ps.executeQuery();
117
			try {
118
				while (rs.next()) {
119
					ret.add(rs.getString(1));
120
				}
121
			} finally {
122
				try {
123
					rs.close();
124
				} catch (Exception e1) {
125
				}
126
			}
127
		} finally {
128
			try {
129
				ps.close();
130
			} catch (Exception e2) {
131
			}
132
		}
133
		return ret.isEmpty() ? null : ret.toArray(new String[ret.size()]);
134
	}
75 135
}

+ 84 - 15
src/main/java/com/ekexiu/portal/dao/PpatentDao.java

@ -1,7 +1,10 @@
1 1
package com.ekexiu.portal.dao;
2 2

3 3
import java.sql.Connection;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
4 6
import java.sql.SQLException;
7
import java.util.ArrayList;
5 8
import java.util.List;
6 9

7 10
import org.jfw.apt.annotation.Nullable;
@ -27,47 +30,113 @@ import com.ekexiu.portal.po.Ppatent;
27 30
import com.ekexiu.portal.pojo.AssedPatent;
28 31

29 32
@DAO
30
public interface PpatentDao {
33
public abstract class PpatentDao {
31 34
	@SelectOne
32 35
	@Nullable
33
	Ppatent query(Connection con, String id) throws SQLException;
36
	public abstract Ppatent query(Connection con, String id) throws SQLException;
34 37

35 38
	@SelectList
36
	List<Ppatent> query(Connection con, @In String[] id) throws SQLException;
39
	public abstract List<Ppatent> query(Connection con, @In String[] id) throws SQLException;
37 40

38 41
	@UpdateWith
39 42
	@From(Ppatent.class)
40
	int update(Connection con, String id, @Set String keywords) throws SQLException;
43
	public abstract int update(Connection con, String id, @Set String keywords) throws SQLException;
41 44

42 45
	@PageQuery
43 46
	@OrderBy(" ORDER BY ASS_TIME DESC,ID ASC")
44
	PageQueryResult<AssedPatent> pageQueryWithProfessor(Connection con,
47
	public abstract PageQueryResult<AssedPatent> pageQueryWithProfessor(Connection con,
45 48
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "A.PROFESSOR_ID=?" }) String professId,
46 49
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "P.NAME LIKE ?" }) String name, int pageSize, int pageNo) throws SQLException;
47 50

48 51
	@PageQuery
49 52
	@OrderBy(" ORDER BY ASS_TIME DESC,ID ASC")
50
	PageQueryResult<AssedPatent> pageQueryWithAuthor(Connection con,
53
	public abstract PageQueryResult<AssedPatent> pageQueryWithAuthor(Connection con,
51 54
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "A.NAME=?" }) String author,
52
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "((A.PROFESSOR_ID=?)  OR  (A.PROFESSOR_ID='################################'))" }) String id,
55
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = {
56
					"((A.PROFESSOR_ID=?)  OR  (A.PROFESSOR_ID='################################'))" }) String id,
53 57
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "P.NAME LIKE ?" }) String name, int pageSize, int pageNo) throws SQLException;
54
	
58

55 59
	@From(Ppatent.class)
56 60
	@UpdateWith
57 61
	@SetSentence("PAGE_VIEWS = PAGE_VIEWS + 1")
58
	public abstract int incPageViews(Connection con,String id)throws SQLException;
59
	
60
	
62
	public abstract int incPageViews(Connection con, String id) throws SQLException;
63

61 64
	@PageSelect
62 65
	@OrderBy(" ORDER BY SORT_NUM DESC,CREATE_TIME DESC,ID DESC")
63
	PageQueryResult<Ppatent> query(Connection con,int pageSize,int pageNo) throws SQLException;
64
	
66
	public abstract PageQueryResult<Ppatent> query(Connection con, int pageSize, int pageNo) throws SQLException;
67

65 68
	@PageSelect
66 69
	@OrderBy(" ORDER BY SORT_NUM DESC,CREATE_TIME DESC,ID DESC")
67 70
	@Or
68
	PageQueryResult<Ppatent> query(Connection con,@Alias({"code","authors","name","keywords"}) @Like String cnt,int pageSize,int pageNo) throws SQLException;
71
	public abstract PageQueryResult<Ppatent> query(Connection con, @Alias({ "code", "authors", "name", "keywords" }) @Like String cnt, int pageSize, int pageNo)
72
			throws SQLException;
69 73

70 74
	@SelectOne
71 75
	@Nullable
72
	Ppatent query(Connection con,long shareId)throws SQLException;
76
	public abstract Ppatent query(Connection con, long shareId) throws SQLException;
77

78
	public String[] queryPatentIdWithSameKeyWord(Connection con, String id, int rows) throws SQLException {
79
		List<String> ret = new ArrayList<String>();
80
		String sql = "select id,count(1) sort from pat_key_word where kw in (select kw from pat_key_word where id=?) and id <>? group by id order by sort desc limit ?";
81
		PreparedStatement ps = con.prepareStatement(sql);
82
		try {
83
			ps.setString(1, id);
84
			ps.setString(2, id);
85
			ps.setInt(3, rows);
86
			ResultSet rs = ps.executeQuery();
87
			try {
88
				while (rs.next()) {
89
					ret.add(rs.getString(1));
90
				}
91
			} finally {
92
				try {
93
					rs.close();
94
				} catch (Exception e1) {
95
				}
96
			}
97
		} finally {
98
			try {
99
				ps.close();
100
			} catch (Exception e2) {
101
			}
102
		}
103
		return ret.isEmpty() ? null : ret.toArray(new String[ret.size()]);
104
	}
105

106
	public String[] queryPatentIdWithKeyWord(Connection con, String[] kws, int rows) throws SQLException {
107
		List<String> ret = new ArrayList<String>();
108
		StringBuilder sql = new StringBuilder();
109
		sql.append("select id,count(1) sort from pat_key_word where kw in (");
110
		for (int i = 0; i < kws.length; ++i) {
111
			sql.append("?,");
112
		}
113
		sql.delete(sql.length() - 1, sql.length());
114
		sql.append(") group by id order by sort desc limit ?");
115
		PreparedStatement ps = con.prepareStatement(sql.toString());
116
		try {
117
			int idx = 1;
118
			for (String kw : kws) {
119
				ps.setString(idx++, kw);
120
			}
121
			ps.setInt(idx++, rows);
122
			ResultSet rs = ps.executeQuery();
123
			try {
124
				while (rs.next()) {
125
					ret.add(rs.getString(1));
126
				}
127
			} finally {
128
				try {
129
					rs.close();
130
				} catch (Exception e1) {
131
				}
132
			}
133
		} finally {
134
			try {
135
				ps.close();
136
			} catch (Exception e2) {
137
			}
138
		}
139
		return ret.isEmpty() ? null : ret.toArray(new String[ret.size()]);
140
	}
141

73 142
}

+ 25 - 0
src/main/java/com/ekexiu/portal/dao/ProKeyWordDao.java

@ -0,0 +1,25 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.orm.annotation.dao.Batch;
7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
10
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
11

12
import com.ekexiu.portal.po.ProKeyWord;
13

14
@DAO
15
public interface ProKeyWordDao {
16

17
	@Insert
18
	@Batch
19
	int[] insert(Connection con,ProKeyWord[] pkw)throws SQLException;
20
	
21
	@DeleteWith
22
	@From(ProKeyWord.class)
23
	int delete(Connection con,String id)throws SQLException;
24
	
25
}

+ 30 - 1
src/main/java/com/ekexiu/portal/dao/ProfessorDao.java

@ -17,6 +17,7 @@ import org.jfw.apt.orm.annotation.dao.method.From;
17 17
import org.jfw.apt.orm.annotation.dao.method.Or;
18 18
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
19 19
import org.jfw.apt.orm.annotation.dao.method.Select;
20
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
20 21
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
21 22
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
22 23
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
@ -26,6 +27,7 @@ import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
26 27
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
27 28
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
28 29
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
30
import org.jfw.apt.orm.annotation.dao.param.In;
29 31
import org.jfw.apt.orm.annotation.dao.param.LessThan;
30 32
import org.jfw.apt.orm.annotation.dao.param.Set;
31 33
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
@ -45,6 +47,11 @@ import com.ekexiu.portal.pojo.UserInfo;
45 47
public abstract class ProfessorDao {
46 48
	@Insert
47 49
	public abstract int insert(Connection con, Professor professor) throws SQLException;
50
	
51
	@UpdateWith
52
	@From(Professor.class)
53
	@SetSentence("PAGE_VIEWS = PAGE_VIEWS + 1")
54
	public abstract int incPageViews(Connection con,String id)throws SQLException;
48 55

49 56
	@Update
50 57
	public abstract int update(Connection con, Professor professor) throws SQLException;
@ -1946,5 +1953,27 @@ public abstract class ProfessorDao {
1946 1953
			}
1947 1954
		}
1948 1955
	}
1949
	
1956
	public String[] queryProfessorIdWithSameKeyWord(Connection con,String id,int rows)throws SQLException{
1957
		List<String> ret = new ArrayList<String>();
1958
		String sql = "select id,count(1) sort from pro_key_word where kw in (select kw from pro_key_word where id=?) and id <>? group by id order by sort desc limit ?";
1959
		PreparedStatement ps = con.prepareStatement(sql);
1960
		try{
1961
			ps.setString(1, id);
1962
			ps.setString(2, id);
1963
			ps.setInt(3, rows);
1964
			ResultSet rs = ps.executeQuery();
1965
			try{
1966
				while(rs.next()){
1967
					ret.add(rs.getString(1));
1968
				}
1969
			}finally{
1970
				try{rs.close();}catch(Exception e1){}
1971
			}
1972
		}finally{
1973
			try{ps.close();}catch(Exception e2){}
1974
		}
1975
		return ret.isEmpty()?null:ret.toArray(new String[ret.size()]);		
1976
	}
1977
	@SelectList
1978
	public abstract List<Professor> query(Connection con,@In String[] id)throws SQLException; 
1950 1979
}

+ 23 - 0
src/main/java/com/ekexiu/portal/dao/ResKeyWordDao.java

@ -0,0 +1,23 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.orm.annotation.dao.Batch;
7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
10
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
11

12
import com.ekexiu.portal.po.ResKeyWord;
13

14
@DAO
15
public interface ResKeyWordDao {
16
	@Insert
17
	@Batch
18
	int[] insert(Connection con,ResKeyWord[] okws)throws SQLException;
19
	
20
	@DeleteWith
21
	@From(ResKeyWord.class)
22
	int delete(Connection con,String id)throws SQLException;
23
}

+ 26 - 0
src/main/java/com/ekexiu/portal/dao/ResourceDao.java

@ -24,6 +24,7 @@ import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
24 24
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
25 25
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
26 26
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
27
import org.jfw.apt.orm.annotation.dao.param.In;
27 28
import org.jfw.apt.orm.annotation.dao.param.Like;
28 29
import org.jfw.apt.orm.annotation.dao.param.Set;
29 30
import org.jfw.util.PageQueryResult;
@ -1778,4 +1779,29 @@ public abstract class ResourceDao {
1778 1779
	@SelectOne
1779 1780
	@Nullable
1780 1781
	public abstract Resource query(Connection con,long shareId)throws SQLException;
1782
	
1783
	@SelectList
1784
	public abstract List<Resource> query(Connection con,@In String[] resourceId)throws SQLException;
1785
	
1786
	public String[] queryResourceIdWithSameKeyWord(Connection con,String id,int rows)throws SQLException{
1787
		List<String> ret = new ArrayList<String>();
1788
		String sql = "select id,count(1) sort from res_key_word where kw in (select kw from res_key_word where id=?) and id <>? group by id order by sort desc limit ?";
1789
		PreparedStatement ps = con.prepareStatement(sql);
1790
		try{
1791
			ps.setString(1, id);
1792
			ps.setString(2, id);
1793
			ps.setInt(3, rows);
1794
			ResultSet rs = ps.executeQuery();
1795
			try{
1796
				while(rs.next()){
1797
					ret.add(rs.getString(1));
1798
				}
1799
			}finally{
1800
				try{rs.close();}catch(Exception e1){}
1801
			}
1802
		}finally{
1803
			try{ps.close();}catch(Exception e2){}
1804
		}
1805
		return ret.isEmpty()?null:ret.toArray(new String[ret.size()]);		
1806
	}
1781 1807
}

+ 12 - 1
src/main/java/com/ekexiu/portal/job/ArticleTaskJobEntry.java

@ -13,6 +13,7 @@ import org.jfw.apt.annotation.Bean;
13 13

14 14
import com.ekexiu.portal.dao.ArticleDao;
15 15
import com.ekexiu.portal.po.Article;
16
import com.ekexiu.portal.service.ArticleService;
16 17

17 18
@Bean
18 19
public class ArticleTaskJobEntry implements Runnable {
@ -23,6 +24,16 @@ public class ArticleTaskJobEntry implements Runnable {
23 24
	private DataSource dataSource;
24 25
	@Autowrie
25 26
	private ArticleDao articleDao;
27
	@Autowrie
28
	private ArticleService articleService;
29
	
30
	
31
	public ArticleService getArticleService() {
32
		return articleService;
33
	}
34
	public void setArticleService(ArticleService articleService) {
35
		this.articleService = articleService;
36
	}
26 37
	public long getDelayTime() {
27 38
		return delayTime;
28 39
	}
@ -50,7 +61,7 @@ public class ArticleTaskJobEntry implements Runnable {
50 61
				SimpleDateFormat df = new SimpleDateFormat(this.dateFormat);
51 62
				List<Article> articles = this.articleDao.queryTiming(con, df.format(new Date()));
52 63
				for (Article article : articles) {
53
					this.articleDao.updateStatus(con, article.getArticleId(), "1");
64
					this.articleService.publish(con,article.getArticleId());
54 65
					logger.info("定时发布文章:"+article.getArticleId()+"--"+df.format(new Date()));
55 66
				}
56 67
                con.commit();

+ 59 - 25
src/main/java/com/ekexiu/portal/job/HotKeyJobEntry.java

@ -1,13 +1,20 @@
1 1
package com.ekexiu.portal.job;
2 2

3 3
import java.sql.Connection;
4
import java.sql.ResultSet;
5
import java.sql.SQLException;
6
import java.sql.Statement;
4 7
import java.util.ArrayList;
5
import java.util.List;
8
import java.util.Collections;
9
import java.util.Comparator;
10
import java.util.HashMap;
11
import java.util.Map;
6 12

7 13
import javax.sql.DataSource;
8 14

9 15
import org.jfw.apt.annotation.Autowrie;
10 16
import org.jfw.apt.annotation.Bean;
17
import org.jfw.util.jdbc.JdbcUtil;
11 18

12 19
import com.ekexiu.portal.pojo.DataDictCode;
13 20
import com.ekexiu.portal.service.DataDictService;
@ -53,41 +60,68 @@ public class HotKeyJobEntry extends DictTaskJobEntry implements Runnable {
53 60
		this.dataDictService = dataDictService;
54 61
	}
55 62

63
	private void addEntry(String caption, Map<String, DataDictCode> map) {
64
		DataDictCode item = map.get(caption);
65
		if (item == null) {
66
			item = new DataDictCode();
67
			item.setCaption(caption);
68
			item.setCount(1);
69
			map.put(caption, item);
70
		} else {
71
			item.setCount(1 + item.getCount());
72
		}
73
	}
74

75
	private void addEntrys(Connection con, String sql, Map<String, DataDictCode> map) throws SQLException {
76
		Statement st = con.createStatement();
77
		try {
78
			ResultSet rs = st.executeQuery(sql);
79
			try {
80
				while (rs.next()) {
81
					addEntry(rs.getString(1), map);
82
				}
83
			} finally {
84
				JdbcUtil.close(rs);
85
			}
86
		} finally {
87
			JdbcUtil.close(st);
88
		}
89
	}
90

56 91
	@Override
57 92
	public void run() {
93

94
		Map<String, DataDictCode> tmpMap = new HashMap<String, DataDictCode>();
58 95
		try {
59 96
			Connection con = this.dataSource.getConnection();
60 97
			try {
61
				Items items = fillSetValue(con,
62
						"SELECT SUBJECT FROM PROFESSOR UNION ALL SELECT INDUSTRY FROM PROFESSOR UNION ALL SELECT SUBJECT FROM ARTICLE UNION ALL SELECT SUBJECT FROM RESOURCE");
63
				List<Item> list = items.getItemByDescSort();
64
				List<DataDictCode> codes = new ArrayList<DataDictCode>();
65
				for (Item item : list) {
66
					if (item.getValue() > 1) {
67
						DataDictCode code = new DataDictCode();
68
						code.setCount(item.getValue());
69
						code.setCaption(item.getCaption());
70
						codes.add(code);
98
				addEntrys(con, "SELECT KW FROM ART_KEY_WORD", tmpMap);
99
				addEntrys(con, "SELECT KW FROM PRO_KEY_WORD", tmpMap);
100
				addEntrys(con, "SELECT KW FROM ORG_KEY_WORD", tmpMap);
101
				addEntrys(con, "SELECT KW FROM RES_KEY_WORD", tmpMap);
102
				addEntrys(con, "SELECT KW FROM PAP_KEY_WORD", tmpMap);
103
				addEntrys(con, "SELECT KW FROM PAT_KEY_WORD", tmpMap);
104
				ArrayList<DataDictCode> list = new ArrayList<DataDictCode>(tmpMap.size());
105
				list.addAll(tmpMap.values());
106
				Collections.sort(list, new Comparator<DataDictCode>() {
107
					public int compare(DataDictCode o1, DataDictCode o2) {
108
						long l = o2.getCount() - o1.getCount();
109
						if (l == 0)
110
							return 0;
111
						else if (l > 0)
112
							return 1;
113
						else
114
							return -1;
71 115
					}
72
				}
73
				this.dataDictService.setHotKey(codes);
74

116
				});
117
				this.dataDictService.setHotKey(list);
75 118
			} catch (Exception e) {
76
				try {
77
					con.rollback();
78
				} catch (Exception e1) {
79
					e1.printStackTrace();
80
				}
81
			} finally {
82
				try {
83
					con.close();
84
				} catch (Exception e) {
85 119
					e.printStackTrace();
86
				}
120
			} finally {
121
				JdbcUtil.close(con);
87 122
			}
88 123
		} catch (Exception e) {
89 124
			e.printStackTrace();
90 125
		}
91

92 126
	}
93 127
}

+ 26 - 0
src/main/java/com/ekexiu/portal/po/ArtKeyWord.java

@ -0,0 +1,26 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.Table;
5
import org.jfw.apt.orm.core.enums.DE;
6

7
@Table
8
public class ArtKeyWord {
9
	private String id;
10
	private String kw;
11
	
12
	@Column(DE.id_32)
13
	public String getId() {
14
		return id;
15
	}
16
	public void setId(String id) {
17
		this.id = id;
18
	}
19
	@Column(DE.text_de)
20
	public String getKw() {
21
		return kw;
22
	}
23
	public void setKw(String kw) {
24
		this.kw = kw;
25
	}
26
}

+ 45 - 0
src/main/java/com/ekexiu/portal/po/ArticleOrg.java

@ -0,0 +1,45 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.Table;
5
import org.jfw.apt.orm.annotation.entry.Unique;
6
import org.jfw.apt.orm.annotation.entry.Uniques;
7
import org.jfw.apt.orm.core.enums.DE;
8

9
import com.ekexiu.portal.basepo.CreateTimeSupported;
10
@Table
11
@Uniques(@Unique(clolumns = { "articleId", "orgId" }, name = "ARTICLE_ORG_UQ"))
12
public class ArticleOrg implements CreateTimeSupported {
13
	private String articleId;
14
	private String orgId;
15
	private String createTime;
16
	private Article article;
17
	@Override
18
	public String getCreateTime() {
19
		return this.createTime;
20
	}
21
	@Override
22
	public void setCreateTime(String createTime) {
23
		this.createTime = createTime;
24
	}
25
	@Column(DE.id_32)
26
	public String getArticleId() {
27
		return articleId;
28
	}
29
	public void setArticleId(String articleId) {
30
		this.articleId = articleId;
31
	}
32
	@Column(DE.id_32)
33
	public String getOrgId() {
34
		return orgId;
35
	}
36
	public void setOrgId(String orgId) {
37
		this.orgId = orgId;
38
	}
39
	public Article getArticle() {
40
		return article;
41
	}
42
	public void setArticle(Article article) {
43
		this.article = article;
44
	}
45
}

+ 14 - 5
src/main/java/com/ekexiu/portal/po/LeaveWord.java

@ -14,9 +14,10 @@ public class LeaveWord implements CreateTimeSupported {
14 14
	private String id;
15 15
	private String content;
16 16
	private String sender;
17
	private String articleId;
17
	private String objId;
18 18
	private String createTime;
19 19
	private long orderKey;
20
	private String category;
20 21
	private EditProfessor professor;
21 22
	
22 23
	public EditProfessor getProfessor() {
@ -47,11 +48,11 @@ public class LeaveWord implements CreateTimeSupported {
47 48
		this.sender = sender;
48 49
	}
49 50
	@Column(DE.id_32)
50
	public String getArticleId() {
51
		return articleId;
51
	public String getObjId() {
52
		return objId;
52 53
	}
53
	public void setArticleId(String articleId) {
54
		this.articleId = articleId;
54
	public void setObjId(String objId) {
55
		this.objId = objId;
55 56
	}
56 57
	public String getCreateTime() {
57 58
		return createTime;
@ -66,5 +67,13 @@ public class LeaveWord implements CreateTimeSupported {
66 67
	public void setOrderKey(long orderKey) {
67 68
		this.orderKey = orderKey;
68 69
	}
70
	@Column(DE.singleChar)
71
	public String getCategory() {
72
		return category;
73
	}
74
	public void setCategory(String category) {
75
		this.category = category;
76
	}
77
	
69 78
	
70 79
}

+ 26 - 0
src/main/java/com/ekexiu/portal/po/OrgKeyWord.java

@ -0,0 +1,26 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.Table;
5
import org.jfw.apt.orm.core.enums.DE;
6

7
@Table
8
public class OrgKeyWord {
9
	private String id;
10
	private String kw;
11
	
12
	@Column(DE.id_32)
13
	public String getId() {
14
		return id;
15
	}
16
	public void setId(String id) {
17
		this.id = id;
18
	}
19
	@Column(DE.text_de)
20
	public String getKw() {
21
		return kw;
22
	}
23
	public void setKw(String kw) {
24
		this.kw = kw;
25
	}
26
}

+ 26 - 0
src/main/java/com/ekexiu/portal/po/PapKeyWord.java

@ -0,0 +1,26 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.Table;
5
import org.jfw.apt.orm.core.enums.DE;
6

7
@Table
8
public class PapKeyWord {
9
	private String id;
10
	private String kw;
11
	
12
	@Column(DE.id_32)
13
	public String getId() {
14
		return id;
15
	}
16
	public void setId(String id) {
17
		this.id = id;
18
	}
19
	@Column(DE.text_de)
20
	public String getKw() {
21
		return kw;
22
	}
23
	public void setKw(String kw) {
24
		this.kw = kw;
25
	}
26
}

+ 37 - 0
src/main/java/com/ekexiu/portal/po/PaperAgree.java

@ -0,0 +1,37 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
import com.ekexiu.portal.basepo.CreateTimeSupported;
9

10
@PrimaryKey({"paperId","opId"})
11
@Table
12
public class PaperAgree implements CreateTimeSupported {
13
	private String opId;
14
	private String paperId;
15
	private String createTime;
16
	@Column(DE.id_32)
17
	public String getOpId() {
18
		return opId;
19
	}
20
	public void setOpId(String opId) {
21
		this.opId = opId;
22
	}
23
	@Column(DE.id_32)
24
	public String getPaperId() {
25
		return paperId;
26
	}
27
	public void setPaperId(String paperId) {
28
		this.paperId = paperId;
29
	}
30
	public String getCreateTime() {
31
		return createTime;
32
	}
33
	public void setCreateTime(String createTime) {
34
		this.createTime = createTime;
35
	}
36
	
37
}

+ 26 - 0
src/main/java/com/ekexiu/portal/po/PatKeyWord.java

@ -0,0 +1,26 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.Table;
5
import org.jfw.apt.orm.core.enums.DE;
6

7
@Table
8
public class PatKeyWord {
9
	private String id;
10
	private String kw;
11
	
12
	@Column(DE.id_32)
13
	public String getId() {
14
		return id;
15
	}
16
	public void setId(String id) {
17
		this.id = id;
18
	}
19
	@Column(DE.text_de)
20
	public String getKw() {
21
		return kw;
22
	}
23
	public void setKw(String kw) {
24
		this.kw = kw;
25
	}
26
}

+ 37 - 0
src/main/java/com/ekexiu/portal/po/PatentAgree.java

@ -0,0 +1,37 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
import com.ekexiu.portal.basepo.CreateTimeSupported;
9

10
@PrimaryKey({"patentId","opId"})
11
@Table
12
public class PatentAgree implements CreateTimeSupported {
13
	private String opId;
14
	private String patentId;
15
	private String createTime;
16
	@Column(DE.id_32)
17
	public String getOpId() {
18
		return opId;
19
	}
20
	public void setOpId(String opId) {
21
		this.opId = opId;
22
	}
23
	@Column(DE.id_32)
24
	public String getPatentId() {
25
		return patentId;
26
	}
27
	public void setPatentId(String patentId) {
28
		this.patentId = patentId;
29
	}
30
	public String getCreateTime() {
31
		return createTime;
32
	}
33
	public void setCreateTime(String createTime) {
34
		this.createTime = createTime;
35
	}
36
	
37
}

+ 28 - 0
src/main/java/com/ekexiu/portal/po/ProKeyWord.java

@ -0,0 +1,28 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.Table;
5
import org.jfw.apt.orm.core.enums.DE;
6

7
@Table
8
public class ProKeyWord {
9

10
	private String id;
11
	private String kw;
12
	
13
	@Column(DE.id_32)
14
	public String getId() {
15
		return id;
16
	}
17
	public void setId(String id) {
18
		this.id = id;
19
	}
20
	@Column(DE.text_de)
21
	public String getKw() {
22
		return kw;
23
	}
24
	public void setKw(String kw) {
25
		this.kw = kw;
26
	}
27
	
28
}

+ 9 - 1
src/main/java/com/ekexiu/portal/po/Professor.java

@ -55,6 +55,7 @@ public class Professor implements CreateTimeSupported, ModifyTimeSupported{
55 55
	private Integer growthValue;
56 56
	private String scorePercent;
57 57
	private long shareId;
58
	private long pageViews;
58 59
	
59 60
	private Organization organization;
60 61
	private List<Resource> resources;
@ -342,5 +343,12 @@ public class Professor implements CreateTimeSupported, ModifyTimeSupported{
342 343
		this.shareId = shareId;
343 344
	}
344 345
345
	
346
	@Column(DE.bigSerial)
347
	public long getPageViews() {
348
		return pageViews;
349
	}
350
351
	public void setPageViews(long pageViews) {
352
		this.pageViews = pageViews;
353
	}
346 354
}

+ 26 - 0
src/main/java/com/ekexiu/portal/po/ResKeyWord.java

@ -0,0 +1,26 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.Table;
5
import org.jfw.apt.orm.core.enums.DE;
6

7
@Table
8
public class ResKeyWord {
9
	private String id;
10
	private String kw;
11
	
12
	@Column(DE.id_32)
13
	public String getId() {
14
		return id;
15
	}
16
	public void setId(String id) {
17
		this.id = id;
18
	}
19
	@Column(DE.text_de)
20
	public String getKw() {
21
		return kw;
22
	}
23
	public void setKw(String kw) {
24
		this.kw = kw;
25
	}
26
}

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

@ -10,7 +10,7 @@ import java.io.InputStream;
10 10
import java.sql.Connection;
11 11
import java.sql.SQLException;
12 12
import java.text.SimpleDateFormat;
13
import java.util.ArrayList;
13
import java.util.Collections;
14 14
import java.util.Date;
15 15
import java.util.List;
16 16

@ -29,6 +29,7 @@ import org.jfw.util.io.IoUtil;
29 29

30 30
import com.ekexiu.portal.dao.ArticleAgreeDao;
31 31
import com.ekexiu.portal.dao.ArticleDao;
32
import com.ekexiu.portal.dao.ArticleOrgDao;
32 33
import com.ekexiu.portal.dao.ArticleProDao;
33 34
import com.ekexiu.portal.dao.ArticleResDao;
34 35
import com.ekexiu.portal.dao.LeaveWordDao;
@ -39,6 +40,7 @@ import com.ekexiu.portal.dao.ResourceDao;
39 40
import com.ekexiu.portal.dao.WatchDao;
40 41
import com.ekexiu.portal.po.Article;
41 42
import com.ekexiu.portal.po.ArticleAgree;
43
import com.ekexiu.portal.po.ArticleOrg;
42 44
import com.ekexiu.portal.po.ArticlePro;
43 45
import com.ekexiu.portal.po.ArticleRes;
44 46
import com.ekexiu.portal.po.Image;
@ -52,7 +54,7 @@ public class ArticleService {
52 54
	private File articlePath;
53 55
	private String dateFormat = "yyyyMMdd";
54 56
	private String timeFormat = "yyyyMMddHHmmss";
55
	private int artMaxLen=70;
57
	private int artMaxLen = 70;
56 58
	private static final String JPG = "jpg";
57 59
	public static final String MAX_MODIFYTIME = "9";
58 60
	@Autowrie
@ -80,6 +82,28 @@ public class ArticleService {
80 82
	@Autowrie
81 83
	private ArticleResDao articleResDao;
82 84

85
	@Autowrie
86
	private ArticleOrgDao articleOrgDao;
87

88
	@Autowrie
89
	private KeyWordService keyWordService;
90

91
	public KeyWordService getKeyWordService() {
92
		return keyWordService;
93
	}
94

95
	public void setKeyWordService(KeyWordService keyWordService) {
96
		this.keyWordService = keyWordService;
97
	}
98

99
	public ArticleOrgDao getArticleOrgDao() {
100
		return articleOrgDao;
101
	}
102

103
	public void setArticleOrgDao(ArticleOrgDao articleOrgDao) {
104
		this.articleOrgDao = articleOrgDao;
105
	}
106

83 107
	public String getDateFormat() {
84 108
		return dateFormat;
85 109
	}
@ -127,7 +151,7 @@ public class ArticleService {
127 151
	public void setArticleDao(ArticleDao articleDao) {
128 152
		this.articleDao = articleDao;
129 153
	}
130
	
154

131 155
	public ArticleAgreeDao getArticleAgreeDao() {
132 156
		return articleAgreeDao;
133 157
	}
@ -223,7 +247,7 @@ public class ArticleService {
223 247
		out.flush();
224 248
		return out.toByteArray();
225 249
	}
226
	
250

227 251
	private byte[] readTmpFile(String fn) throws JfwBaseException {
228 252
		File file = new File(this.tmpPath, fn);
229 253
		if (!file.exists())
@ -237,8 +261,8 @@ public class ArticleService {
237 261
			throw new JfwBaseException(91, "read temp resource image error", e);
238 262
		}
239 263
	}
240
	
241
	private void saveArtImg(String fn, String id) throws JfwBaseException, IOException{
264

265
	private void saveArtImg(String fn, String id) throws JfwBaseException, IOException {
242 266
		byte[] src = this.readTmpFile(fn);
243 267
		src = JpgUtil.read(src);
244 268
		byte[] shareResImage = this.resImage(src, this.artMaxLen);
@ -251,68 +275,68 @@ public class ArticleService {
251 275
		IoUtil.saveStream(new FileOutputStream(new File(dateFile, id + "." + JPG)), src, true);
252 276
		IoUtil.saveStream(new FileOutputStream(new File(dateFile, id + "_s." + JPG)), shareResImage, true);
253 277
	}
254
	
255
	private String createDate(){
278

279
	private String createDate() {
256 280
		SimpleDateFormat df = new SimpleDateFormat(this.dateFormat);
257 281
		String date = df.format(new Date());
258 282
		return date;
259 283
	}
260
	
261
	private String publishTime(){
284

285
	private String publishTime() {
262 286
		SimpleDateFormat df = new SimpleDateFormat(this.timeFormat);
263 287
		String publishTime = df.format(new Date());
264 288
		return publishTime;
265 289
	}
266
	
290

267 291
	@Post
268 292
	@Path
269
	public String insert(@JdbcConn(true) Connection con, Article article) 
270
			throws SQLException, IOException, JfwBaseException{
293
	public String insert(@JdbcConn(true) Connection con, Article article) throws SQLException, IOException, JfwBaseException {
271 294
		String articleId = StringUtil.buildUUID();
272
		if(article.getArticleImg() != null){
295
		if (article.getArticleImg() != null) {
273 296
			this.saveArtImg(article.getArticleImg(), articleId);
274
			article.setArticleImg(this.createDate()+"/"+articleId+"."+JPG);
297
			article.setArticleImg(this.createDate() + "/" + articleId + "." + JPG);
275 298
		}
276 299
		article.setArticleId(articleId);
277 300
		article.setArticleAgree(0);
278 301
		article.setPageViews(0);
279 302
		article.setStatus("1");
280 303
		article.setPublishTime(this.publishTime());
281
		if(article.getProfessorId() != null && article.getOrgId() == null){
304
		if (article.getProfessorId() != null && article.getOrgId() == null) {
282 305
			article.setArticleType("1");
283
		}else if(article.getProfessorId() == null && article.getOrgId() != null){
306
		} else if (article.getProfessorId() == null && article.getOrgId() != null) {
284 307
			article.setArticleType("2");
285
		}else{
308
		} else {
286 309
			throw new JfwBaseException(-1, "错误参数:文章发布者ID");
287 310
		}
288 311
		this.articleDao.insert(con, article);
289 312
		return articleId;
290 313
	}
291
	
314

292 315
	@Post
293 316
	@Path("/save")
294
	public String saveArticle(@JdbcConn(true) Connection con,Article article,@Nullable String[] professors,
295
			@Nullable String[] resources) throws SQLException, IOException, JfwBaseException{
296
		if(article.getArticleId() == null){
317
	public String saveArticle(@JdbcConn(true) Connection con, Article article, @Nullable String[] professors, @Nullable String[] resources,
318
			@Nullable String[] orgs) throws SQLException, IOException, JfwBaseException {
319
		if (article.getArticleId() == null) {
297 320
			String articleId = StringUtil.buildUUID();
298
			if(article.getArticleImg() != null){
321
			if (article.getArticleImg() != null) {
299 322
				this.saveArtImg(article.getArticleImg(), articleId);
300
				article.setArticleImg(this.createDate()+"/"+articleId+"."+JPG);
323
				article.setArticleImg(this.createDate() + "/" + articleId + "." + JPG);
301 324
			}
302 325
			article.setArticleId(articleId);
303 326
			article.setArticleAgree(0);
304 327
			article.setPageViews(0);
305 328
			article.setStatus("1");
306 329
			article.setPublishTime(this.publishTime());
307
			if(article.getProfessorId() != null && article.getOrgId() == null){
330
			if (article.getProfessorId() != null && article.getOrgId() == null) {
308 331
				article.setArticleType("1");
309
			}else if(article.getProfessorId() == null && article.getOrgId() != null){
332
			} else if (article.getProfessorId() == null && article.getOrgId() != null) {
310 333
				article.setArticleType("2");
311
			}else{
334
			} else {
312 335
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
313 336
			}
314 337
			this.articleDao.insert(con, article);
315
			if(professors != null){
338
			this.keyWordService.refreshArticle(con, articleId, KeyWordService.splitKeyWord(article.getSubject()));
339
			if (professors != null) {
316 340
				for (String professor : professors) {
317 341
					ArticlePro articlePro = new ArticlePro();
318 342
					articlePro.setArticleId(articleId);
@ -320,7 +344,7 @@ public class ArticleService {
320 344
					this.articleProDao.insert(con, articlePro);
321 345
				}
322 346
			}
323
			if(resources != null){
347
			if (resources != null) {
324 348
				for (String resource : resources) {
325 349
					ArticleRes articleRes = new ArticleRes();
326 350
					articleRes.setArticleId(articleId);
@ -328,17 +352,27 @@ public class ArticleService {
328 352
					this.articleResDao.insert(con, articleRes);
329 353
				}
330 354
			}
355
			if (orgs != null && orgs.length > 0) {
356
				for (String org : orgs) {
357
					ArticleOrg articleOrg = new ArticleOrg();
358
					articleOrg.setArticleId(articleId);
359
					articleOrg.setOrgId(org);
360
					this.articleOrgDao.insert(con, articleOrg);
361
				}
362
			}
331 363
			return articleId;
332
		}else if(article.getArticleId().trim().length() == 32){
333
			if(article.getArticleImg() != null){
364
		} else if (article.getArticleId().trim().length() == 32) {
365
			if (article.getArticleImg() != null) {
334 366
				this.saveArtImg(article.getArticleImg(), article.getArticleId());
335
				article.setArticleImg(this.createDate()+"/"+article.getArticleId()+"."+JPG);
367
				article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
336 368
			}
337 369
			this.articleDao.update(con, article);
338 370
			this.articleDao.updatePublishTime(con, article.getArticleId(), "1", this.publishTime());
371
			this.keyWordService.refreshArticle(con, article.getArticleId(), KeyWordService.splitKeyWord(article.getSubject()));
339 372
			this.articleProDao.delete(con, article.getArticleId());
340 373
			this.articleResDao.delete(con, article.getArticleId());
341
			if(professors != null){
374
			this.articleOrgDao.delete(con, article.getArticleId());
375
			if (professors != null) {
342 376
				for (String professor : professors) {
343 377
					ArticlePro articlePro = new ArticlePro();
344 378
					articlePro.setArticleId(article.getArticleId());
@ -346,7 +380,7 @@ public class ArticleService {
346 380
					this.articleProDao.insert(con, articlePro);
347 381
				}
348 382
			}
349
			if(resources != null){
383
			if (resources != null) {
350 384
				for (String resource : resources) {
351 385
					ArticleRes articleRes = new ArticleRes();
352 386
					articleRes.setArticleId(article.getArticleId());
@ -354,35 +388,44 @@ public class ArticleService {
354 388
					this.articleResDao.insert(con, articleRes);
355 389
				}
356 390
			}
391
			if (orgs != null && orgs.length > 0) {
392
				for (String org : orgs) {
393
					ArticleOrg articleOrg = new ArticleOrg();
394
					articleOrg.setArticleId(article.getArticleId());
395
					articleOrg.setOrgId(org);
396
					this.articleOrgDao.insert(con, articleOrg);
397
				}
398
			}
357 399
			return article.getArticleId();
358
		}else{
400
		} else {
359 401
			throw new JfwBaseException(-2, "bad parameter:articleId");
360 402
		}
361 403
	}
362
	
404

363 405
	@Post
364 406
	@Path("/draft")
365
	public String draft(@JdbcConn(true) Connection con,Article article,@Nullable String[] professors,
366
			@Nullable String[] resources) throws SQLException, IOException, JfwBaseException{
367
		if(article.getArticleId() == null){
407
	public String draft(@JdbcConn(true) Connection con, Article article, @Nullable String[] professors, @Nullable String[] resources, @Nullable String[] orgs)
408
			throws SQLException, IOException, JfwBaseException {
409
		if (article.getArticleId() == null) {
368 410
			String articleId = StringUtil.buildUUID();
369
			if(article.getArticleImg() != null){
411
			if (article.getArticleImg() != null) {
370 412
				this.saveArtImg(article.getArticleImg(), articleId);
371
				article.setArticleImg(this.createDate()+"/"+articleId+"."+JPG);
413
				article.setArticleImg(this.createDate() + "/" + articleId + "." + JPG);
372 414
			}
373 415
			article.setArticleId(articleId);
374 416
			article.setArticleAgree(0);
375 417
			article.setPageViews(0);
376 418
			article.setStatus("0");
377
			if(article.getProfessorId() != null && article.getOrgId() == null){
419
			if (article.getProfessorId() != null && article.getOrgId() == null) {
378 420
				article.setArticleType("1");
379
			}else if(article.getProfessorId() == null && article.getOrgId() != null){
421
			} else if (article.getProfessorId() == null && article.getOrgId() != null) {
380 422
				article.setArticleType("2");
381
			}else{
423
			} else {
382 424
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
383 425
			}
384 426
			this.articleDao.insert(con, article);
385
			if(professors != null){
427
			this.keyWordService.refreshArticle(con, articleId, null);
428
			if (professors != null) {
386 429
				for (String professor : professors) {
387 430
					ArticlePro articlePro = new ArticlePro();
388 431
					articlePro.setArticleId(articleId);
@ -390,7 +433,7 @@ public class ArticleService {
390 433
					this.articleProDao.insert(con, articlePro);
391 434
				}
392 435
			}
393
			if(resources != null){
436
			if (resources != null) {
394 437
				for (String resource : resources) {
395 438
					ArticleRes articleRes = new ArticleRes();
396 439
					articleRes.setArticleId(articleId);
@ -398,17 +441,27 @@ public class ArticleService {
398 441
					this.articleResDao.insert(con, articleRes);
399 442
				}
400 443
			}
444
			if (orgs != null && orgs.length > 0) {
445
				for (String org : orgs) {
446
					ArticleOrg articleOrg = new ArticleOrg();
447
					articleOrg.setArticleId(articleId);
448
					articleOrg.setOrgId(org);
449
					this.articleOrgDao.insert(con, articleOrg);
450
				}
451
			}
401 452
			return articleId;
402
		}else if(article.getArticleId().trim().length() == 32){
403
			if(article.getArticleImg() != null){
453
		} else if (article.getArticleId().trim().length() == 32) {
454
			if (article.getArticleImg() != null) {
404 455
				this.saveArtImg(article.getArticleImg(), article.getArticleId());
405
				article.setArticleImg(this.createDate()+"/"+article.getArticleId()+"."+JPG);
456
				article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
406 457
			}
407 458
			this.articleDao.update(con, article);
408 459
			this.articleDao.updateStatus(con, article.getArticleId(), "0");
460
			this.keyWordService.refreshArticle(con, article.getArticleId(), null);
409 461
			this.articleProDao.delete(con, article.getArticleId());
410 462
			this.articleResDao.delete(con, article.getArticleId());
411
			if(professors != null){
463
			this.articleOrgDao.delete(con, article.getArticleId());
464
			if (professors != null) {
412 465
				for (String professor : professors) {
413 466
					ArticlePro articlePro = new ArticlePro();
414 467
					articlePro.setArticleId(article.getArticleId());
@ -416,7 +469,7 @@ public class ArticleService {
416 469
					this.articleProDao.insert(con, articlePro);
417 470
				}
418 471
			}
419
			if(resources != null){
472
			if (resources != null) {
420 473
				for (String resource : resources) {
421 474
					ArticleRes articleRes = new ArticleRes();
422 475
					articleRes.setArticleId(article.getArticleId());
@ -424,38 +477,46 @@ public class ArticleService {
424 477
					this.articleResDao.insert(con, articleRes);
425 478
				}
426 479
			}
480
			if (orgs != null && orgs.length > 0) {
481
				for (String org : orgs) {
482
					ArticleOrg articleOrg = new ArticleOrg();
483
					articleOrg.setArticleId(article.getArticleId());
484
					articleOrg.setOrgId(org);
485
					this.articleOrgDao.insert(con, articleOrg);
486
				}
487
			}
427 488
			return article.getArticleId();
428
		}else{
489
		} else {
429 490
			throw new JfwBaseException(-2, "bad parameter:articleId");
430 491
		}
431 492
	}
432
	
493

433 494
	@Post
434 495
	@Path("/timing")
435
	public String timingPublish(@JdbcConn(true) Connection con,Article article,@Nullable String[] professors,
436
			@Nullable String[] resources) throws SQLException, IOException, JfwBaseException{
437
		if(article.getPublishTime() == null){
496
	public String timingPublish(@JdbcConn(true) Connection con, Article article, @Nullable String[] professors, @Nullable String[] resources,
497
			@Nullable String[] orgs) throws SQLException, IOException, JfwBaseException {
498
		if (article.getPublishTime() == null) {
438 499
			throw new JfwBaseException(-3, "no parameter found:publishTime");
439 500
		}
440
		if(article.getArticleId() == null){
501
		if (article.getArticleId() == null) {
441 502
			String articleId = StringUtil.buildUUID();
442
			if(article.getArticleImg() != null){
503
			if (article.getArticleImg() != null) {
443 504
				this.saveArtImg(article.getArticleImg(), articleId);
444
				article.setArticleImg(this.createDate()+"/"+articleId+"."+JPG);
505
				article.setArticleImg(this.createDate() + "/" + articleId + "." + JPG);
445 506
			}
446 507
			article.setArticleId(articleId);
447 508
			article.setArticleAgree(0);
448 509
			article.setPageViews(0);
449 510
			article.setStatus("2");
450
			if(article.getProfessorId() != null && article.getOrgId() == null){
511
			if (article.getProfessorId() != null && article.getOrgId() == null) {
451 512
				article.setArticleType("1");
452
			}else if(article.getProfessorId() == null && article.getOrgId() != null){
513
			} else if (article.getProfessorId() == null && article.getOrgId() != null) {
453 514
				article.setArticleType("2");
454
			}else{
515
			} else {
455 516
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
456 517
			}
457 518
			this.articleDao.insert(con, article);
458
			if(professors != null){
519
			if (professors != null) {
459 520
				for (String professor : professors) {
460 521
					ArticlePro articlePro = new ArticlePro();
461 522
					articlePro.setArticleId(articleId);
@ -463,7 +524,7 @@ public class ArticleService {
463 524
					this.articleProDao.insert(con, articlePro);
464 525
				}
465 526
			}
466
			if(resources != null){
527
			if (resources != null) {
467 528
				for (String resource : resources) {
468 529
					ArticleRes articleRes = new ArticleRes();
469 530
					articleRes.setArticleId(articleId);
@ -471,18 +532,28 @@ public class ArticleService {
471 532
					this.articleResDao.insert(con, articleRes);
472 533
				}
473 534
			}
535
			if (orgs != null && orgs.length > 0) {
536
				for (String org : orgs) {
537
					ArticleOrg articleOrg = new ArticleOrg();
538
					articleOrg.setArticleId(articleId);
539
					articleOrg.setOrgId(org);
540
					this.articleOrgDao.insert(con, articleOrg);
541
				}
542
			}
474 543
			return articleId;
475
		}else if(article.getArticleId().trim().length() == 32){
476
			if(article.getArticleImg() != null){
544
		} else if (article.getArticleId().trim().length() == 32) {
545
			if (article.getArticleImg() != null) {
477 546
				this.saveArtImg(article.getArticleImg(), article.getArticleId());
478
				article.setArticleImg(this.createDate()+"/"+article.getArticleId()+"."+JPG);
547
				article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
479 548
			}
480 549
			this.articleDao.update(con, article);
481 550
			this.articleDao.updatePublishTime(con, article.getArticleId(), "2", article.getPublishTime());
551
			this.keyWordService.refreshArticle(con, article.getArticleId(), null);
482 552
			this.articleResDao.delete(con, article.getArticleId());
483 553
			this.articleProDao.delete(con, article.getArticleId());
484
			this.articleResDao.delete(con, article.getArticleId());
485
			if(professors != null){
554
			this.articleOrgDao.delete(con, article.getArticleId());
555

556
			if (professors != null) {
486 557
				for (String professor : professors) {
487 558
					ArticlePro articlePro = new ArticlePro();
488 559
					articlePro.setArticleId(article.getArticleId());
@ -490,7 +561,7 @@ public class ArticleService {
490 561
					this.articleProDao.insert(con, articlePro);
491 562
				}
492 563
			}
493
			if(resources != null){
564
			if (resources != null) {
494 565
				for (String resource : resources) {
495 566
					ArticleRes articleRes = new ArticleRes();
496 567
					articleRes.setArticleId(article.getArticleId());
@ -498,172 +569,188 @@ public class ArticleService {
498 569
					this.articleResDao.insert(con, articleRes);
499 570
				}
500 571
			}
572
			if (orgs != null && orgs.length > 0) {
573
				for (String org : orgs) {
574
					ArticleOrg articleOrg = new ArticleOrg();
575
					articleOrg.setArticleId(article.getArticleId());
576
					articleOrg.setOrgId(org);
577
					this.articleOrgDao.insert(con, articleOrg);
578
				}
579
			}
501 580
			return article.getArticleId();
502
		}else{
581
		} else {
503 582
			throw new JfwBaseException(-2, "bad parameter:articleId");
504 583
		}
505 584
	}
506
	
585

507 586
	@Post
508 587
	@Path("/updateArt")
509
	public void update(@JdbcConn(true) Connection con, Article article) 
510
			throws SQLException, JfwBaseException, IOException{
511
		if(article.getArticleImg() != null){
588
	public void update(@JdbcConn(true) Connection con, Article article) throws SQLException, JfwBaseException, IOException {
589
		if (article.getArticleImg() != null) {
512 590
			this.saveArtImg(article.getArticleImg(), article.getArticleId());
513
			article.setArticleImg(this.createDate()+"/"+article.getArticleId()+"."+JPG);
591
			article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
514 592
		}
515 593
		this.articleDao.update(con, article);
516 594
	}
517
	
595

518 596
	@Post
519 597
	@Path("/pageViews")
520
	public void pageViews(@JdbcConn(true) Connection con,String articleId) throws SQLException{
598
	public void pageViews(@JdbcConn(true) Connection con, String articleId) throws SQLException {
521 599
		this.articleDao.incPageViews(con, articleId);
522 600
	}
523
	
601

524 602
	@Post
525 603
	@Path("/updateDraft")
526
	public void updateDraft(@JdbcConn(true) Connection con, String articleId) throws SQLException{
527
		//修改文章状态为草稿
604
	public void updateDraft(@JdbcConn(true) Connection con, String articleId) throws SQLException {
605
		// 修改文章状态为草稿
528 606
		this.articleDao.updateStatus(con, articleId, "0");
607
		this.keyWordService.refreshArticle(con, articleId, null);
529 608
	}
530
	
609

531 610
	@Post
532 611
	@Path("/publish")
533
	public void publish(@JdbcConn(true) Connection con,String articleId) throws SQLException{
534
		//修改文章状态为发布
612
	public void publish(@JdbcConn(true) Connection con, String articleId) throws SQLException {
613
		// 修改文章状态为发布
535 614
		this.articleDao.updateStatus(con, articleId, "1");
615
		Article a = this.articleDao.queryOne(con, articleId);
616
		if (a != null) {
617
			this.keyWordService.refreshArticle(con, articleId, KeyWordService.splitKeyWord(a.getSubject()));
618
		}
536 619
	}
537
	
620

538 621
	@Post
539 622
	@Path("/deleteArticle")
540
	public void deleteArticle(@JdbcConn(true) Connection con,String articleId) throws SQLException{
541
		//修改文章状态为删除
623
	public void deleteArticle(@JdbcConn(true) Connection con, String articleId) throws SQLException {
624
		// 修改文章状态为删除
542 625
		this.articleDao.updateStatus(con, articleId, "3");
626
		this.keyWordService.refreshArticle(con, articleId, null);
543 627
	}
544
	
628

545 629
	@Post
546 630
	@Path("/close")
547
	public void closeArticle(@JdbcConn(true) Connection con,String articleId) throws SQLException{
548
		//修改文章状态为关闭
631
	public void closeArticle(@JdbcConn(true) Connection con, String articleId) throws SQLException {
632
		// 修改文章状态为关闭
549 633
		this.articleDao.updateStatus(con, articleId, "4");
550 634
	}
551
	
635

552 636
	@Post
553 637
	@Path("/agree")
554
	public void agree(@JdbcConn(true) Connection con,String operateId,String articleId)throws SQLException{
555
		if(this.articleDao.incAgree(con, articleId) > 0){
638
	public void agree(@JdbcConn(true) Connection con, String operateId, String articleId) throws SQLException {
639
		if (this.articleDao.incAgree(con, articleId) > 0) {
556 640
			ArticleAgree articleAgree = new ArticleAgree();
557 641
			articleAgree.setOperateId(operateId);
558 642
			articleAgree.setArticleId(articleId);
559 643
			this.articleAgreeDao.insert(con, articleAgree);
560 644
		}
561 645
	}
562
	
646

563 647
	@Post
564 648
	@Path("/unAgree")
565
	public void unAgree(@JdbcConn(true) Connection con,String operateId,String articleId)throws SQLException{
566
		if(this.articleDao.decAgree(con, articleId) > 0){
649
	public void unAgree(@JdbcConn(true) Connection con, String operateId, String articleId) throws SQLException {
650
		if (this.articleDao.decAgree(con, articleId) > 0) {
567 651
			this.articleAgreeDao.deleteAgree(con, operateId, articleId);
568 652
		}
569 653
	}
570
	
654

571 655
	@Get
572 656
	@Path("/isAgree")
573
	public ArticleAgree queryAgree(@JdbcConn Connection con,String operateId,String articleId)throws SQLException{
657
	public ArticleAgree queryAgree(@JdbcConn Connection con, String operateId, String articleId) throws SQLException {
574 658
		return this.articleAgreeDao.queryOne(con, operateId, articleId);
575 659
	}
576
	
660

577 661
	@Get
578 662
	@Path("/agreeList")
579
	public List<ArticleAgree> queryAgreeList(@JdbcConn Connection con,String articleId)throws SQLException{
663
	public List<ArticleAgree> queryAgreeList(@JdbcConn Connection con, String articleId) throws SQLException {
580 664
		return this.articleAgreeDao.query(con, articleId);
581 665
	}
582
	
666

583 667
	@Get
584 668
	@Path("/qaPro")
585
	public List<Article> queryPro(@JdbcConn Connection con, String professorId) throws SQLException{
669
	public List<Article> queryPro(@JdbcConn Connection con, String professorId) throws SQLException {
586 670
		return this.articleDao.queryPro(con, professorId);
587 671
	}
588
	
672

589 673
	@Get
590 674
	@Path("/qaProPublish")
591
	public List<Article> queryProPublish(@JdbcConn Connection con, String professorId) throws SQLException{
675
	public List<Article> queryProPublish(@JdbcConn Connection con, String professorId) throws SQLException {
592 676
		return this.articleDao.queryProPublish(con, professorId);
593 677
	}
594
	
678

595 679
	@Get
596 680
	@Path("/pqProPublish")
597
	public PageQueryResult<Article> pageQueryProPublish(@JdbcConn Connection con, String professorId,@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo) throws SQLException{
598
		return this.articleDao.pageQueryProPublish(con, professorId,pageSize,pageNo);
681
	public PageQueryResult<Article> pageQueryProPublish(@JdbcConn Connection con, String professorId, @DefaultValue("10") int pageSize,
682
			@DefaultValue("1") int pageNo) throws SQLException {
683
		return this.articleDao.pageQueryProPublish(con, professorId, pageSize, pageNo);
599 684
	}
600
	
685

601 686
	@Get
602 687
	@Path("/qaForDesk")
603
	public List<Article> queryForDesk(@JdbcConn Connection con, String professorId) throws SQLException{
688
	public List<Article> queryForDesk(@JdbcConn Connection con, String professorId) throws SQLException {
604 689
		return this.articleDao.queryForDesk(con, professorId);
605 690
	}
606
	
691

607 692
	@Get
608 693
	@Path("/qaOrg")
609
	public List<Article> queryOrg(@JdbcConn Connection con,String orgId)throws SQLException{
694
	public List<Article> queryOrg(@JdbcConn Connection con, String orgId) throws SQLException {
610 695
		return this.articleDao.queryOrg(con, orgId);
611 696
	}
612
	
697

613 698
	@Get
614 699
	@Path("/qaOrgPublish")
615
	public List<Article> queryOrgPublish(@JdbcConn Connection con,String orgId)throws SQLException{
700
	public List<Article> queryOrgPublish(@JdbcConn Connection con, String orgId) throws SQLException {
616 701
		return this.articleDao.queryOrgPublish(con, orgId);
617 702
	}
618
	
703

619 704
	@Get
620 705
	@Path("/pqOrgPublish")
621
	public PageQueryResult<Article> pageQueryOrgPublish(@JdbcConn Connection con,String orgId,@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
622
		return this.articleDao.pageQueryOrgPublish(con, orgId,pageSize,pageNo);
706
	public PageQueryResult<Article> pageQueryOrgPublish(@JdbcConn Connection con, String orgId, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo)
707
			throws SQLException {
708
		return this.articleDao.pageQueryOrgPublish(con, orgId, pageSize, pageNo);
623 709
	}
624
	
710

625 711
	@Get
626 712
	@Path("/qlOrg")
627
	public List<Article> queryLimitOrg(@JdbcConn Connection con,String orgId,@DefaultValue("com.ekexiu.portal.service.ArticleService.MAX_MODIFYTIME") String modifyTime,@DefaultValue("20") int rows)throws SQLException{
713
	public List<Article> queryLimitOrg(@JdbcConn Connection con, String orgId,
714
			@DefaultValue("com.ekexiu.portal.service.ArticleService.MAX_MODIFYTIME") String modifyTime, @DefaultValue("20") int rows) throws SQLException {
628 715
		return this.articleDao.queryLimit(con, orgId, modifyTime, rows);
629 716
	}
630
	
717

631 718
	@Get
632 719
	@Path("/query")
633
	public Article queryOne(@JdbcConn Connection con, String articleId) throws SQLException{
720
	public Article queryOne(@JdbcConn Connection con, String articleId) throws SQLException {
634 721
		return this.articleDao.queryOne(con, articleId);
635 722
	}
636
	
723

637 724
	@Get
638 725
	@Path("/pqpublish")
639
	public PageQueryResult<Article> queryPagePublish(@JdbcConn Connection con,@Nullable String articleTitle,
640
			@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
641
		if(articleTitle != null){
726
	public PageQueryResult<Article> queryPagePublish(@JdbcConn Connection con, @Nullable String articleTitle, @DefaultValue("10") int pageSize,
727
			@DefaultValue("1") int pageNo) throws SQLException {
728
		if (articleTitle != null) {
642 729
			articleTitle = "%" + articleTitle + "%";
643 730
		}
644 731
		return this.articleDao.queryPageForPublish(con, articleTitle, pageSize, pageNo);
645 732
	}
646
	
733

647 734
	@Get
648 735
	@Path("/firstpq")
649
	public PageQueryResult<Article> firstPageQuery(@JdbcConn Connection con,@Nullable String key,
650
			@DefaultValue("20") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
651
		if(key != null){
736
	public PageQueryResult<Article> firstPageQuery(@JdbcConn Connection con, @Nullable String key, @DefaultValue("20") int pageSize,
737
			@DefaultValue("1") int pageNo) throws SQLException {
738
		if (key != null) {
652 739
			key = "%" + key + "%";
653 740
		}
654 741
		PageQueryResult<Article> queryResult = this.articleDao.firstPageQuery(con, key, pageSize, pageNo);
655 742
		List<Article> articles = queryResult.getData();
656
		if(!articles.isEmpty()){
743
		if (!articles.isEmpty()) {
657 744
			for (Article article : articles) {
658
				if("1".equals(article.getArticleType())){
745
				if ("1".equals(article.getArticleType())) {
659 746
					EditProfessor professor = this.professorDao.queryBaseInfo(con, article.getProfessorId());
660
					if(professor != null){
747
					if (professor != null) {
661 748
						professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
662 749
					}
663 750
					article.setProfessor(professor);
664
				}else if("2".equals(article.getArticleType())){
751
				} else if ("2".equals(article.getArticleType())) {
665 752
					EditOrganization organization = this.orgDao.queryEditOrg(con, article.getOrgId());
666
					if(organization != null){
753
					if (organization != null) {
667 754
						organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
668 755
					}
669 756
					article.setEditOrganization(organization);
@ -672,44 +759,45 @@ public class ArticleService {
672 759
		}
673 760
		return queryResult;
674 761
	}
675
	
762

676 763
	@Get
677 764
	@Path("/pqself")
678
	public PageQueryResult<Article> queryPageSelf(@JdbcConn Connection con,@Nullable String professorId,@Nullable String orgId,
679
			@Nullable String articleTitle,@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
680
		if(articleTitle != null){
765
	public PageQueryResult<Article> queryPageSelf(@JdbcConn Connection con, @Nullable String professorId, @Nullable String orgId, @Nullable String articleTitle,
766
			@DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
767
		if (articleTitle != null) {
681 768
			articleTitle = "%" + articleTitle + "%";
682 769
		}
683 770
		return this.articleDao.queryPageForSelf(con, professorId, orgId, articleTitle, pageSize, pageNo);
684 771
	}
685
	
772

686 773
	@Get
687 774
	@Path("/pqFind")
688
	public PageQueryResult<FindInfo> queryPage(@JdbcConn Connection con,@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
775
	public PageQueryResult<FindInfo> queryPage(@JdbcConn Connection con, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
689 776
		PageQueryResult<FindInfo> queryResult = this.articleDao.queryPage(con, pageSize, pageNo);
690 777
		List<FindInfo> findInfos = queryResult.getData();
691 778
		for (FindInfo findInfo : findInfos) {
692
			if("3".equals(findInfo.getType())){
779
			if ("3".equals(findInfo.getType())) {
693 780
				List<Image> images = this.imagesService.queryRes(con, findInfo.getId());
694
				if(images.size() > 0){
695
					findInfo.setImage(findInfo.getId()+".jpg");
781
				if (images.size() > 0) {
782
					findInfo.setImage(findInfo.getId() + ".jpg");
696 783
				}
697 784
			}
698 785
		}
699 786
		queryResult.setData(findInfos);
700 787
		return queryResult;
701 788
	}
702
	
789

703 790
	@Get
704 791
	@Path("/findHot")
705
	public PageQueryResult<FindInfo> queryFindHot(@JdbcConn Connection con,@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
792
	public PageQueryResult<FindInfo> queryFindHot(@JdbcConn Connection con, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo)
793
			throws SQLException {
706 794
		PageQueryResult<FindInfo> queryResult = this.articleDao.queryFindHot(con, pageSize, pageNo);
707 795
		List<FindInfo> findInfos = queryResult.getData();
708
		if(!findInfos.isEmpty()){
796
		if (!findInfos.isEmpty()) {
709 797
			for (FindInfo findInfo : findInfos) {
710
				if("3".equals(findInfo.getType()) || "4".equals(findInfo.getType())){
798
				if ("3".equals(findInfo.getType()) || "4".equals(findInfo.getType())) {
711 799
					List<Image> images = this.imagesService.queryRes(con, findInfo.getId());
712
					if(images.size() > 0){
800
					if (images.size() > 0) {
713 801
						findInfo.setImage(images.get(0).getImageSrc());
714 802
					}
715 803
				}
@ -718,48 +806,117 @@ public class ArticleService {
718 806
		}
719 807
		return queryResult;
720 808
	}
721
	
809

722 810
	@Get
723 811
	@Path("/ralatePro")
724
	public List<ArticlePro> ralatePro(@JdbcConn Connection con,String articleId) throws SQLException{
812
	public List<ArticlePro> ralatePro(@JdbcConn Connection con, String articleId) throws SQLException {
725 813
		return this.articleProDao.query(con, articleId);
726 814
	}
727
	
815

728 816
	@Get
729 817
	@Path("/ralateRes")
730
	public List<ArticleRes> ralateRes(@JdbcConn Connection con,String articleId) throws SQLException{
818
	public List<ArticleRes> ralateRes(@JdbcConn Connection con, String articleId) throws SQLException {
731 819
		return this.articleResDao.query(con, articleId);
732 820
	}
733
	
821

822
	@Get
823
	@Path("/ralateOrg")
824
	public List<ArticleOrg> ralateOrg(@JdbcConn Connection con, String articleId) throws SQLException {
825
		return this.articleOrgDao.query(con, articleId);
826
	}
827

734 828
	@Get
735 829
	@Path("/ralateArticles")
736
	public List<Article> ralateArticles(@JdbcConn Connection con,@Nullable String[] keys,@Nullable String professorId,
737
			@Nullable String orgId,String articleId,@DefaultValue("10") int rows)throws SQLException{
738
		List<Article> articles = new ArrayList<Article>();
739
		if(keys != null){
740
			articles = this.articleDao.queryLimit(con, keys, articleId, rows);
830
	public List<Article> ralateArticles(@JdbcConn Connection con, @Nullable String[] keys, @Nullable String professorId, @Nullable String orgId,
831
			String articleId, @DefaultValue("5") int rows) throws SQLException {
832
		String[] ids = this.articleDao.queryArticleIdWithSameKeyWord(con, articleId, rows);
833
		if (ids != null) {
834
			return this.articleDao.query(con, ids);
741 835
		}
742
		if(articles.isEmpty()){
743
			articles = this.articleDao.queryByAuthor(con, professorId, orgId, articleId, rows);
744
			if(articles.isEmpty()){
745
				articles = this.articleDao.queryByPageViews(con, articleId, rows);
746
			}
836
		return Collections.<Article> emptyList();
837
		// List<Article> articles = new ArrayList<Article>();
838
		// if(keys != null){
839
		// articles = this.articleDao.queryLimit(con, keys, articleId, rows);
840
		// }
841
		// if(articles.isEmpty()){
842
		// articles = this.articleDao.queryByAuthor(con, professorId, orgId,
843
		// articleId, rows);
844
		// if(articles.isEmpty()){
845
		// articles = this.articleDao.queryByPageViews(con, articleId, rows);
846
		// }
847
		// }
848
		// return articles;
849
	}
850

851
	// @Post
852
	// @Path("/delete")
853
	// public void delete(@JdbcConn(true) Connection con, String articleId)
854
	// throws SQLException{
855
	// this.articleDao.delete(con, articleId);
856
	// this.leaveWordDao.deleteArticle(con, articleId,LeaveWordService.ARTICLE);
857
	// this.articleAgreeDao.delete(con, articleId);
858
	// this.watchDao.deleteWatch(con, articleId);
859
	// this.articleOrgDao.delete(con, articleId);
860
	// this.articleProDao.delete(con, articleId);
861
	// this.articleProDao.delete(con, articleId);
862
	// }
863

864
	@Get
865
	@Path("/byAssProfessor")
866
	public List<Article> byAssProfessor(@JdbcConn Connection con, String id, @DefaultValue("5") int rows) throws SQLException {
867

868
		List<ArticlePro> pros = this.articleProDao.queryByProfessorId(con, id);
869

870
		if (pros == null || pros.isEmpty()) {
871
			return Collections.<Article> emptyList();
872
		}
873
		String[] ids = new String[pros.size()];
874
		int i = 0;
875
		for (ArticlePro ar : pros) {
876
			ids[i++] = ar.getArticleId();
747 877
		}
748
		return articles;
878

879
		return this.articleDao.limitQueryPublish(con, ids, rows);
749 880
	}
750 881
	
751
	@Post
752
	@Path("/delete")
753
	public void delete(@JdbcConn(true) Connection con, String articleId) throws SQLException{
754
		this.articleDao.delete(con, articleId);
755
		this.leaveWordDao.deleteArticle(con, articleId);
756
		this.articleAgreeDao.delete(con, articleId);
757
		this.watchDao.deleteWatch(con, articleId);
882
	@Get
883
	@Path("/byAssOrg")
884
	public List<Article> byAssOrg(@JdbcConn Connection con, String id, @DefaultValue("5") int rows) throws SQLException {
885

886
		List<ArticleOrg> pros = this.articleOrgDao.queryByOrgId(con, id);
887

888
		if (pros == null || pros.isEmpty()) {
889
			return Collections.<Article> emptyList();
890
		}
891
		String[] ids = new String[pros.size()];
892
		int i = 0;
893
		for (ArticleOrg ar : pros) {
894
			ids[i++] = ar.getArticleId();
895
		}
896

897
		return this.articleDao.limitQueryPublish(con, ids, rows);
758 898
	}
759
	
899
	@Get
900
	@Path("/byAssResource")
901
	public List<Article> byAssResource(@JdbcConn Connection con, String id, @DefaultValue("5") int rows) throws SQLException {
902

903
		List<ArticleRes> pros = this.articleResDao.queryByResourceId(con, id);
904

905
		if (pros == null || pros.isEmpty()) {
906
			return Collections.<Article> emptyList();
907
		}
908
		String[] ids = new String[pros.size()];
909
		int i = 0;
910
		for (ArticleRes ar : pros) {
911
			ids[i++] = ar.getArticleId();
912
		}
913

914
		return this.articleDao.limitQueryPublish(con, ids, rows);
915
	}
916

760 917
	@Path("/byShareId")
761 918
	@Get
762
	public Article query(@JdbcConn Connection con,long id) throws SQLException{
919
	public Article query(@JdbcConn Connection con, long id) throws SQLException {
763 920
		return this.articleDao.query(con, id);
764 921
	}
765 922


+ 198 - 0
src/main/java/com/ekexiu/portal/service/KeyWordService.java

@ -0,0 +1,198 @@
1
package com.ekexiu.portal.service;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.ArrayList;
6

7
import org.jfw.apt.annotation.Autowrie;
8
import org.jfw.apt.annotation.Bean;
9

10
import com.ekexiu.portal.dao.ArtKeyWordDao;
11
import com.ekexiu.portal.dao.OrgKeyWordDao;
12
import com.ekexiu.portal.dao.PapKeyWordDao;
13
import com.ekexiu.portal.dao.PatKeyWordDao;
14
import com.ekexiu.portal.dao.ProKeyWordDao;
15
import com.ekexiu.portal.dao.ResKeyWordDao;
16
import com.ekexiu.portal.po.ArtKeyWord;
17
import com.ekexiu.portal.po.OrgKeyWord;
18
import com.ekexiu.portal.po.PapKeyWord;
19
import com.ekexiu.portal.po.PatKeyWord;
20
import com.ekexiu.portal.po.ProKeyWord;
21
import com.ekexiu.portal.po.ResKeyWord;
22

23
@Bean
24
public class KeyWordService {
25

26
	@Autowrie
27
	private ProKeyWordDao proKeyWordDao;
28
	@Autowrie
29
	private OrgKeyWordDao orgKeyWordDao;
30
	@Autowrie
31
	private ResKeyWordDao resKeyWordDao;
32
	@Autowrie
33
	private ArtKeyWordDao artKeyWordDao;
34
	@Autowrie
35
	private PatKeyWordDao patKeyWordDao;
36
	@Autowrie
37
	private PapKeyWordDao papKeyWordDao;
38

39
	public ProKeyWordDao getProKeyWordDao() {
40
		return proKeyWordDao;
41
	}
42

43
	public void setProKeyWordDao(ProKeyWordDao proKeyWordDao) {
44
		this.proKeyWordDao = proKeyWordDao;
45
	}
46

47
	public OrgKeyWordDao getOrgKeyWordDao() {
48
		return orgKeyWordDao;
49
	}
50

51
	public void setOrgKeyWordDao(OrgKeyWordDao orgKeyWordDao) {
52
		this.orgKeyWordDao = orgKeyWordDao;
53
	}
54

55
	public ResKeyWordDao getResKeyWordDao() {
56
		return resKeyWordDao;
57
	}
58

59
	public void setResKeyWordDao(ResKeyWordDao resKeyWordDao) {
60
		this.resKeyWordDao = resKeyWordDao;
61
	}
62

63
	public ArtKeyWordDao getArtKeyWordDao() {
64
		return artKeyWordDao;
65
	}
66

67
	public void setArtKeyWordDao(ArtKeyWordDao artKeyWordDao) {
68
		this.artKeyWordDao = artKeyWordDao;
69
	}
70

71
	public PatKeyWordDao getPatKeyWordDao() {
72
		return patKeyWordDao;
73
	}
74

75
	public void setPatKeyWordDao(PatKeyWordDao patKeyWordDao) {
76
		this.patKeyWordDao = patKeyWordDao;
77
	}
78

79
	public PapKeyWordDao getPapKeyWordDao() {
80
		return papKeyWordDao;
81
	}
82

83
	public void setPapKeyWordDao(PapKeyWordDao papKeyWordDao) {
84
		this.papKeyWordDao = papKeyWordDao;
85
	}
86

87
	public void refreshProfessor(Connection con, String id, String[] kws) throws SQLException {
88
		proKeyWordDao.delete(con, id);
89
		if (kws != null && kws.length > 0) {
90
			ProKeyWord[] okws = new ProKeyWord[kws.length];
91
			for (int i = 0; i < kws.length; ++i) {
92
				ProKeyWord okw = new ProKeyWord();
93
				okw.setId(id);
94
				okw.setKw(kws[i]);
95
				okws[i] = okw;
96
			}
97
			proKeyWordDao.insert(con, okws);
98
		}
99
	}
100

101
	public void refreshOrg(Connection con, String id, String[] kws) throws SQLException {
102
		orgKeyWordDao.delete(con, id);
103
		if (kws != null && kws.length > 0) {
104
			OrgKeyWord[] okws = new OrgKeyWord[kws.length];
105
			for (int i = 0; i < kws.length; ++i) {
106
				OrgKeyWord okw = new OrgKeyWord();
107
				okw.setId(id);
108
				okw.setKw(kws[i]);
109
				okws[i] = okw;
110
			}
111
			orgKeyWordDao.insert(con, okws);
112
		}
113
	}
114

115
	public void refreshArticle(Connection con, String id, String[] kws) throws SQLException {
116
		artKeyWordDao.delete(con, id);
117
		if (kws != null && kws.length > 0) {
118
			ArtKeyWord[] okws = new ArtKeyWord[kws.length];
119
			for (int i = 0; i < kws.length; ++i) {
120
				ArtKeyWord okw = new ArtKeyWord();
121
				okw.setId(id);
122
				okw.setKw(kws[i]);
123
				okws[i] = okw;
124
			}
125
			artKeyWordDao.insert(con, okws);
126
		}
127
	}
128

129
	public void refreshResource(Connection con, String id, String[] kws) throws SQLException {
130
		resKeyWordDao.delete(con, id);
131
		if (kws != null && kws.length > 0) {
132
			ResKeyWord[] okws = new ResKeyWord[kws.length];
133
			for (int i = 0; i < kws.length; ++i) {
134
				ResKeyWord okw = new ResKeyWord();
135
				okw.setId(id);
136
				okw.setKw(kws[i]);
137
				okws[i] = okw;
138
			}
139
			resKeyWordDao.insert(con, okws);
140
		}
141
	}
142

143
	public void refreshPaper(Connection con, String id, String[] kws) throws SQLException {
144
		papKeyWordDao.delete(con, id);
145
		if (kws != null && kws.length > 0) {
146
			PapKeyWord[] okws = new PapKeyWord[kws.length];
147
			for (int i = 0; i < kws.length; ++i) {
148
				PapKeyWord okw = new PapKeyWord();
149
				okw.setId(id);
150
				okw.setKw(kws[i]);
151
				okws[i] = okw;
152
			}
153
			papKeyWordDao.insert(con, okws);
154
		}
155
	}
156

157
	public void refreshPatent(Connection con, String id, String[] kws) throws SQLException {
158
		patKeyWordDao.delete(con, id);
159
		if (kws != null && kws.length > 0) {
160
			PatKeyWord[] okws = new PatKeyWord[kws.length];
161
			for (int i = 0; i < kws.length; ++i) {
162
				PatKeyWord okw = new PatKeyWord();
163
				okw.setId(id);
164
				okw.setKw(kws[i]);
165
				okws[i] = okw;
166
			}
167
			patKeyWordDao.insert(con, okws);
168
		}
169
	}
170

171
	public static String[] splitKeyWord(String kws) {
172
		if (kws == null || kws.trim().length() == 0)
173
			return null;
174
		kws = kws.trim();
175
		ArrayList<String> result = new ArrayList<String>();
176
		char[] cs = kws.toCharArray();
177
		int mi = cs.length;
178
		if (mi > 0) {
179
			int begin = 0;
180
			for (int i = 0; i < mi; ++i) {
181
				char c = cs[i];
182
				if (c == ',') {
183
					if (i != begin) {
184
						String kw = new String(cs, begin, i - begin);
185
						if (!result.contains(kw)) {
186
							result.add(new String(cs, begin, i - begin));
187
						}
188
					}
189
					begin = i + 1;
190
				}
191
			}
192
			if (begin != mi)
193
				result.add(new String(cs, begin, mi - begin));
194
		}
195
		return result.isEmpty() ? null : result.toArray(new String[result.size()]);
196
	}
197

198
}

+ 86 - 4
src/main/java/com/ekexiu/portal/service/LeaveWordService.java

@ -20,6 +20,11 @@ import com.ekexiu.portal.pojo.EditProfessor;
20 20
@Path("/leaveWord")
21 21
public class LeaveWordService {
22 22
	public static final String MAX_CREATETIME="9";
23
	
24
	public static final String ARTICLE="1";
25
	public static final String PAPER="2";
26
	public static final String PATENT="3";
27
	
23 28

24 29
	@Autowrie
25 30
	private LeaveWordDao leaveWordDao;
@ -54,10 +59,45 @@ public class LeaveWordService {
54 59

55 60
	@Post
56 61
	@Path
57
	public String insert(@JdbcConn(true) Connection con,LeaveWord word) throws SQLException{
62
	public String insert(@JdbcConn(true) Connection con,String content,String sender,String articleId) throws SQLException{
58 63
		String id = StringUtil.buildUUID();
64
		LeaveWord word = new LeaveWord();
59 65
		word.setId(id);
60 66
		word.setOrderKey(System.nanoTime());
67
		word.setObjId(articleId);
68
		word.setCategory(ARTICLE);
69
		word.setContent(content);
70
		word.setSender(sender);
71
		this.leaveWordDao.insert(con, word);
72
		return id;
73
	}
74
	
75
	@Post
76
	@Path("/paper")
77
	public String paper(@JdbcConn(true) Connection con,String paperId,String content,String sender) throws SQLException{
78
		String id = StringUtil.buildUUID();
79
		LeaveWord word = new LeaveWord();
80
		word.setId(id);
81
		word.setOrderKey(System.nanoTime());
82
		word.setObjId(paperId);
83
		word.setCategory(PAPER);
84
		word.setContent(content);
85
		word.setSender(sender);
86
		this.leaveWordDao.insert(con, word);
87
		return id;
88
	}
89
	
90
	@Post
91
	@Path("/patent")
92
	public String patent(@JdbcConn(true) Connection con,String patentId,String content,String sender) throws SQLException{
93
		String id = StringUtil.buildUUID();
94
		LeaveWord word = new LeaveWord();
95
		word.setId(id);
96
		word.setOrderKey(System.nanoTime());
97
		word.setObjId(patentId);
98
		word.setCategory(PATENT);
99
		word.setContent(content);
100
		word.setSender(sender);
61 101
		this.leaveWordDao.insert(con, word);
62 102
		return id;
63 103
	}
@ -65,13 +105,56 @@ public class LeaveWordService {
65 105
	@Get
66 106
	@Path("/lwCount")
67 107
	public int queryCount(@JdbcConn Connection con,String articleId)throws SQLException{
68
		return this.leaveWordDao.queryCount(con, articleId);
108
		return this.leaveWordDao.queryCount(con, articleId,ARTICLE);
109
	}
110
	@Get
111
	@Path("/lwCount/paper")
112
	public int queryCountByPaper(@JdbcConn Connection con,String paperId)throws SQLException{
113
		return this.leaveWordDao.queryCount(con, paperId,PAPER);
114
	}
115
	@Get
116
	@Path("/lwCount/patent")
117
	public int queryCountByPatent(@JdbcConn Connection con,String patentId)throws SQLException{
118
		return this.leaveWordDao.queryCount(con, patentId,PATENT);
69 119
	}
120

121
	
122
	
70 123
	
71 124
	@Get
72 125
	@Path("/ql")
73 126
	public List<LeaveWord> query(@JdbcConn Connection con,String articleId,@DefaultValue("com.ekexiu.portal.service.LeaveWordService.MAX_CREATETIME")  String createTime,@DefaultValue("Long.MAX_VALUE") long orderKey,@DefaultValue("10") int rows) throws SQLException{
74
		List<LeaveWord> leaveWords = this.leaveWordDao.query(con, articleId, createTime, orderKey, rows);
127
		List<LeaveWord> leaveWords = this.leaveWordDao.query(con, articleId,ARTICLE, createTime, orderKey, rows);
128
		if(!leaveWords.isEmpty()){
129
			for (LeaveWord leaveWord : leaveWords) {
130
				EditProfessor professor = this.professorDao.queryBaseInfo(con, leaveWord.getSender());
131
				if(professor != null){
132
					professor.setHasHeadImage(this.imageService.hasProfessorImage(leaveWord.getSender()));
133
				}
134
				leaveWord.setProfessor(professor);
135
			}
136
		}
137
		return leaveWords;
138
	}
139
	
140
	@Get
141
	@Path("/ql/paper")
142
	public List<LeaveWord> queryWithPaper(@JdbcConn Connection con,String paperId,@DefaultValue("com.ekexiu.portal.service.LeaveWordService.MAX_CREATETIME")  String createTime,@DefaultValue("Long.MAX_VALUE") long orderKey,@DefaultValue("10") int rows) throws SQLException{
143
		List<LeaveWord> leaveWords = this.leaveWordDao.query(con, paperId,PAPER, createTime, orderKey, rows);
144
		if(!leaveWords.isEmpty()){
145
			for (LeaveWord leaveWord : leaveWords) {
146
				EditProfessor professor = this.professorDao.queryBaseInfo(con, leaveWord.getSender());
147
				if(professor != null){
148
					professor.setHasHeadImage(this.imageService.hasProfessorImage(leaveWord.getSender()));
149
				}
150
				leaveWord.setProfessor(professor);
151
			}
152
		}
153
		return leaveWords;
154
	}	@Get
155
	@Path("/ql/patent")
156
	public List<LeaveWord> queryWithPatent(@JdbcConn Connection con,String patentId,@DefaultValue("com.ekexiu.portal.service.LeaveWordService.MAX_CREATETIME")  String createTime,@DefaultValue("Long.MAX_VALUE") long orderKey,@DefaultValue("10") int rows) throws SQLException{
157
		List<LeaveWord> leaveWords = this.leaveWordDao.query(con, patentId,PATENT, createTime, orderKey, rows);
75 158
		if(!leaveWords.isEmpty()){
76 159
			for (LeaveWord leaveWord : leaveWords) {
77 160
				EditProfessor professor = this.professorDao.queryBaseInfo(con, leaveWord.getSender());
@ -89,5 +172,4 @@ public class LeaveWordService {
89 172
	public void delete(@JdbcConn(true) Connection con,String id)throws SQLException{
90 173
		this.leaveWordDao.delete(con, id);
91 174
	}
92
	
93 175
}

+ 76 - 2
src/main/java/com/ekexiu/portal/service/OrgService.java

@ -3,6 +3,7 @@ package com.ekexiu.portal.service;
3 3
import java.io.IOException;
4 4
import java.sql.Connection;
5 5
import java.sql.SQLException;
6
import java.util.Collections;
6 7
import java.util.List;
7 8
8 9
import org.jfw.apt.annotation.Autowrie;
@ -20,6 +21,7 @@ import com.ekexiu.portal.dao.OrgDao;
20 21
import com.ekexiu.portal.dao.OrgRegInfoDao;
21 22
import com.ekexiu.portal.po.OrgRegInfo;
22 23
import com.ekexiu.portal.po.Organization;
24
import com.ekexiu.portal.po.Professor;
23 25
import com.ekexiu.portal.pojo.EditOrganization;
24 26
25 27
@Path("/org")
@ -39,8 +41,18 @@ public class OrgService {
39 41
	@Autowrie
40 42
	private OrgRegInfoDao orgRegInfoDao;
41 43
	
44
	@Autowrie
45
	private KeyWordService keyWordService;
42 46
	
43 47
	
48
	public KeyWordService getKeyWordService() {
49
		return keyWordService;
50
	}
51
52
	public void setKeyWordService(KeyWordService keyWordService) {
53
		this.keyWordService = keyWordService;
54
	}
55
44 56
	public OrgRegInfoDao getOrgRegInfoDao() {
45 57
		return orgRegInfoDao;
46 58
	}
@ -88,6 +100,18 @@ public class OrgService {
88 100
		organization.setId(StringUtil.buildUUID());
89 101
		if(organization.getOrgType()== null) organization.setOrgType(this.defaultOrgType);
90 102
		this.orgDao.insert(con, organization);
103
		Organization no = this.orgDao.query(con, organization.getId());
104
		if(no!=null && no.getIsJoin().equals("1")){
105
			String s = no.getSubject();
106
			String in = no.getIndustry();
107
			String kw = s==null?"":s.trim();
108
			kw = kw + (in==null?"":(","+in.trim()));
109
			
110
			this.keyWordService.refreshOrg(con,organization.getId(),KeyWordService.splitKeyWord(kw));
111
		}else{
112
			this.keyWordService.refreshOrg(con,organization.getId(),null);
113
		}
114
		
91 115
	}
92 116
	
93 117
	
@ -98,6 +122,17 @@ public class OrgService {
98 122
			this.imageService.saveOrgLogo(organization.getId(), fn);
99 123
		}
100 124
		this.orgDao.update(con, organization);
125
		Organization no = this.orgDao.query(con, organization.getId());
126
		if(no!=null && no.getIsJoin().equals("1")){
127
			String s = no.getSubject();
128
			String in = no.getIndustry();
129
			String kw = s==null?"":s.trim();
130
			kw = kw + (in==null?"":(","+in.trim()));
131
			
132
			this.keyWordService.refreshOrg(con,organization.getId(),KeyWordService.splitKeyWord(kw));
133
		}else{
134
			this.keyWordService.refreshOrg(con,organization.getId(),null);
135
		}
101 136
	}
102 137
	
103 138
	@Get
@ -186,9 +221,24 @@ public class OrgService {
186 221
	
187 222
	@Get
188 223
	@Path("/find/pq")
189
	public PageQueryResult<EditOrganization> pageQuery(@JdbcConn Connection con,@Nullable String kw,@DefaultValue("20") int pageSize,@DefaultValue("1") int pageNo)throws SQLException
224
	public PageQueryResult<EditOrganization> pageQuery(@JdbcConn Connection con,@Nullable String kw,@Nullable String industry,
225
			@Nullable String city, @DefaultValue("20") int pageSize,@DefaultValue("1") int pageNo)throws SQLException
190 226
	{
191
		PageQueryResult<EditOrganization> pqr = kw==null?this.orgDao.query(con, pageSize, pageNo):this.orgDao.query(con,"%"+kw+"%", pageSize, pageNo);
227
		PageQueryResult<EditOrganization> pqr =null;
228
		if(kw==null && industry==null && city ==null)
229
		{
230
			pqr = this.orgDao.query(con, pageSize, pageNo);
231
		}else if(kw != null && industry==null && city ==null){
232
			pqr =this.orgDao.query(con,"%"+kw+"%", pageSize, pageNo);
233
		}else if(kw == null){
234
			industry = industry==null?"%":("%"+industry+"%");			
235
			city = city==null?"%":("%"+city+"%");			
236
			pqr = this.orgDao.queryByIndustryAndAddr(con, industry, city, pageSize, pageNo);
237
		}else{
238
			industry = industry==null?"%":("%"+industry+"%");			
239
			city = city==null?"%":("%"+city+"%");		
240
			pqr = this.orgDao.queryByKwAndIndustryAndAddr(con, "%"+kw+"%", industry, city, pageSize, pageNo);
241
		}
192 242
		for (EditOrganization organization : pqr.getData()) {
193 243
			organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
194 244
		}
@ -203,4 +253,28 @@ public class OrgService {
203 253
		}
204 254
		return ret;
205 255
	}
256
	
257
	@Get
258
	@Path("/qr")
259
	public List<EditOrganization> relateQuery(@JdbcConn Connection con,@Nullable String kw,@DefaultValue("3") int limit) throws SQLException{
260
		List<EditOrganization> ret = this.orgDao.relateQuery(con, kw==null?"%":("%"+kw+"%"), limit);
261
		for (EditOrganization organization :ret) {
262
			organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
263
		}
264
		return ret;
265
	}
266
	
267
	@Get
268
	@Path("/ralateOrgs")
269
	public List<EditOrganization> ralateArticles(@JdbcConn Connection con,String orgId,@DefaultValue("5") int rows)throws SQLException{
270
		String[] ids = this.orgDao.queryOrgIdWithSameKeyWord(con, orgId, rows);
271
		if(ids!=null){
272
			List<EditOrganization> ret = this.orgDao.query(con,ids);
273
			for (EditOrganization organization :ret) {
274
				organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
275
			}
276
			return ret;
277
		}
278
		return Collections.<EditOrganization>emptyList();
279
	}
206 280
}

+ 75 - 0
src/main/java/com/ekexiu/portal/service/PpaperService.java

@ -2,6 +2,7 @@ package com.ekexiu.portal.service;
2 2

3 3
import java.sql.Connection;
4 4
import java.sql.SQLException;
5
import java.util.Collections;
5 6
import java.util.List;
6 7

7 8
import org.jfw.apt.annotation.Autowrie;
@ -13,10 +14,13 @@ import org.jfw.apt.web.annotation.operate.Post;
13 14
import org.jfw.apt.web.annotation.param.JdbcConn;
14 15
import org.jfw.util.PageQueryResult;
15 16

17
import com.ekexiu.portal.dao.PaperAgreeDao;
16 18
import com.ekexiu.portal.dao.PaperAuthorDao;
17 19
import com.ekexiu.portal.dao.PpaperDao;
20
import com.ekexiu.portal.po.PaperAgree;
18 21
import com.ekexiu.portal.po.PaperAuthor;
19 22
import com.ekexiu.portal.po.Ppaper;
23
import com.ekexiu.portal.po.Ppatent;
20 24
import com.ekexiu.portal.pojo.AssedPaper;
21 25

22 26
@Path("/ppaper")
@ -26,6 +30,31 @@ public class PpaperService {
26 30
	private PpaperDao ppaperDao;
27 31
	@Autowrie
28 32
	private PaperAuthorDao paperAuthorDao;
33
	
34
	@Autowrie
35
	private KeyWordService keyWordService;
36
	
37
	@Autowrie
38
	private PaperAgreeDao paperAgreeDao;
39
	
40
	
41
	
42

43
	public PaperAgreeDao getPaperAgreeDao() {
44
		return paperAgreeDao;
45
	}
46

47
	public void setPaperAgreeDao(PaperAgreeDao paperAgreeDao) {
48
		this.paperAgreeDao = paperAgreeDao;
49
	}
50

51
	public KeyWordService getKeyWordService() {
52
		return keyWordService;
53
	}
54

55
	public void setKeyWordService(KeyWordService keyWordService) {
56
		this.keyWordService = keyWordService;
57
	}
29 58

30 59
	public PpaperDao getPpaperDao() {
31 60
		return ppaperDao;
@ -136,6 +165,7 @@ public class PpaperService {
136 165
	@Path("/kw")
137 166
	public void update(@JdbcConn(true) Connection con, String id, @Nullable String keywords) throws SQLException {
138 167
		this.ppaperDao.update(con, id, keywords);
168
		this.keyWordService.refreshPaper(con, id, KeyWordService.splitKeyWord(keywords));		
139 169
	}
140 170

141 171
	@Get
@ -143,4 +173,49 @@ public class PpaperService {
143 173
	public Ppaper query(@JdbcConn Connection con,long id) throws SQLException{
144 174
		return this.ppaperDao.query(con,id);
145 175
	}
176
	@Get
177
	@Path("/ralatePapers")
178
	public List<Ppaper> ralatePapers(@JdbcConn Connection con,String paperId,@DefaultValue("5") int rows)throws SQLException{
179
		String[] ids = this.ppaperDao.queryPaperIdWithSameKeyWord(con, paperId, rows);
180
		if(ids!=null){
181
			return this.ppaperDao.query(con,ids);
182
		}
183
		return Collections.<Ppaper>emptyList();
184
	}
185
	
186
	
187
	@Post
188
	@Path("/agree")
189
	public void agree(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
190
		PaperAgree pa = new PaperAgree();
191
		pa.setOpId(uid);
192
		pa.setPaperId(id);
193
		this.paperAgreeDao.insert(con, pa);		
194
	}
195
	
196
//	@Post
197
//	@Path("/unAgree")
198
//	public void unAgree(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
199
//		this.paperAgreeDao.delete(con,uid, id);
200
//	}
201
	
202
	@Get
203
	@Path("/agree")
204
	public boolean hasAgree(@JdbcConn(false) Connection con,String id,String uid)throws SQLException{
205
		return null!= this.paperAgreeDao.query(con,uid, id);
206
	}
207
	@Get
208
	@Path("/agreeCount")
209
	public int agreeCount(@JdbcConn(false) Connection con,String id)throws SQLException{
210
		return this.paperAgreeDao.query(con,id);
211
	}
212
	
213
	@Get
214
	@Path("/assPapers")
215
	public List<Ppaper> assPapers(@JdbcConn Connection con,String[] kws,@DefaultValue("5") int rows) throws SQLException{
216
		if(kws==null || kws.length==0) return Collections.<Ppaper>emptyList();		
217
		String[] ids = this.ppaperDao.queryPatentIdWithKeyWord(con, kws, rows);
218
		if(ids==null || ids.length==0) return Collections.<Ppaper>emptyList();
219
		return this.ppaperDao.query(con, ids);		
220
	}
146 221
}

+ 73 - 0
src/main/java/com/ekexiu/portal/service/PpatentServcie.java

@ -2,6 +2,7 @@ package com.ekexiu.portal.service;
2 2

3 3
import java.sql.Connection;
4 4
import java.sql.SQLException;
5
import java.util.Collections;
5 6
import java.util.List;
6 7

7 8
import org.jfw.apt.annotation.Autowrie;
@ -13,8 +14,12 @@ import org.jfw.apt.web.annotation.operate.Post;
13 14
import org.jfw.apt.web.annotation.param.JdbcConn;
14 15
import org.jfw.util.PageQueryResult;
15 16

17
import com.ekexiu.portal.dao.PaperAuthorDao;
18
import com.ekexiu.portal.dao.PatentAgreeDao;
16 19
import com.ekexiu.portal.dao.PatentAuthorDao;
17 20
import com.ekexiu.portal.dao.PpatentDao;
21
import com.ekexiu.portal.po.PaperAuthor;
22
import com.ekexiu.portal.po.PatentAgree;
18 23
import com.ekexiu.portal.po.PatentAuthor;
19 24
import com.ekexiu.portal.po.Ppatent;
20 25
import com.ekexiu.portal.pojo.AssedPatent;
@ -27,7 +32,29 @@ public class PpatentServcie {
27 32
	@Autowrie
28 33
	private PatentAuthorDao patentAuthorDao;
29 34
	
35
	@Autowrie
36
	private KeyWordService keyWordService;
37
	
38
	@Autowrie
39
	private PatentAgreeDao patentAgreeDao;
40
	
30 41
	
42

43
	public PatentAgreeDao getPatentAgreeDao() {
44
		return patentAgreeDao;
45
	}
46

47
	public void setPatentAgreeDao(PatentAgreeDao patentAgreeDao) {
48
		this.patentAgreeDao = patentAgreeDao;
49
	}
50

51
	public KeyWordService getKeyWordService() {
52
		return keyWordService;
53
	}
54

55
	public void setKeyWordService(KeyWordService keyWordService) {
56
		this.keyWordService = keyWordService;
57
	}
31 58
	
32 59
	public PpatentDao getPpatentDao() {
33 60
		return ppatentDao;
@ -134,10 +161,56 @@ public class PpatentServcie {
134 161
	@Path("/kw")
135 162
	public void update(@JdbcConn(true) Connection con,String id,@Nullable String keywords)throws SQLException{
136 163
		this.ppatentDao.update(con, id, keywords);
164
		this.keyWordService.refreshPatent(con, id, KeyWordService.splitKeyWord(keywords));		
137 165
	}
138 166
	@Get
139 167
	@Path("/byShareId")
140 168
	public Ppatent query(@JdbcConn Connection con,long id)throws SQLException{
141 169
		return this.ppatentDao.query(con,id);
142 170
	}
171
	@Get
172
	@Path("/ralatePatents")
173
	public List<Ppatent> ralatePatents(@JdbcConn Connection con,String patentId,@DefaultValue("5") int rows)throws SQLException{
174
		String[] ids = this.ppatentDao.queryPatentIdWithSameKeyWord(con, patentId, rows);
175
		if(ids!=null){
176
			return this.ppatentDao.query(con,ids);
177
		}
178
		return Collections.<Ppatent>emptyList();
179
	}
180
	
181
	@Post
182
	@Path("/agree")
183
	public void agree(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
184
		PatentAgree pa = new PatentAgree();
185
		pa.setOpId(uid);
186
		pa.setPatentId(id);
187
		this.patentAgreeDao.insert(con, pa);		
188
	}
189
	
190
//	@Post
191
//	@Path("/unAgree")
192
//	public void unAgree(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
193
//		this.patentAgreeDao.delete(con,uid, id);
194
//	}
195
	
196
	@Get
197
	@Path("/agree")
198
	public boolean hasAgree(@JdbcConn(false) Connection con,String id,String uid)throws SQLException{
199
		return null!= this.patentAgreeDao.query(con,uid, id);
200
	}
201
	@Get
202
	@Path("/agreeCount")
203
	public int agreeCount(@JdbcConn(false) Connection con,String id)throws SQLException{
204
		return this.patentAgreeDao.query(con,id);
205
	}
206
	
207
	@Get
208
	@Path("/assPatents")
209
	public List<Ppatent> assPatent(@JdbcConn Connection con,String[] kws,@DefaultValue("5") int rows)throws SQLException{
210
		if(kws==null || kws.length==0) return Collections.<Ppatent>emptyList();		
211
		String[] ids = this.ppatentDao.queryPatentIdWithKeyWord(con, kws, rows);
212
		if(ids==null || ids.length==0) return Collections.<Ppatent>emptyList();
213
		return this.ppatentDao.query(con, ids);		
214
	}
215
	
143 216
}

+ 255 - 130
src/main/java/com/ekexiu/portal/service/ProfessorService.java

@ -4,9 +4,15 @@ import java.io.IOException;
4 4
import java.math.BigDecimal;
5 5
import java.net.URLEncoder;
6 6
import java.sql.Connection;
7
import java.sql.PreparedStatement;
8
import java.sql.ResultSet;
7 9
import java.sql.SQLException;
8 10
import java.text.DecimalFormat;
11
import java.util.ArrayList;
12
import java.util.Collections;
13
import java.util.HashMap;
9 14
import java.util.List;
15
import java.util.Map;
10 16

11 17
import org.jfw.apt.annotation.Autowrie;
12 18
import org.jfw.apt.annotation.DefaultValue;
@ -21,6 +27,7 @@ import org.jfw.apt.web.annotation.param.PathVar;
21 27
import org.jfw.apt.web.annotation.param.RequestBody;
22 28
import org.jfw.util.PageQueryResult;
23 29
import org.jfw.util.StringUtil;
30
import org.jfw.util.jdbc.JdbcUtil;
24 31

25 32
import com.ekexiu.portal.dao.ArticleDao;
26 33
import com.ekexiu.portal.dao.HonorDao;
@ -92,6 +99,17 @@ public class ProfessorService {
92 99
	@Autowrie
93 100
	private OrgResStaffDao orgResStaffDao;
94 101

102
	@Autowrie
103
	private KeyWordService keyWordService;
104

105
	public KeyWordService getKeyWordService() {
106
		return keyWordService;
107
	}
108

109
	public void setKeyWordService(KeyWordService keyWordService) {
110
		this.keyWordService = keyWordService;
111
	}
112

95 113
	public GrowthLogService getGrowthLogService() {
96 114
		return growthLogService;
97 115
	}
@ -243,7 +261,6 @@ public class ProfessorService {
243 261
	public void setOrgDao(OrgDao orgDao) {
244 262
		this.orgDao = orgDao;
245 263
	}
246
	
247 264

248 265
	public ImageDao getImageDao() {
249 266
		return imageDao;
@ -263,37 +280,36 @@ public class ProfessorService {
263 280

264 281
	@Post
265 282
	@Path
266
	public String insert(@JdbcConn(true) Connection con, Professor professor, @Nullable String orgName)
267
			throws SQLException, IOException {
268
		if(professor.getId() == null ) {
283
	public String insert(@JdbcConn(true) Connection con, Professor professor, @Nullable String orgName) throws SQLException, IOException {
284
		if (professor.getId() == null) {
269 285
			professor.setId(StringUtil.buildUUID());
270 286
		}
271 287
		if (professor.getOrgId() == null && orgName != null) {
272
			if(null != this.orgDao.queryByName(con, orgName)){
288
			if (null != this.orgDao.queryByName(con, orgName)) {
273 289
				professor.setOrgId(this.orgDao.queryByName(con, orgName));
274 290
			} else {
275 291
				professor.setOrgId(this.orgService.createOrganization(con, orgName));
276 292
			}
277 293
		}
278
		if(professor.getOrgAuth() == null){
294
		if (professor.getOrgAuth() == null) {
279 295
			professor.setOrgAuth("0");
280 296
		}
281 297
		User user = this.userDao.query(con, professor.getId());
282
		if(user != null){
298
		if (user != null) {
283 299
			int value = 0;
284
			if(user.getMobilePhone() != null && user.getMobilePhone().trim().length() == 11){
300
			if (user.getMobilePhone() != null && user.getMobilePhone().trim().length() == 11) {
285 301
				professor.setPhone(user.getMobilePhone());
286 302
				value = value + this.rule.getBindMobile();
287 303
				this.growthLogService.firstBindMobile(con, professor.getId());
288 304
			}
289
			if(user.getEmail() != null && !"".equals(user.getEmail())){
305
			if (user.getEmail() != null && !"".equals(user.getEmail())) {
290 306
				professor.setEmail(user.getEmail());
291 307
				value = value + this.rule.getBindEmail();
292 308
				this.growthLogService.firstBindEmail(con, professor.getId());
293 309
			}
294 310
			professor.setScoreValue(value);
295 311
			professor.setGrowthValue(value);
296
		}else{
312
		} else {
297 313
			professor.setScoreValue(0);
298 314
			professor.setGrowthValue(0);
299 315
		}
@ -304,30 +320,30 @@ public class ProfessorService {
304 320
	@Put
305 321
	@Path
306 322
	public void update(@JdbcConn(true) Connection con, @RequestBody EditProfessor professor) throws SQLException, IOException {
307
		if(professor.getOrgName()!=null)
308
			if(null != this.orgDao.queryByName(con, professor.getOrgName())){
323
		if (professor.getOrgName() != null)
324
			if (null != this.orgDao.queryByName(con, professor.getOrgName())) {
309 325
				professor.setOrgId(this.orgDao.queryByName(con, professor.getOrgName()));
310 326
			} else {
311 327
				professor.setOrgId(this.orgService.createOrganization(con, professor.getOrgName()));
312 328
			}
313 329
		this.professorDao.update(con, professor);
314 330
	}
315
	
331

316 332
	@Post
317 333
	@Path("/updatePro")
318
	public void updatePro(@JdbcConn(true) Connection con,EditProfessor professor)throws SQLException, IOException{
319
		if(professor.getOrgName()!=null)
320
			if(null != this.orgDao.queryByName(con, professor.getOrgName())){
334
	public void updatePro(@JdbcConn(true) Connection con, EditProfessor professor) throws SQLException, IOException {
335
		if (professor.getOrgName() != null)
336
			if (null != this.orgDao.queryByName(con, professor.getOrgName())) {
321 337
				professor.setOrgId(this.orgDao.queryByName(con, professor.getOrgName()));
322 338
			} else {
323 339
				professor.setOrgId(this.orgService.createOrganization(con, professor.getOrgName()));
324 340
			}
325 341
		this.professorDao.update(con, professor);
326 342
	}
327
	
343

328 344
	@Get
329 345
	@Path("/queryInvite")
330
	public List<EditProfessor> queryInvite(@JdbcConn Connection con, String id) throws SQLException{
346
	public List<EditProfessor> queryInvite(@JdbcConn Connection con, String id) throws SQLException {
331 347
		List<EditProfessor> professors = this.professorDao.queryInvite(con, id);
332 348
		for (EditProfessor professor : professors) {
333 349
			professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
@ -336,27 +352,27 @@ public class ProfessorService {
336 352
		}
337 353
		return professors;
338 354
	}
339
	
355

340 356
	@Get
341 357
	@Path("/auth")
342
	public Professor queryAuth(@JdbcConn Connection con, String id) throws SQLException{
358
	public Professor queryAuth(@JdbcConn Connection con, String id) throws SQLException {
343 359
		return this.professorDao.queryAuth(con, id);
344 360
	}
345
	
361

346 362
	@Get
347 363
	@Path("/baseInfo/{id}")
348 364
	public EditProfessor queryBaseInfo(@JdbcConn Connection con, @PathVar String id) throws SQLException {
349 365
		EditProfessor professor = this.professorDao.queryBaseInfo(con, id);
350
		if(null != professor){
366
		if (null != professor) {
351 367
			professor.setHasHeadImage(this.imageService.hasProfessorImage(id));
352 368
		}
353 369
		return professor;
354 370
	}
355
	
371

356 372
	@Get
357 373
	@Path("/qaByName")
358
	public List<EditProfessor> queryByName(@JdbcConn Connection con,@Nullable String name,@DefaultValue("3") int total)throws SQLException {
359
		if(name != null){
374
	public List<EditProfessor> queryByName(@JdbcConn Connection con, @Nullable String name, @DefaultValue("3") int total) throws SQLException {
375
		if (name != null) {
360 376
			name = "%" + name + "%";
361 377
		}
362 378
		List<EditProfessor> professors = this.professorDao.queryByName(con, name, total);
@ -365,35 +381,36 @@ public class ProfessorService {
365 381
		}
366 382
		return professors;
367 383
	}
368
	
384

369 385
	@Get
370 386
	@Path("/editBaseInfo/{id}")
371 387
	public EditProfessor queryEditBaseInfo(@JdbcConn Connection con, @PathVar String id) throws SQLException {
372 388
		EditProfessor professor = this.professorDao.queryEditBaseInfo(con, id);
373
		if(null != professor){
389
		if (null != professor) {
374 390
			professor.setHasHeadImage(this.imageService.hasProfessorImage(id));
375 391
		}
376 392
		return professor;
377 393
	}
378
	
394

379 395
	@Get
380 396
	@Path("/{id}")
381 397
	public Professor query(@JdbcConn Connection con, @PathVar String id) throws SQLException {
382 398
		return this.professorDao.query(con, id);
383 399
	}
400

384 401
	@Get
385 402
	@Path("/qa")
386 403
	public List<Professor> queryAll(@JdbcConn Connection con) throws SQLException {
387 404
		return this.professorDao.query(con);
388 405
	}
389
	
406

390 407
	@Get
391 408
	@Path("/pqOrgAuth")
392
	public PageQueryResult<EditProfessor> queryPageOrgAuth(@JdbcConn Connection con,String orgId,@Nullable String orgAuth,
393
			@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
409
	public PageQueryResult<EditProfessor> queryPageOrgAuth(@JdbcConn Connection con, String orgId, @Nullable String orgAuth, @DefaultValue("10") int pageSize,
410
			@DefaultValue("1") int pageNo) throws SQLException {
394 411
		PageQueryResult<EditProfessor> queryResult = this.professorDao.queryPage(con, orgId, orgAuth, pageSize, pageNo);
395 412
		List<EditProfessor> professors = queryResult.getData();
396
		if(!professors.isEmpty()){
413
		if (!professors.isEmpty()) {
397 414
			for (EditProfessor professor : professors) {
398 415
				professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
399 416
				professor.setResearchAreas(this.researchAreaDao.query(con, professor.getId()));
@ -402,10 +419,10 @@ public class ProfessorService {
402 419
		}
403 420
		return queryResult;
404 421
	}
405
	
422

406 423
	@Get
407 424
	@Path("/qaOrgAuth")
408
	public List<EditProfessor> queryOrgAuth(@JdbcConn Connection con,String orgId,@Nullable String orgAuth)throws SQLException{
425
	public List<EditProfessor> queryOrgAuth(@JdbcConn Connection con, String orgId, @Nullable String orgAuth) throws SQLException {
409 426
		List<EditProfessor> professors = this.professorDao.queryByOrg(con, orgId, orgAuth);
410 427
		for (EditProfessor professor : professors) {
411 428
			professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
@ -413,7 +430,7 @@ public class ProfessorService {
413 430
		}
414 431
		return professors;
415 432
	}
416
	
433

417 434
	public void updateStarAvg(Connection con) throws SQLException {
418 435
		try {
419 436
			List<Professor> professors = this.professorDao.queryStar(con);
@ -432,7 +449,7 @@ public class ProfessorService {
432 449
			e.printStackTrace();
433 450
		}
434 451
	}
435
	
452

436 453
	public void updateScorePercent(Connection con) throws SQLException {
437 454
		List<Professor> professors = this.professorDao.queryList(con);
438 455
		int count = this.professorDao.queryCount(con);
@ -440,8 +457,8 @@ public class ProfessorService {
440 457
			for (Professor professor : professors) {
441 458
				int lessThan = this.professorDao.queryCountLessThan(con, professor.getScoreValue());
442 459
				double value = 0;
443
				if(count != 0){
444
					value = (double)lessThan/(double)count;
460
				if (count != 0) {
461
					value = (double) lessThan / (double) count;
445 462
				}
446 463
				DecimalFormat df = new DecimalFormat("#%");
447 464
				this.professorDao.updateScorePercent(con, professor.getId(), df.format(value));
@ -451,13 +468,14 @@ public class ProfessorService {
451 468
			e.printStackTrace();
452 469
		}
453 470
	}
454
	
471

455 472
	@Get
456 473
	@Path("/pqHot")
457
	public PageQueryResult<EditProfessor> queryHot(@JdbcConn Connection con,@DefaultValue("8") int pageSize,@DefaultValue("1") int pageNo) throws SQLException {
474
	public PageQueryResult<EditProfessor> queryHot(@JdbcConn Connection con, @DefaultValue("8") int pageSize, @DefaultValue("1") int pageNo)
475
			throws SQLException {
458 476
		PageQueryResult<EditProfessor> queryResult = this.professorDao.queryHot(con, pageSize, pageNo);
459 477
		List<EditProfessor> professors = queryResult.getData();
460
		if(!professors.isEmpty()){
478
		if (!professors.isEmpty()) {
461 479
			for (EditProfessor editProfessor : professors) {
462 480
				editProfessor.setHasHeadImage(this.imageService.hasProfessorImage(editProfessor.getId()));
463 481
				editProfessor.setResearchAreas(this.researchAreaDao.query(con, editProfessor.getId()));
@ -466,21 +484,30 @@ public class ProfessorService {
466 484
		}
467 485
		return queryResult;
468 486
	}
469
	
487

470 488
	@Get
471 489
	@Path("/pqAPP")
472
	public PageQueryResult<EditProfessor> queryAPP(@JdbcConn Connection con, @Nullable String key,
473
			@Nullable String subject,@Nullable String industry,@Nullable String province,
474
			@Nullable String address, @DefaultValue("1") Integer authType, 
475
			@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo) throws SQLException{
476
		if(key!=null) {key="%"+key+"%";}
477
		if(subject!=null) {subject ="%"+subject+"%";}
478
		if(null!=industry) {industry="%"+industry+"%";}
479
		if(null!=province) {province="%"+province+"%";}
480
		if(null!=address) {address="%"+address+"%";}
481
		PageQueryResult<EditProfessor> queryResult = this.professorDao.queryAPP(con,key,subject,industry,province,address,authType,pageSize,pageNo);
490
	public PageQueryResult<EditProfessor> queryAPP(@JdbcConn Connection con, @Nullable String key, @Nullable String subject, @Nullable String industry,
491
			@Nullable String province, @Nullable String address, @DefaultValue("1") Integer authType, @DefaultValue("10") int pageSize,
492
			@DefaultValue("1") int pageNo) throws SQLException {
493
		if (key != null) {
494
			key = "%" + key + "%";
495
		}
496
		if (subject != null) {
497
			subject = "%" + subject + "%";
498
		}
499
		if (null != industry) {
500
			industry = "%" + industry + "%";
501
		}
502
		if (null != province) {
503
			province = "%" + province + "%";
504
		}
505
		if (null != address) {
506
			address = "%" + address + "%";
507
		}
508
		PageQueryResult<EditProfessor> queryResult = this.professorDao.queryAPP(con, key, subject, industry, province, address, authType, pageSize, pageNo);
482 509
		List<EditProfessor> editProfessors = queryResult.getData();
483
		if(!editProfessors.isEmpty()) {
510
		if (!editProfessors.isEmpty()) {
484 511
			for (EditProfessor editProfessor : editProfessors) {
485 512
				editProfessor.setHasHeadImage(this.imageService.hasProfessorImage(editProfessor.getId()));
486 513
				editProfessor.setResearchAreas(this.researchAreaDao.query(con, editProfessor.getId()));
@ -490,82 +517,97 @@ public class ProfessorService {
490 517
		}
491 518
		return queryResult;
492 519
	}
493
	
520

494 521
	@Post
495 522
	@Path("/sortFirst")
496
	public void updateSortFirst(@JdbcConn(true) Connection con, String id, Integer sortFirst) throws SQLException{
523
	public void updateSortFirst(@JdbcConn(true) Connection con, String id, Integer sortFirst) throws SQLException {
497 524
		this.professorDao.updateSortFirst(con, id, sortFirst);
498 525
	}
499
	
526

500 527
	@Post
501 528
	@Path("/authentication")
502
	public void updateAuthentication(@JdbcConn(true) Connection con, String id, Integer authentication, 
503
			Integer authType, Integer authStatus) throws SQLException{
529
	public void updateAuthentication(@JdbcConn(true) Connection con, String id, Integer authentication, Integer authType, Integer authStatus)
530
			throws SQLException {
504 531
		this.professorDao.updateAuthentication(con, id, authentication, authType, authStatus);
505 532
	}
506
	
533

507 534
	@Post
508 535
	@Path("/authType")
509
	public void updateAuthType(@JdbcConn(true) Connection con,String id,Integer authType)throws SQLException{
536
	public void updateAuthType(@JdbcConn(true) Connection con, String id, Integer authType) throws SQLException {
510 537
		this.professorDao.updateAuthType(con, id, authType);
511 538
	}
512
	
539

513 540
	@Post
514 541
	@Path("/authen")
515
	public void updateAuthen(@JdbcConn(true) Connection con,String id,Integer authentication)throws SQLException{
542
	public void updateAuthen(@JdbcConn(true) Connection con, String id, Integer authentication) throws SQLException {
516 543
		this.professorDao.updateAuthentication(con, id, authentication);
517 544
	}
518
	
545

519 546
	@Post
520 547
	@Path("/authStatus")
521
	public void updateAuthStatus(@JdbcConn(true) Connection con, String id, Integer authStatus) throws SQLException{
548
	public void updateAuthStatus(@JdbcConn(true) Connection con, String id, Integer authStatus) throws SQLException {
522 549
		this.professorDao.updateAuthStatus(con, id, authStatus);
523 550
	}
524
	
551

525 552
	@Post
526 553
	@Path("/passOrgAuth")
527
	public void passOrgAuth(@JdbcConn(true) Connection con,String id)throws SQLException{
554
	public void passOrgAuth(@JdbcConn(true) Connection con, String id) throws SQLException {
528 555
		this.professorDao.updateOrgAuth(con, id, "1");
529
		//通过企业认证给用户增加积分
556
		// 通过企业认证给用户增加积分
530 557
		this.growthLogService.authOrg(con, id);
531 558
	}
532
	
559

533 560
	@Post
534 561
	@Path("/removeOrgAuth")
535
	public void removeOrgAuth(@JdbcConn(true) Connection con,String id)throws SQLException{
562
	public void removeOrgAuth(@JdbcConn(true) Connection con, String id) throws SQLException {
536 563
		this.professorDao.updateOrgAuth(con, id, "0");
537 564
	}
538
	
565

539 566
	@Post
540 567
	@Path("/starLevel")
541
	public void updateStarLevel(@JdbcConn(true) Connection con, String id, BigDecimal starLevel) throws SQLException{
568
	public void updateStarLevel(@JdbcConn(true) Connection con, String id, BigDecimal starLevel) throws SQLException {
542 569
		this.professorDao.updateStarLevel(con, id, starLevel);
543 570
	}
544
	
571

545 572
	@Post
546 573
	@Path("/subject")
547
	public void updateSubject(@JdbcConn(true) Connection con,String id,@Nullable String subject) throws SQLException{
574
	public void updateSubject(@JdbcConn(true) Connection con, String id, @Nullable String subject) throws SQLException {
548 575
		this.professorDao.updateSubject(con, id, subject);
576
		Professor p = this.professorDao.query(con, id);
577
		// String subject = p.getSubject();
578
		if (subject == null)
579
			subject = "";
580
		String industry = p.getIndustry();
581
		if (industry == null)
582
			industry = "";
583
		this.keyWordService.refreshProfessor(con, id, KeyWordService.splitKeyWord(subject + "," + industry));
549 584
	}
550
	
585

551 586
	@Post
552 587
	@Path("/industry")
553
	public void updateIndustry(@JdbcConn(true) Connection con,String id,@Nullable String industry) throws SQLException{
588
	public void updateIndustry(@JdbcConn(true) Connection con, String id, @Nullable String industry) throws SQLException {
554 589
		this.professorDao.updateIndustry(con, id, industry);
590
		Professor p = this.professorDao.query(con, id);
591
		String subject = p.getSubject();
592
		if (subject == null)
593
			subject = "";
594
		if (industry == null)
595
			industry = "";
596
		this.keyWordService.refreshProfessor(con, id, KeyWordService.splitKeyWord(subject + "," + industry));
555 597
	}
598

556 599
	@Post
557 600
	@Path("/address")
558
	public void updateAddress(@JdbcConn(true) Connection con, String id,
559
			@Nullable String province,@Nullable String address) throws SQLException{
601
	public void updateAddress(@JdbcConn(true) Connection con, String id, @Nullable String province, @Nullable String address) throws SQLException {
560 602
		this.professorDao.updateProvince(con, id, province);
561 603
		this.professorDao.updateAddress(con, id, address);
562 604
	}
605

563 606
	@Post
564 607
	@Path("/descp")
565
	public void updateDescp(@JdbcConn(true) Connection con,String id,@Nullable String descp) throws SQLException{
608
	public void updateDescp(@JdbcConn(true) Connection con, String id, @Nullable String descp) throws SQLException {
566 609
		this.professorDao.updateDescp(con, id, descp);
567 610
	}
568
	
569 611

570 612
	@Delete
571 613
	@Path("/{id}")
@ -583,20 +625,29 @@ public class ProfessorService {
583 625
		this.watchDao.deleteWatch(con, id);
584 626
		this.resourceDao.deletePro(con, id);
585 627
		this.articleDao.deletePro(con, id);
628
		this.keyWordService.refreshProfessor(con, id, null);
586 629
	}
587
	
630

588 631
	@Get
589 632
	@Path("/pqBaseInfo")
590
	PageQueryResult<EditProfessor> queryEditBaseInfo(@JdbcConn(false) Connection con,@Nullable String key,
591
			@Nullable String subject,@Nullable String industry,@Nullable String address,@DefaultValue("1") Integer authType, 
592
			@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
593
		if(key!=null) {key="%"+key+"%";}
594
		if(subject!=null) {subject ="%"+subject+"%";}
595
		if(null!=industry) {industry="%"+industry+"%";}
596
		if(null!=address) {address="%"+address+"%";}
633
	PageQueryResult<EditProfessor> queryEditBaseInfo(@JdbcConn(false) Connection con, @Nullable String key, @Nullable String subject, @Nullable String industry,
634
			@Nullable String address, @DefaultValue("1") Integer authType, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo)
635
			throws SQLException {
636
		if (key != null) {
637
			key = "%" + key + "%";
638
		}
639
		if (subject != null) {
640
			subject = "%" + subject + "%";
641
		}
642
		if (null != industry) {
643
			industry = "%" + industry + "%";
644
		}
645
		if (null != address) {
646
			address = "%" + address + "%";
647
		}
597 648
		PageQueryResult<EditProfessor> queryResult = this.professorDao.queryEditBaseInfo(con, key, subject, industry, address, authType, pageSize, pageNo);
598 649
		List<EditProfessor> editProfessors = queryResult.getData();
599
		if(!editProfessors.isEmpty()){
650
		if (!editProfessors.isEmpty()) {
600 651
			for (EditProfessor editProfessor : editProfessors) {
601 652
				editProfessor.setHasHeadImage(this.imageService.hasProfessorImage(editProfessor.getId()));
602 653
				editProfessor.setResearchAreas(this.researchAreaDao.query(con, editProfessor.getId()));
@ -605,39 +656,47 @@ public class ProfessorService {
605 656
		}
606 657
		return queryResult;
607 658
	}
608
	
659

609 660
	@Get
610 661
	@Path("/pqUserInfo")
611
	PageQueryResult<UserInfo> queryUserInfo(@JdbcConn(false) Connection con,@Nullable String key,
612
			@Nullable String address,@Nullable String orgName,@Nullable Integer activeState,@Nullable Integer authType, 
613
			@DefaultValue("20") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
614
		if(key!=null) {key="%"+key+"%";}
615
		if(null!=address) {address="%"+address+"%";}
616
		if(orgName!=null) {orgName ="%"+orgName+"%";}
662
	PageQueryResult<UserInfo> queryUserInfo(@JdbcConn(false) Connection con, @Nullable String key, @Nullable String address, @Nullable String orgName,
663
			@Nullable Integer activeState, @Nullable Integer authType, @DefaultValue("20") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
664
		if (key != null) {
665
			key = "%" + key + "%";
666
		}
667
		if (null != address) {
668
			address = "%" + address + "%";
669
		}
670
		if (orgName != null) {
671
			orgName = "%" + orgName + "%";
672
		}
617 673
		return this.professorDao.queryUserInfo(con, key, address, authType, orgName, activeState, pageSize, pageNo);
618 674
	}
619
	
675

620 676
	@Get
621 677
	@Path("/pq")
622
	PageQueryResult<Professor> query(@JdbcConn(false) Connection con,@Nullable String key,
623
			@Nullable String subject,@Nullable String industry,@Nullable String address, 
624
			@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
625
	//	System.out.println("key==["+(key==null?"":key)+"]");
626
	//	System.out.println("subject==["+(subject==null?"":subject)+"]");
627
	//	System.out.println("industry==["+(industry==null?"":industry)+"]");
628
		if(key!=null) key="%"+key+"%";
629
		if(subject!=null) subject ="%"+subject+"%";
630
		if(null!=industry) industry="%"+industry+"%";
631
		if(null!=address) address="%"+address+"%";
678
	PageQueryResult<Professor> query(@JdbcConn(false) Connection con, @Nullable String key, @Nullable String subject, @Nullable String industry,
679
			@Nullable String address, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
680
		// System.out.println("key==["+(key==null?"":key)+"]");
681
		// System.out.println("subject==["+(subject==null?"":subject)+"]");
682
		// System.out.println("industry==["+(industry==null?"":industry)+"]");
683
		if (key != null)
684
			key = "%" + key + "%";
685
		if (subject != null)
686
			subject = "%" + subject + "%";
687
		if (null != industry)
688
			industry = "%" + industry + "%";
689
		if (null != address)
690
			address = "%" + address + "%";
632 691
		return this.professorDao.query(con, key, subject, industry, address, pageSize, pageNo);
633 692
	}
634
	
693

635 694
	@Get
636 695
	@Path("/info/{id}")
637
	public ProfessorInfo qinfo(@JdbcConn(false) Connection con,@PathVar String id) throws SQLException{
696
	public ProfessorInfo qinfo(@JdbcConn(false) Connection con, @PathVar String id) throws SQLException {
638 697
		ProfessorInfo info = this.professorDao.queryInfo(con, id);
639
		if(info!=null){
640
			if(info.getOrgId() != null){
698
		if (info != null) {
699
			if (info.getOrgId() != null) {
641 700
				info.setOrgName(this.orgDao.query(con, info.getOrgId()).getName());
642 701
			}
643 702
			info.setHasHeadImage(this.imageService.hasProfessorImage(id));
@ -648,7 +707,7 @@ public class ProfessorService {
648 707
			info.setPatents(this.patentDao.query(con, id));
649 708
			info.setProjects(this.projectDao.query(con, id));
650 709
			List<EditResearchAreaLog> logs = this.researchAreaLogDao.query(con, id);
651
			if(!logs.isEmpty()){
710
			if (!logs.isEmpty()) {
652 711
				for (EditResearchAreaLog log : logs) {
653 712
					log.setHasHeadImage(this.imageService.hasProfessorImage(log.getOpreteProfessorId()));
654 713
				}
@ -656,7 +715,7 @@ public class ProfessorService {
656 715
			info.setEditResearchAreaLogs(logs);
657 716
			info.setResearchAreas(this.researchAreaDao.query(con, id));
658 717
			List<Resource> resources = this.resourceDao.queryPro(con, id);
659
			if(!resources.isEmpty()){
718
			if (!resources.isEmpty()) {
660 719
				for (Resource resource : resources) {
661 720
					resource.setImages(this.imageDao.queryRes(con, resource.getResourceId()));
662 721
				}
@ -664,29 +723,95 @@ public class ProfessorService {
664 723
			info.setResources(resources);
665 724
		}
666 725
		return info;
667
		
726

668 727
	}
728

669 729
	@Get
670 730
	@Path("/byShareId")
671
	public Professor query(@JdbcConn Connection con,long id)throws SQLException{
672
		return this.professorDao.query(con,id);
731
	public Professor query(@JdbcConn Connection con, long id) throws SQLException {
732
		return this.professorDao.query(con, id);
733
	}
734

735
	/**
736
	 * 增加用户浏览量
737
	 * @param con
738
	 * @param id
739
	 * @throws SQLException
740
	 */
741
	@Post
742
	@Path("/incPageViews")
743
	public void incPageViews(@JdbcConn(true) Connection con, String id) throws SQLException {
744
		this.professorDao.incPageViews(con, id);
745
	}
746
	
747
	@Get
748
	@Path("/ralateProfessors")
749
	public List<Professor> ralateArticles(@JdbcConn Connection con,String professorId,@DefaultValue("5") int rows)throws SQLException{
750
		String[] ids = this.professorDao.queryProfessorIdWithSameKeyWord(con, professorId, rows);
751
		if(ids!=null){
752
			 List<Professor> ret = this.professorDao.query(con,ids);
753
			 return ret;
754
		}
755
		return Collections.<Professor>emptyList();
756
	}
757
	
758
	@Get
759
	@Path("/coadjutant")
760
	public List<Map<String,Object>> queryCoadjutant(@JdbcConn Connection con,String id,@DefaultValue("5") int rows)throws SQLException{
761
		PreparedStatement ps = con.prepareStatement("SELECT professor_id,SUM (patent_count) patent_count,	SUM (paper_count) paper_count, "+
762
	    "SUM (tc) tc FROM ((SELECT professor_id,COUNT (1) patent_count,0 paper_count,COUNT (1) tc FROM patent_author WHERE patent_id IN ("+
763
		"SELECT DISTINCT patent_id FROM patent_author WHERE professor_id = ? ) AND professor_id <> ? AND professor_id <> '################################' "+
764
		"GROUP BY professor_id) UNION ALL (SELECT professor_id,0 patent_count,COUNT (1) paper_count,COUNT (1) tc	FROM paper_author WHERE paper_id IN (	SELECT DISTINCT "+
765
		"paper_id FROM paper_author WHERE professor_id = ? ) AND professor_id <>?  AND professor_id <> '################################' GROUP BY professor_id ) "
766
		+") _T_ GROUP BY professor_id ORDER BY tc DESC LIMIT ?");
767
		try{
768
			ps.setString(1,id);
769
			ps.setString(2,id);
770
			ps.setString(3,id);
771
			ps.setString(4,id);
772
			ps.setInt(5,rows);
773
			ResultSet rs = ps.executeQuery();
774
			try{
775
				List<Map<String,Object>> ret = new ArrayList<Map<String,Object>>();
776
				while(rs.next()){
777
					Map<String,Object> row = new HashMap<String,Object>();
778
					ret.add(row);
779
					row.put("professorId",rs.getString(1));
780
					row.put("patentCount",rs.getInt(2));
781
					row.put("paperCount",rs.getInt(3));
782
				}
783
				return ret;
784
			}finally{
785
				JdbcUtil.close(rs);
786
			}
787
		}finally{
788
			JdbcUtil.close(ps);
789
		}
673 790
	}
674 791
	
675
	public static void main(String[] args)throws Exception{
676
//		Connection con = DriverManager.getConnection("jdbc:postgresql://121.42.53.174:5432/ekexiu", "postgres",  "postgres");
677
//		try{
678
//		ProfessorService service = new ProfessorService();
679
//		ProfessorDao dao = new ProfessorDaoExtend();
680
//		service.setProfessorDao(dao);
681
//		PageQueryResult<Professor> result =service.query(con,"鏉?, "鏉愭枡", "閲戝睘", 10, 2);
682
//		System.out.println(result.getTotal());
683
//		for(Professor p:result.getData()){
684
//			System.out.println("======");
685
//			JsonService.toJson(p,System.out);
686
//		}
687
//		}finally{
688
//			con.close();
689
//		}
792
//	
793
//	
794
//	@Get
795
//	@Path("/articleRef")
796

797
	public static void main(String[] args) throws Exception {
798
		// Connection con =
799
		// DriverManager.getConnection("jdbc:postgresql://121.42.53.174:5432/ekexiu",
800
		// "postgres", "postgres");
801
		// try{
802
		// ProfessorService service = new ProfessorService();
803
		// ProfessorDao dao = new ProfessorDaoExtend();
804
		// service.setProfessorDao(dao);
805
		// PageQueryResult<Professor> result =service.query(con,"鏉?, "鏉愭枡",
806
		// "閲戝睘", 10, 2);
807
		// System.out.println(result.getTotal());
808
		// for(Professor p:result.getData()){
809
		// System.out.println("======");
810
		// JsonService.toJson(p,System.out);
811
		// }
812
		// }finally{
813
		// con.close();
814
		// }
690 815
		System.out.println(URLEncoder.encode("输出中文", "UTF-8"));
691 816
	}
692 817
}

+ 125 - 72
src/main/java/com/ekexiu/portal/service/ResourceService.java

@ -4,7 +4,7 @@ import java.io.IOException;
4 4
import java.sql.Connection;
5 5
import java.sql.SQLException;
6 6
import java.text.SimpleDateFormat;
7
import java.util.ArrayList;
7
import java.util.Collections;
8 8
import java.util.Date;
9 9
import java.util.List;
10 10

@ -69,6 +69,20 @@ public class ResourceService {
69 69
	private OrgDao orgDao;
70 70
	@Autowrie
71 71
	private ResourceTmpLogDao resourceTmpLogDao;
72
	
73
	
74
	@Autowrie
75
	private KeyWordService keyWordService;
76
	
77
	
78

79
	public KeyWordService getKeyWordService() {
80
		return keyWordService;
81
	}
82

83
	public void setKeyWordService(KeyWordService keyWordService) {
84
		this.keyWordService = keyWordService;
85
	}
72 86

73 87
	public String getTimeFormat() {
74 88
		return timeFormat;
@ -199,6 +213,7 @@ public class ResourceService {
199 213
		resource.setResourceId(resourceId);
200 214
		this.resourceDao.insert(con, resource);
201 215
		//this.growthLogService.addResource(con, resource.getProfessorId());
216
		this.keyWordService.refreshResource(con,resourceId, KeyWordService.splitKeyWord(resource.getSubject()));
202 217
		return resourceId;
203 218
	}
204 219
	
@ -223,6 +238,7 @@ public class ResourceService {
223 238
			throw new JfwBaseException(-1, "bad parameter:ownerId");
224 239
		}
225 240
		this.resourceDao.insert(con, resource);
241
		this.keyWordService.refreshResource(con,resourceId,KeyWordService.splitKeyWord(resource.getSubject()));
226 242
		this.resourceTmpLogDao.insert(con, log);
227 243
		if(imgSrc != null){
228 244
			Image image = new Image();
@ -260,6 +276,7 @@ public class ResourceService {
260 276
			resource.setPublishTime(this.publishTime());
261 277
			resource.setResourceType("1");
262 278
			this.resourceDao.insert(con, resource);
279
			this.keyWordService.refreshResource(con,resourceId,KeyWordService.splitKeyWord(resource.getSubject()));
263 280
			//this.growthLogService.addResource(con, resource.getProfessorId());
264 281
			return resourceId;
265 282
		}else if(resource.getResourceId().trim().length() == 32){
@ -285,12 +302,23 @@ public class ResourceService {
285 302
			}
286 303
			this.resourceDao.update(con, resource);
287 304
			this.resourceDao.updatePublishTime(con, resource.getResourceId(), "1", this.publishTime());
305
			this.keyWordService.refreshResource(con,resource.getResourceId(),KeyWordService.splitKeyWord(resource.getSubject()));
288 306
			return resource.getResourceId();
289 307
		}else{
290 308
			throw new JfwBaseException(-1, "bad parameter:resourceId");
291 309
		}
292 310
	}
293
	
311
	/**
312
	 * 保存划稿
313
	 * @param con
314
	 * @param resource
315
	 * @param fns
316
	 * @param imageIds
317
	 * @return
318
	 * @throws SQLException
319
	 * @throws IOException
320
	 * @throws JfwBaseException
321
	 */
294 322
	@Post
295 323
	@Path("/draft")
296 324
	public String draft(@JdbcConn(true) Connection con, Resource resource, @Nullable String[] fns, @Nullable String[] imageIds) 
@ -305,6 +333,7 @@ public class ResourceService {
305 333
			resource.setPageViews(0);
306 334
			resource.setResourceType("1");
307 335
			this.resourceDao.insert(con, resource);
336
			this.keyWordService.refreshResource(con,resourceId,null);
308 337
			return resourceId;
309 338
		}else if(resource.getResourceId().trim().length() == 32){
310 339
			int imageLength = 0;
@ -329,6 +358,7 @@ public class ResourceService {
329 358
			}
330 359
			this.resourceDao.update(con, resource);
331 360
			this.resourceDao.updateStatus(con, resource.getResourceId(), "0");
361
			this.keyWordService.refreshResource(con,resource.getResourceId(),null);
332 362
			return resource.getResourceId();
333 363
		}else{
334 364
			throw new JfwBaseException(-1, "bad parameter:resourceId");
@ -349,6 +379,7 @@ public class ResourceService {
349 379
			resource.setPageViews(0);
350 380
			resource.setResourceType("1");
351 381
			this.resourceDao.insert(con, resource);
382
			this.keyWordService.refreshResource(con,resourceId,null);
352 383
			return resourceId;
353 384
		}else if(resource.getResourceId().trim().length() == 32){
354 385
			int imageLength = 0;
@ -373,6 +404,7 @@ public class ResourceService {
373 404
			}
374 405
			this.resourceDao.update(con, resource);
375 406
			this.resourceDao.updatePublishTime(con, resource.getResourceId(), "2", resource.getPublishTime());
407
			this.keyWordService.refreshResource(con,resource.getResourceId(),null);
376 408
			return resource.getResourceId();
377 409
		}else{
378 410
			throw new JfwBaseException(-1, "bad parameter:resourceId");
@ -394,6 +426,7 @@ public class ResourceService {
394 426
			resource.setPublishTime(this.publishTime());
395 427
			resource.setResourceType("2");
396 428
			this.resourceDao.insert(con, resource);
429
			this.keyWordService.refreshResource(con,resourceId,KeyWordService.splitKeyWord(resource.getSubject()));
397 430
			if(professorIds != null){
398 431
				for (String professorId : professorIds) {
399 432
					OrgResStaff orgResStaff = new OrgResStaff();
@ -426,6 +459,7 @@ public class ResourceService {
426 459
			}
427 460
			this.resourceDao.update(con, resource);
428 461
			this.resourceDao.updatePublishTime(con, resource.getResourceId(), "1", this.publishTime());
462
			this.keyWordService.refreshResource(con,resource.getResourceId(),null);
429 463
			this.orgResStaffDao.delete(con, resource.getResourceId());
430 464
			if(professorIds != null){
431 465
				for (String professorId : professorIds) {
@ -455,6 +489,7 @@ public class ResourceService {
455 489
			resource.setPageViews(0);
456 490
			resource.setResourceType("2");
457 491
			this.resourceDao.insert(con, resource);
492
			this.keyWordService.refreshResource(con,resourceId,null);
458 493
			if(professorIds != null){
459 494
				for (String professorId : professorIds) {
460 495
					OrgResStaff orgResStaff = new OrgResStaff();
@ -487,6 +522,7 @@ public class ResourceService {
487 522
			}
488 523
			this.resourceDao.update(con, resource);
489 524
			this.resourceDao.updateStatus(con, resource.getResourceId(), "0");
525
			this.keyWordService.refreshResource(con,resource.getResourceId(),null);
490 526
			this.orgResStaffDao.delete(con, resource.getResourceId());
491 527
			if(professorIds != null){
492 528
				for (String professorId : professorIds) {
@ -507,6 +543,7 @@ public class ResourceService {
507 543
	public void deleteRes(@JdbcConn(true) Connection con, String resourceId) throws SQLException{
508 544
		//修改资源状态为删除
509 545
		this.resourceDao.updateStatus(con, resourceId, "3");
546
		this.keyWordService.refreshResource(con,resourceId,null);
510 547
	}
511 548
	
512 549
	@Post
@ -519,6 +556,7 @@ public class ResourceService {
519 556
		}
520 557
		resource.setResourceId(resourceId);
521 558
		this.resourceDao.insert(con, resource);
559
		this.keyWordService.refreshResource(con,resourceId,KeyWordService.splitKeyWord(resource.getSubject()));
522 560
		//this.growthLogService.addResource(con, resource.getProfessorId());
523 561
		return resourceId;
524 562
	}
@ -531,6 +569,7 @@ public class ResourceService {
531 569
			this.imagesService.insert(con, resource.getResourceId(), fn);
532 570
		}
533 571
		this.resourceDao.update(con, resource);
572
		this.keyWordService.refreshResource(con,resource.getResourceId(),KeyWordService.splitKeyWord(resource.getSubject()));
534 573
	}
535 574
	
536 575
	@Post
@ -608,76 +647,76 @@ public class ResourceService {
608 647
		return queryResult;
609 648
	}
610 649
	
611
	@Get
612
	@Path("/ralateRes")
613
	public List<Resource> queryLimit(@JdbcConn Connection con,@Nullable String[] keys,String resourceId,
614
			String professorId,@DefaultValue("10") int rows)throws SQLException{
615
		List<Resource> resources = new ArrayList<Resource>();
616
		if(keys != null){
617
			resources = this.resourceDao.queryLimit(con, keys, resourceId, rows);
618
		}
619
		if(resources.isEmpty()){
620
			resources = this.resourceDao.queryByProId(con, professorId, resourceId, rows);
621
			if(resources.isEmpty()){
622
				resources = this.resourceDao.queryByProId(con, null, resourceId, rows);
623
			}
624
		}
625
		if(!resources.isEmpty()){
626
			for (Resource resource : resources) {
627
				resource.setImages(this.imagesService.queryRes(con, resource.getResourceId()));
628
				if(resource.getProfessorId() != null){
629
					EditProfessor professor = this.professorDao.queryBaseInfo(con, resource.getProfessorId());
630
					if(professor != null){
631
						professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
632
					}
633
					resource.setEditProfessor(professor);
634
				}else if(resource.getOrgId() != null){
635
					EditOrganization organization = this.orgDao.queryEditOrg(con, resource.getOrgId());
636
					if(organization != null){
637
						organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
638
					}
639
					resource.setOrganization(organization);
640
				}
641
			}
642
		}
643
		return resources;
644
	}
645
	
646
	@Get
647
	@Path("/orgRalateRes")
648
	public List<Resource> queryOrgRalateRes(@JdbcConn Connection con,@Nullable String[] keys,String resourceId,
649
			String orgId,@DefaultValue("10") int rows)throws SQLException{
650
		List<Resource> resources = new ArrayList<Resource>();
651
		if(keys != null){
652
			resources = this.resourceDao.queryLimit(con, keys, resourceId, rows);
653
		}
654
		if(resources.isEmpty()){
655
			resources = this.resourceDao.queryByOrgId(con, orgId, resourceId, rows);
656
			if(resources.isEmpty()){
657
				resources = this.resourceDao.queryByOrgId(con, null, resourceId, rows);
658
			}
659
		}
660
		if(!resources.isEmpty()){
661
			for (Resource resource : resources) {
662
				resource.setImages(this.imagesService.queryRes(con, resource.getResourceId()));
663
				if(resource.getProfessorId() != null){
664
					EditProfessor professor = this.professorDao.queryBaseInfo(con, resource.getProfessorId());
665
					if(professor != null){
666
						professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
667
					}
668
					resource.setEditProfessor(professor);
669
				}else if(resource.getOrgId() != null){
670
					EditOrganization organization = this.orgDao.queryEditOrg(con, resource.getOrgId());
671
					if(organization != null){
672
						organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
673
					}
674
					resource.setOrganization(organization);
675
				}
676
			}
677
		}
678
		return resources;
679
	}
680
	
650
//	@Get
651
//	@Path("/ralateRes")
652
//	public List<Resource> queryLimit(@JdbcConn Connection con,@Nullable String[] keys,String resourceId,
653
//			String professorId,@DefaultValue("10") int rows)throws SQLException{
654
//		List<Resource> resources = new ArrayList<Resource>();
655
//		if(keys != null){
656
//			resources = this.resourceDao.queryLimit(con, keys, resourceId, rows);
657
//		}
658
//		if(resources.isEmpty()){
659
//			resources = this.resourceDao.queryByProId(con, professorId, resourceId, rows);
660
//			if(resources.isEmpty()){
661
//				resources = this.resourceDao.queryByProId(con, null, resourceId, rows);
662
//			}
663
//		}
664
//		if(!resources.isEmpty()){
665
//			for (Resource resource : resources) {
666
//				resource.setImages(this.imagesService.queryRes(con, resource.getResourceId()));
667
//				if(resource.getProfessorId() != null){
668
//					EditProfessor professor = this.professorDao.queryBaseInfo(con, resource.getProfessorId());
669
//					if(professor != null){
670
//						professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
671
//					}
672
//					resource.setEditProfessor(professor);
673
//				}else if(resource.getOrgId() != null){
674
//					EditOrganization organization = this.orgDao.queryEditOrg(con, resource.getOrgId());
675
//					if(organization != null){
676
//						organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
677
//					}
678
//					resource.setOrganization(organization);
679
//				}
680
//			}
681
//		}
682
//		return resources;
683
//	}
684
//	
685
//	@Get
686
//	@Path("/orgRalateRes")
687
//	public List<Resource> queryOrgRalateRes(@JdbcConn Connection con,@Nullable String[] keys,String resourceId,
688
//			String orgId,@DefaultValue("10") int rows)throws SQLException{
689
//		List<Resource> resources = new ArrayList<Resource>();
690
//		if(keys != null){
691
//			resources = this.resourceDao.queryLimit(con, keys, resourceId, rows);
692
//		}
693
//		if(resources.isEmpty()){
694
//			resources = this.resourceDao.queryByOrgId(con, orgId, resourceId, rows);
695
//			if(resources.isEmpty()){
696
//				resources = this.resourceDao.queryByOrgId(con, null, resourceId, rows);
697
//			}
698
//		}
699
//		if(!resources.isEmpty()){
700
//			for (Resource resource : resources) {
701
//				resource.setImages(this.imagesService.queryRes(con, resource.getResourceId()));
702
//				if(resource.getProfessorId() != null){
703
//					EditProfessor professor = this.professorDao.queryBaseInfo(con, resource.getProfessorId());
704
//					if(professor != null){
705
//						professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
706
//					}
707
//					resource.setEditProfessor(professor);
708
//				}else if(resource.getOrgId() != null){
709
//					EditOrganization organization = this.orgDao.queryEditOrg(con, resource.getOrgId());
710
//					if(organization != null){
711
//						organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
712
//					}
713
//					resource.setOrganization(organization);
714
//				}
715
//			}
716
//		}
717
//		return resources;
718
//	}
719
//	
681 720
	@Get
682 721
	@Path("/articles")
683 722
	public List<ArticleRes> queryArticles(@JdbcConn Connection con, String resourceId, @DefaultValue("5") int rows) throws SQLException{
@ -952,4 +991,18 @@ public class ResourceService {
952 991
	public Resource query(@JdbcConn Connection con,long id)throws SQLException{
953 992
		return this.resourceDao.query(con,id);
954 993
	}
994
	
995
	@Get
996
	@Path("/ralateResources")
997
	public List<Resource> ralateResources(@JdbcConn Connection con,String resourceId,@DefaultValue("5") int rows)throws SQLException{
998
		String[] ids = this.resourceDao.queryResourceIdWithSameKeyWord(con, resourceId, rows);
999
		if(ids!=null){
1000
			List<Resource> ret = this.resourceDao.query(con,ids);
1001
			for(Resource res:ret){
1002
				res.setImages(this.imageDao.queryRes(con, res.getResourceId()));
1003
			}
1004
			return ret;
1005
		}
1006
		return Collections.<Resource>emptyList();
1007
	}
955 1008
}

+ 65 - 0
src/main/resources/database.sql

@ -1518,7 +1518,72 @@ ALTER TABLE  organization ADD COLUMN linkman text;
1518 1518
COMMENT ON COLUMN  organization.linkman IS '联系人';
1519 1519

1520 1520

1521
--begin v1.9.1
1522
ALTER TABLE professor ADD COLUMN page_views  int8 default 0 not null;
1523
COMMENT ON COLUMN professor.page_views IS '浏览量';
1524

1525
CREATE TABLE art_key_word (id char(32) NOT NULL,kw text not null);
1526
COMMENT ON TABLE art_key_word IS '文章关键字';
1527
COMMENT ON COLUMN art_key_word.id IS '文章ID';
1528
COMMENT ON COLUMN art_key_word.kw IS '关键字';
1529
CREATE TABLE res_key_word (id char(32) NOT NULL,kw text not null);
1530
COMMENT ON TABLE res_key_word IS '资源关键字';
1531
COMMENT ON COLUMN res_key_word.id IS '资源ID';
1532
COMMENT ON COLUMN res_key_word.kw IS '关键字';
1533
CREATE TABLE pro_key_word (id char(32) NOT NULL,kw text not null);
1534
COMMENT ON TABLE pro_key_word IS '用户关键字';
1535
COMMENT ON COLUMN pro_key_word.id IS '用户ID';
1536
COMMENT ON COLUMN pro_key_word.kw IS '关键字';
1537
CREATE TABLE org_key_word (id char(32) NOT NULL,kw text not null);
1538
COMMENT ON TABLE org_key_word IS '企业关键字';
1539
COMMENT ON COLUMN org_key_word.id IS '企业ID';
1540
COMMENT ON COLUMN org_key_word.kw IS '关键字';
1541
CREATE TABLE pap_key_word (id char(32) NOT NULL,kw text not null);
1542
COMMENT ON TABLE pap_key_word IS '论文关键字';
1543
COMMENT ON COLUMN pap_key_word.id IS '论文ID';
1544
COMMENT ON COLUMN pap_key_word.kw IS '关键字';
1545
CREATE TABLE pat_key_word (id char(32) NOT NULL,kw text not null);
1546
COMMENT ON TABLE pat_key_word IS '专利关键字';
1547
COMMENT ON COLUMN pat_key_word.id IS '专利ID';
1548
COMMENT ON COLUMN pat_key_word.kw IS '关键字';
1549

1550
CREATE TABLE ARTICLE_ORG (ARTICLE_ID CHAR(32) NOT NULL,ORG_ID CHAR(32) NOT NULL,CREATE_TIME CHAR(14) NOT NULL);
1551
ALTER TABLE ARTICLE_ORG ADD UNIQUE (ARTICLE_ID,ORG_ID);
1552
COMMENT ON COLUMN ARTICLE_ORG.ARTICLE_ID IS '文章ID';
1553
COMMENT ON COLUMN ARTICLE_ORG.ORG_ID IS '企业ID';
1554

1555
alter table leave_word add column  category char(1) not null default '1';
1556
comment on column leave_word.category is '留言分类  1: 文章  2:论文   3:专利';
1557

1558
ALTER TABLE leave_word RENAME article_id TO obj_id;
1559
comment on column leave_word.obj_id is '留言对象ID';
1560

1561
CREATE TABLE paper_agree (
1562
	op_id char(32) NOT NULL,
1563
	paper_id char(32) NOT NULL,
1564
	create_time char(14) NOT NULL
1565
);
1566
COMMENT ON TABLE paper_agree IS '论文点赞表';
1567
COMMENT ON COLUMN paper_agree.op_id IS '点赞人的ID';
1568
COMMENT ON COLUMN paper_agree.paper_id IS '被点赞的论文ID';
1569
COMMENT ON COLUMN paper_agree.create_time IS '点赞时间';
1570

1571
CREATE TABLE patent_agree (
1572
	op_id char(32) NOT NULL,
1573
	patent_id char(32) NOT NULL,
1574
	create_time char(14) NOT NULL
1575
);
1576
COMMENT ON TABLE patent_agree IS '专利点赞表';
1577
COMMENT ON COLUMN patent_agree.op_id IS '点赞人的ID';
1578
COMMENT ON COLUMN patent_agree.patent_id IS '被点赞的专利ID';
1579
COMMENT ON COLUMN patent_agree.create_time IS '点赞时间';
1580

1581
ALTER TABLE patent_agree ADD PRIMARY KEY (op_id,patent_id);
1582
ALTER TABLE paper_agree ADD PRIMARY KEY (op_id,paper_id);
1521 1583

1584
ALTER TABLE organization ALTER COLUMN is_join SET DEFAULT '0';
1585
UPDATE organization set is_join='0' WHERE is_join is null;
1586
ALTER TABLE organization ALTER COLUMN is_join SET NOT NULL;
1522 1587

1523 1588

1524 1589


+ 1 - 1
src/main/resources/project-test-dev.properties

@ -149,7 +149,7 @@ com_ekexiu_portal_service_ArticleService.tmpPath::java.io.File=/kexiu/www/html1/
149 149
com_ekexiu_portal_service_ArticleService.articlePath::java.io.File=/kexiu/webdata1/data/article
150 150
com_ekexiu_portal_service_ArticleService.dateFormat::java.lang.String=yyyyMMdd
151 151
#科研文章图片尺寸
152
com_ekexiu_portal_service_ArticleService.artMaxLen::int=640
152
com_ekexiu_portal_service_ArticleService.artMaxLen::int=200
153 153
#资源分享图片尺寸
154 154
com_ekexiu_portal_service_ImagesService.resImageMaxLen::int=240
155 155
#认证图片保存目录

+ 1 - 1
src/main/resources/project-test.properties

@ -149,7 +149,7 @@ com_ekexiu_portal_service_ArticleService.tmpPath::java.io.File=/kexiu/www/html/i
149 149
com_ekexiu_portal_service_ArticleService.articlePath::java.io.File=/kexiu/webdata/data/article
150 150
com_ekexiu_portal_service_ArticleService.dateFormat::java.lang.String=yyyyMMdd
151 151
#科研文章图片尺寸
152
com_ekexiu_portal_service_ArticleService.artMaxLen::int=640
152
com_ekexiu_portal_service_ArticleService.artMaxLen::int=200
153 153
#资源分享图片尺寸
154 154
com_ekexiu_portal_service_ImagesService.resImageMaxLen::int=240
155 155
#认证图片保存目录

+ 1 - 1
src/main/resources/project.properties

@ -149,7 +149,7 @@ com_ekexiu_portal_service_ArticleService.tmpPath::java.io.File=/kexiu/www/html/i
149 149
com_ekexiu_portal_service_ArticleService.articlePath::java.io.File=/kexiu/webdata/data/article
150 150
com_ekexiu_portal_service_ArticleService.dateFormat::java.lang.String=yyyyMMdd
151 151
#科研文章图片尺寸
152
com_ekexiu_portal_service_ArticleService.artMaxLen::int=640
152
com_ekexiu_portal_service_ArticleService.artMaxLen::int=200
153 153
#资源分享图片尺寸
154 154
com_ekexiu_portal_service_ImagesService.resImageMaxLen::int=240
155 155
#认证图片保存目录