jiapeng 7 anni fa
parent
commit
8af552024b

+ 108 - 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,125 @@ 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
	}
393 321
	
322
	public abstract List<Article> query(Connection con,@In String[] articleId) throws SQLException;
323

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

+ 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)

+ 220 - 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,6 +413,14 @@ 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)
@ -234,4 +433,25 @@ public abstract class OrgDao {
234 433
	@Or
235 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;
236 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
	}
237 457
}

+ 35 - 10
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,42 @@ 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;
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
	}
74 99

75 100
}

+ 35 - 10
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,27 +30,27 @@ 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 55
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "((A.PROFESSOR_ID=?)  OR  (A.PROFESSOR_ID='################################'))" }) String id,
53 56
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "P.NAME LIKE ?" }) String name, int pageSize, int pageNo) throws SQLException;
@ -55,19 +58,41 @@ public interface PpatentDao {
55 58
	@From(Ppatent.class)
56 59
	@UpdateWith
57 60
	@SetSentence("PAGE_VIEWS = PAGE_VIEWS + 1")
58
	public abstract int incPageViews(Connection con,String id)throws SQLException;
61
    public abstract int incPageViews(Connection con,String id)throws SQLException;
59 62
	
60 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;
66
	public abstract PageQueryResult<Ppatent> 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<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) throws SQLException;
69 72

70 73
	@SelectOne
71 74
	@Nullable
72
	Ppatent query(Connection con,long shareId)throws SQLException;
75
	public abstract Ppatent query(Connection con,long shareId)throws SQLException;
76
	
77
	public String[] queryPatentIdWithSameKeyWord(Connection con,String id,int rows)throws SQLException{
78
		List<String> ret = new ArrayList<String>();
79
		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 ?";
80
		PreparedStatement ps = con.prepareStatement(sql);
81
		try{
82
			ps.setString(1, id);
83
			ps.setString(2, id);
84
			ps.setInt(3, rows);
85
			ResultSet rs = ps.executeQuery();
86
			try{
87
				while(rs.next()){
88
					ret.add(rs.getString(1));
89
				}
90
			}finally{
91
				try{rs.close();}catch(Exception e1){}
92
			}
93
		}finally{
94
			try{ps.close();}catch(Exception e2){}
95
		}
96
		return ret.isEmpty()?null:ret.toArray(new String[ret.size()]);		
97
	}
73 98
}

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

@ -27,6 +27,7 @@ import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
27 27
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
28 28
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
29 29
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
30
import org.jfw.apt.orm.annotation.dao.param.In;
30 31
import org.jfw.apt.orm.annotation.dao.param.LessThan;
31 32
import org.jfw.apt.orm.annotation.dao.param.Set;
32 33
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
@ -1952,5 +1953,27 @@ public abstract class ProfessorDao {
1952 1953
			}
1953 1954
		}
1954 1955
	}
1955
	
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; 
1956 1979
}

+ 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
}

+ 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
}

+ 29 - 24
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

@ -829,30 +829,35 @@ public class ArticleService {
829 829
	@Path("/ralateArticles")
830 830
	public List<Article> ralateArticles(@JdbcConn Connection con,@Nullable String[] keys,@Nullable String professorId,
831 831
			@Nullable String orgId,String articleId,@DefaultValue("10") int rows)throws SQLException{
832
		List<Article> articles = new ArrayList<Article>();
833
		if(keys != null){
834
			articles = this.articleDao.queryLimit(con, keys, articleId, rows);
832
		String[] ids = this.articleDao.queryArticleIdWithSameKeyWord(con, articleId, rows);
833
		if(ids!=null){
834
			return this.articleDao.query(con,ids);
835 835
		}
836
		if(articles.isEmpty()){
837
			articles = this.articleDao.queryByAuthor(con, professorId, orgId, articleId, rows);
838
			if(articles.isEmpty()){
839
				articles = this.articleDao.queryByPageViews(con, articleId, rows);
840
			}
841
		}
842
		return articles;
843
	}
844
	
845
	@Post
846
	@Path("/delete")
847
	public void delete(@JdbcConn(true) Connection con, String articleId) throws SQLException{
848
		this.articleDao.delete(con, articleId);
849
		this.leaveWordDao.deleteArticle(con, articleId);
850
		this.articleAgreeDao.delete(con, articleId);
851
		this.watchDao.deleteWatch(con, articleId);
852
		this.articleOrgDao.delete(con, articleId);
853
		this.articleProDao.delete(con, articleId);
854
		this.articleProDao.delete(con, articleId);
855
	}
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, articleId, rows);
843
//			if(articles.isEmpty()){
844
//				articles = this.articleDao.queryByPageViews(con, articleId, rows);
845
//			}
846
//		}
847
//		return articles;
848
	}
849
	
850
//	@Post
851
//	@Path("/delete")
852
//	public void delete(@JdbcConn(true) Connection con, String articleId) throws SQLException{
853
//		this.articleDao.delete(con, articleId);
854
//		this.leaveWordDao.deleteArticle(con, articleId,LeaveWordService.ARTICLE);
855
//		this.articleAgreeDao.delete(con, articleId);
856
//		this.watchDao.deleteWatch(con, articleId);
857
//		this.articleOrgDao.delete(con, articleId);
858
//		this.articleProDao.delete(con, articleId);
859
//		this.articleProDao.delete(con, articleId);
860
//	}
856 861
	
857 862
	@Path("/byShareId")
858 863
	@Get

+ 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
}

+ 33 - 3
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")
@ -219,9 +221,24 @@ public class OrgService {
219 221
	
220 222
	@Get
221 223
	@Path("/find/pq")
222
	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
223 226
	{
224
		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
		}
225 242
		for (EditOrganization organization : pqr.getData()) {
226 243
			organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
227 244
		}
@ -245,6 +262,19 @@ public class OrgService {
245 262
			organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
246 263
		}
247 264
		return ret;
248
		
265
	}
266
	
267
	@Get
268
	@Path("/ralateOrgs")
269
	public List<EditOrganization> ralateArticles(@JdbcConn Connection con,String orgId,@DefaultValue("10") 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();
249 279
	}
250 280
}

+ 11 - 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;
@ -17,6 +18,7 @@ import com.ekexiu.portal.dao.PaperAuthorDao;
17 18
import com.ekexiu.portal.dao.PpaperDao;
18 19
import com.ekexiu.portal.po.PaperAuthor;
19 20
import com.ekexiu.portal.po.Ppaper;
21
import com.ekexiu.portal.po.Resource;
20 22
import com.ekexiu.portal.pojo.AssedPaper;
21 23

22 24
@Path("/ppaper")
@ -157,4 +159,13 @@ public class PpaperService {
157 159
	public Ppaper query(@JdbcConn Connection con,long id) throws SQLException{
158 160
		return this.ppaperDao.query(con,id);
159 161
	}
162
	@Get
163
	@Path("/ralatePapers")
164
	public List<Ppaper> ralatePapers(@JdbcConn Connection con,String paperId,@DefaultValue("10") int rows)throws SQLException{
165
		String[] ids = this.ppaperDao.queryPaperIdWithSameKeyWord(con, paperId, rows);
166
		if(ids!=null){
167
			return this.ppaperDao.query(con,ids);
168
		}
169
		return Collections.<Ppaper>emptyList();
170
	}
160 171
}

+ 11 - 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;
@ -16,6 +17,7 @@ import org.jfw.util.PageQueryResult;
16 17
import com.ekexiu.portal.dao.PatentAuthorDao;
17 18
import com.ekexiu.portal.dao.PpatentDao;
18 19
import com.ekexiu.portal.po.PatentAuthor;
20
import com.ekexiu.portal.po.Ppaper;
19 21
import com.ekexiu.portal.po.Ppatent;
20 22
import com.ekexiu.portal.pojo.AssedPatent;
21 23

@ -152,4 +154,13 @@ public class PpatentServcie {
152 154
	public Ppatent query(@JdbcConn Connection con,long id)throws SQLException{
153 155
		return this.ppatentDao.query(con,id);
154 156
	}
157
	@Get
158
	@Path("/ralatePatent")
159
	public List<Ppatent> ralatePatents(@JdbcConn Connection con,String patentId,@DefaultValue("10") int rows)throws SQLException{
160
		String[] ids = this.ppatentDao.queryPatentIdWithSameKeyWord(con, patentId, rows);
161
		if(ids!=null){
162
			return this.ppatentDao.query(con,ids);
163
		}
164
		return Collections.<Ppatent>emptyList();
165
	}
155 166
}

+ 13 - 0
src/main/java/com/ekexiu/portal/service/ProfessorService.java

@ -6,6 +6,7 @@ import java.net.URLEncoder;
6 6
import java.sql.Connection;
7 7
import java.sql.SQLException;
8 8
import java.text.DecimalFormat;
9
import java.util.Collections;
9 10
import java.util.List;
10 11

11 12
import org.jfw.apt.annotation.Autowrie;
@ -38,6 +39,7 @@ import com.ekexiu.portal.dao.ResearchAreaLogDao;
38 39
import com.ekexiu.portal.dao.ResourceDao;
39 40
import com.ekexiu.portal.dao.UserDao;
40 41
import com.ekexiu.portal.dao.WatchDao;
42
import com.ekexiu.portal.po.Article;
41 43
import com.ekexiu.portal.po.Professor;
42 44
import com.ekexiu.portal.po.Resource;
43 45
import com.ekexiu.portal.po.User;
@ -736,6 +738,17 @@ public class ProfessorService {
736 738
	public void incPageViews(@JdbcConn(true) Connection con, String id) throws SQLException {
737 739
		this.professorDao.incPageViews(con, id);
738 740
	}
741
	
742
	@Get
743
	@Path("/ralateProfessors")
744
	public List<Professor> ralateArticles(@JdbcConn Connection con,String professorId,@DefaultValue("10") int rows)throws SQLException{
745
		String[] ids = this.professorDao.queryProfessorIdWithSameKeyWord(con, professorId, rows);
746
		if(ids!=null){
747
			return this.professorDao.query(con,ids);
748
		}
749
		return Collections.<Professor>emptyList();
750
	}
751
	
739 752

740 753
	public static void main(String[] args) throws Exception {
741 754
		// Connection con =

+ 81 - 70
src/main/java/com/ekexiu/portal/service/ResourceService.java

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

@ -647,76 +648,76 @@ public class ResourceService {
647 648
		return queryResult;
648 649
	}
649 650
	
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
	
651
//	@Get
652
//	@Path("/ralateRes")
653
//	public List<Resource> queryLimit(@JdbcConn Connection con,@Nullable String[] keys,String resourceId,
654
//			String professorId,@DefaultValue("10") int rows)throws SQLException{
655
//		List<Resource> resources = new ArrayList<Resource>();
656
//		if(keys != null){
657
//			resources = this.resourceDao.queryLimit(con, keys, resourceId, rows);
658
//		}
659
//		if(resources.isEmpty()){
660
//			resources = this.resourceDao.queryByProId(con, professorId, resourceId, rows);
661
//			if(resources.isEmpty()){
662
//				resources = this.resourceDao.queryByProId(con, null, resourceId, rows);
663
//			}
664
//		}
665
//		if(!resources.isEmpty()){
666
//			for (Resource resource : resources) {
667
//				resource.setImages(this.imagesService.queryRes(con, resource.getResourceId()));
668
//				if(resource.getProfessorId() != null){
669
//					EditProfessor professor = this.professorDao.queryBaseInfo(con, resource.getProfessorId());
670
//					if(professor != null){
671
//						professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
672
//					}
673
//					resource.setEditProfessor(professor);
674
//				}else if(resource.getOrgId() != null){
675
//					EditOrganization organization = this.orgDao.queryEditOrg(con, resource.getOrgId());
676
//					if(organization != null){
677
//						organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
678
//					}
679
//					resource.setOrganization(organization);
680
//				}
681
//			}
682
//		}
683
//		return resources;
684
//	}
685
//	
686
//	@Get
687
//	@Path("/orgRalateRes")
688
//	public List<Resource> queryOrgRalateRes(@JdbcConn Connection con,@Nullable String[] keys,String resourceId,
689
//			String orgId,@DefaultValue("10") int rows)throws SQLException{
690
//		List<Resource> resources = new ArrayList<Resource>();
691
//		if(keys != null){
692
//			resources = this.resourceDao.queryLimit(con, keys, resourceId, rows);
693
//		}
694
//		if(resources.isEmpty()){
695
//			resources = this.resourceDao.queryByOrgId(con, orgId, resourceId, rows);
696
//			if(resources.isEmpty()){
697
//				resources = this.resourceDao.queryByOrgId(con, null, resourceId, rows);
698
//			}
699
//		}
700
//		if(!resources.isEmpty()){
701
//			for (Resource resource : resources) {
702
//				resource.setImages(this.imagesService.queryRes(con, resource.getResourceId()));
703
//				if(resource.getProfessorId() != null){
704
//					EditProfessor professor = this.professorDao.queryBaseInfo(con, resource.getProfessorId());
705
//					if(professor != null){
706
//						professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
707
//					}
708
//					resource.setEditProfessor(professor);
709
//				}else if(resource.getOrgId() != null){
710
//					EditOrganization organization = this.orgDao.queryEditOrg(con, resource.getOrgId());
711
//					if(organization != null){
712
//						organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
713
//					}
714
//					resource.setOrganization(organization);
715
//				}
716
//			}
717
//		}
718
//		return resources;
719
//	}
720
//	
720 721
	@Get
721 722
	@Path("/articles")
722 723
	public List<ArticleRes> queryArticles(@JdbcConn Connection con, String resourceId, @DefaultValue("5") int rows) throws SQLException{
@ -991,4 +992,14 @@ public class ResourceService {
991 992
	public Resource query(@JdbcConn Connection con,long id)throws SQLException{
992 993
		return this.resourceDao.query(con,id);
993 994
	}
995
	
996
	@Get
997
	@Path("/ralateResources")
998
	public List<Resource> ralateResources(@JdbcConn Connection con,String resourceId,@DefaultValue("5") int rows)throws SQLException{
999
		String[] ids = this.resourceDao.queryResourceIdWithSameKeyWord(con, resourceId, rows);
1000
		if(ids!=null){
1001
			return this.resourceDao.query(con,ids);
1002
		}
1003
		return Collections.<Resource>emptyList();
1004
	}
994 1005
}

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

@ -1547,6 +1547,17 @@ COMMENT ON TABLE pat_key_word IS '专利关键字';
1547 1547
COMMENT ON COLUMN pat_key_word.id IS '专利ID';
1548 1548
COMMENT ON COLUMN pat_key_word.kw IS '关键字';
1549 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

1550 1561

1551 1562

1552 1563