jiapeng 7 lat temu
rodzic
commit
4fbf9b72d7

+ 6 - 0
src/main/java/com/ekexiu/portal/dao/ArticleDao.java

@ -320,6 +320,12 @@ public abstract class ArticleDao {
320 320
	}
321 321
	@SelectList
322 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;
328
	
323 329

324 330
//	public List<Article> queryLimit(Connection con,String[] keys,String articleId,int rows) throws SQLException{
325 331
//		int index = 1;

+ 5 - 2
src/main/java/com/ekexiu/portal/dao/ArticleOrgDao.java

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

+ 2 - 0
src/main/java/com/ekexiu/portal/dao/ArticleProDao.java

@ -29,5 +29,7 @@ public abstract class ArticleProDao {
29 29
	@DeleteWith
30 30
	@From(ArticlePro.class)
31 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;
32 34

33 35
}

+ 4 - 0
src/main/java/com/ekexiu/portal/dao/ArticleResDao.java

@ -11,6 +11,7 @@ import org.jfw.apt.orm.annotation.dao.DAO;
11 11
import org.jfw.apt.orm.annotation.dao.method.From;
12 12
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
13 13
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
14
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
14 15

15 16
import com.ekexiu.portal.po.ArticleRes;
16 17

@ -80,4 +81,7 @@ public abstract class ArticleResDao {
80 81
	@From(ArticleRes.class)
81 82
	public abstract int delete(Connection con, String articleId) throws SQLException;
82 83

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

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

@ -21,9 +21,9 @@ public interface PaperAgreeDao {
21 21
	@Insert
22 22
	int insert(Connection con,PaperAgree pa) throws SQLException;
23 23
	
24
	@DeleteWith
25
	@From(PaperAgree.class)
26
	int delete(Connection con,String opId,String paperId) throws SQLException;
24
//	@DeleteWith
25
//	@From(PaperAgree.class)
26
//	int delete(Connection con,String opId,String paperId) throws SQLException;
27 27
	
28 28
	@DeleteWith
29 29
	@From(PaperAgree.class)

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

@ -21,9 +21,9 @@ public interface PatentAgreeDao {
21 21
	@Insert
22 22
	int insert(Connection con,PatentAgree pa) throws SQLException;
23 23
	
24
	@DeleteWith
25
	@From(PatentAgree.class)
26
	int delete(Connection con,String opId,String patentId) throws SQLException;
24
//	@DeleteWith
25
//	@From(PatentAgree.class)
26
//	int delete(Connection con,String opId,String patentId) throws SQLException;
27 27
	
28 28
	@DeleteWith
29 29
	@From(PatentAgree.class)

+ 36 - 1
src/main/java/com/ekexiu/portal/dao/PpaperDao.java

@ -96,5 +96,40 @@ public abstract class PpaperDao {
96 96
		}
97 97
		return ret.isEmpty()?null:ret.toArray(new String[ret.size()]);		
98 98
	}
99

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
	}
100 135
}

+ 63 - 19
src/main/java/com/ekexiu/portal/dao/PpatentDao.java

@ -52,47 +52,91 @@ public abstract class PpatentDao {
52 52
	@OrderBy(" ORDER BY ASS_TIME DESC,ID ASC")
53 53
	public abstract PageQueryResult<AssedPatent> pageQueryWithAuthor(Connection con,
54 54
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "A.NAME=?" }) String author,
55
			@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,
56 57
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "P.NAME LIKE ?" }) String name, int pageSize, int pageNo) throws SQLException;
57
	
58

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

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

68 68
	@PageSelect
69 69
	@OrderBy(" ORDER BY SORT_NUM DESC,CREATE_TIME DESC,ID DESC")
70 70
	@Or
71
	public abstract 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;
72 73

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

98 142
}

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

@ -54,7 +54,7 @@ public class ArticleService {
54 54
	private File articlePath;
55 55
	private String dateFormat = "yyyyMMdd";
56 56
	private String timeFormat = "yyyyMMddHHmmss";
57
	private int artMaxLen=70;
57
	private int artMaxLen = 70;
58 58
	private static final String JPG = "jpg";
59 59
	public static final String MAX_MODIFYTIME = "9";
60 60
	@Autowrie
@ -81,14 +81,12 @@ public class ArticleService {
81 81
	private ArticleProDao articleProDao;
82 82
	@Autowrie
83 83
	private ArticleResDao articleResDao;
84
	
84

85 85
	@Autowrie
86 86
	private ArticleOrgDao articleOrgDao;
87
	
87

88 88
	@Autowrie
89 89
	private KeyWordService keyWordService;
90
	
91
	
92 90

93 91
	public KeyWordService getKeyWordService() {
94 92
		return keyWordService;
@ -153,7 +151,7 @@ public class ArticleService {
153 151
	public void setArticleDao(ArticleDao articleDao) {
154 152
		this.articleDao = articleDao;
155 153
	}
156
	
154

157 155
	public ArticleAgreeDao getArticleAgreeDao() {
158 156
		return articleAgreeDao;
159 157
	}
@ -249,7 +247,7 @@ public class ArticleService {
249 247
		out.flush();
250 248
		return out.toByteArray();
251 249
	}
252
	
250

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

265
	private void saveArtImg(String fn, String id) throws JfwBaseException, IOException {
268 266
		byte[] src = this.readTmpFile(fn);
269 267
		src = JpgUtil.read(src);
270 268
		byte[] shareResImage = this.resImage(src, this.artMaxLen);
@ -277,69 +275,68 @@ public class ArticleService {
277 275
		IoUtil.saveStream(new FileOutputStream(new File(dateFile, id + "." + JPG)), src, true);
278 276
		IoUtil.saveStream(new FileOutputStream(new File(dateFile, id + "_s." + JPG)), shareResImage, true);
279 277
	}
280
	
281
	private String createDate(){
278

279
	private String createDate() {
282 280
		SimpleDateFormat df = new SimpleDateFormat(this.dateFormat);
283 281
		String date = df.format(new Date());
284 282
		return date;
285 283
	}
286
	
287
	private String publishTime(){
284

285
	private String publishTime() {
288 286
		SimpleDateFormat df = new SimpleDateFormat(this.timeFormat);
289 287
		String publishTime = df.format(new Date());
290 288
		return publishTime;
291 289
	}
292
	
290

293 291
	@Post
294 292
	@Path
295
	public String insert(@JdbcConn(true) Connection con, Article article) 
296
			throws SQLException, IOException, JfwBaseException{
293
	public String insert(@JdbcConn(true) Connection con, Article article) throws SQLException, IOException, JfwBaseException {
297 294
		String articleId = StringUtil.buildUUID();
298
		if(article.getArticleImg() != null){
295
		if (article.getArticleImg() != null) {
299 296
			this.saveArtImg(article.getArticleImg(), articleId);
300
			article.setArticleImg(this.createDate()+"/"+articleId+"."+JPG);
297
			article.setArticleImg(this.createDate() + "/" + articleId + "." + JPG);
301 298
		}
302 299
		article.setArticleId(articleId);
303 300
		article.setArticleAgree(0);
304 301
		article.setPageViews(0);
305 302
		article.setStatus("1");
306 303
		article.setPublishTime(this.publishTime());
307
		if(article.getProfessorId() != null && article.getOrgId() == null){
304
		if (article.getProfessorId() != null && article.getOrgId() == null) {
308 305
			article.setArticleType("1");
309
		}else if(article.getProfessorId() == null && article.getOrgId() != null){
306
		} else if (article.getProfessorId() == null && article.getOrgId() != null) {
310 307
			article.setArticleType("2");
311
		}else{
308
		} else {
312 309
			throw new JfwBaseException(-1, "错误参数:文章发布者ID");
313 310
		}
314 311
		this.articleDao.insert(con, article);
315 312
		return articleId;
316 313
	}
317
	
314

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

408 405
	@Post
409 406
	@Path("/draft")
410
	public String draft(@JdbcConn(true) Connection con,Article article,@Nullable String[] professors,
411
			@Nullable String[] resources,@Nullable String[] orgs) throws SQLException, IOException, JfwBaseException{
412
		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) {
413 410
			String articleId = StringUtil.buildUUID();
414
			if(article.getArticleImg() != null){
411
			if (article.getArticleImg() != null) {
415 412
				this.saveArtImg(article.getArticleImg(), articleId);
416
				article.setArticleImg(this.createDate()+"/"+articleId+"."+JPG);
413
				article.setArticleImg(this.createDate() + "/" + articleId + "." + JPG);
417 414
			}
418 415
			article.setArticleId(articleId);
419 416
			article.setArticleAgree(0);
420 417
			article.setPageViews(0);
421 418
			article.setStatus("0");
422
			if(article.getProfessorId() != null && article.getOrgId() == null){
419
			if (article.getProfessorId() != null && article.getOrgId() == null) {
423 420
				article.setArticleType("1");
424
			}else if(article.getProfessorId() == null && article.getOrgId() != null){
421
			} else if (article.getProfessorId() == null && article.getOrgId() != null) {
425 422
				article.setArticleType("2");
426
			}else{
423
			} else {
427 424
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
428 425
			}
429 426
			this.articleDao.insert(con, article);
430
			this.keyWordService.refreshArticle(con,articleId, null);
431
			if(professors != null){
427
			this.keyWordService.refreshArticle(con, articleId, null);
428
			if (professors != null) {
432 429
				for (String professor : professors) {
433 430
					ArticlePro articlePro = new ArticlePro();
434 431
					articlePro.setArticleId(articleId);
@ -436,7 +433,7 @@ public class ArticleService {
436 433
					this.articleProDao.insert(con, articlePro);
437 434
				}
438 435
			}
439
			if(resources != null){
436
			if (resources != null) {
440 437
				for (String resource : resources) {
441 438
					ArticleRes articleRes = new ArticleRes();
442 439
					articleRes.setArticleId(articleId);
@ -444,8 +441,8 @@ public class ArticleService {
444 441
					this.articleResDao.insert(con, articleRes);
445 442
				}
446 443
			}
447
			if(orgs!=null && orgs.length>0){
448
				for(String org:orgs){
444
			if (orgs != null && orgs.length > 0) {
445
				for (String org : orgs) {
449 446
					ArticleOrg articleOrg = new ArticleOrg();
450 447
					articleOrg.setArticleId(articleId);
451 448
					articleOrg.setOrgId(org);
@ -453,10 +450,10 @@ public class ArticleService {
453 450
				}
454 451
			}
455 452
			return articleId;
456
		}else if(article.getArticleId().trim().length() == 32){
457
			if(article.getArticleImg() != null){
453
		} else if (article.getArticleId().trim().length() == 32) {
454
			if (article.getArticleImg() != null) {
458 455
				this.saveArtImg(article.getArticleImg(), article.getArticleId());
459
				article.setArticleImg(this.createDate()+"/"+article.getArticleId()+"."+JPG);
456
				article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
460 457
			}
461 458
			this.articleDao.update(con, article);
462 459
			this.articleDao.updateStatus(con, article.getArticleId(), "0");
@ -464,7 +461,7 @@ public class ArticleService {
464 461
			this.articleProDao.delete(con, article.getArticleId());
465 462
			this.articleResDao.delete(con, article.getArticleId());
466 463
			this.articleOrgDao.delete(con, article.getArticleId());
467
			if(professors != null){
464
			if (professors != null) {
468 465
				for (String professor : professors) {
469 466
					ArticlePro articlePro = new ArticlePro();
470 467
					articlePro.setArticleId(article.getArticleId());
@ -472,7 +469,7 @@ public class ArticleService {
472 469
					this.articleProDao.insert(con, articlePro);
473 470
				}
474 471
			}
475
			if(resources != null){
472
			if (resources != null) {
476 473
				for (String resource : resources) {
477 474
					ArticleRes articleRes = new ArticleRes();
478 475
					articleRes.setArticleId(article.getArticleId());
@ -480,8 +477,8 @@ public class ArticleService {
480 477
					this.articleResDao.insert(con, articleRes);
481 478
				}
482 479
			}
483
			if(orgs!=null && orgs.length>0){
484
				for(String org:orgs){
480
			if (orgs != null && orgs.length > 0) {
481
				for (String org : orgs) {
485 482
					ArticleOrg articleOrg = new ArticleOrg();
486 483
					articleOrg.setArticleId(article.getArticleId());
487 484
					articleOrg.setOrgId(org);
@ -489,37 +486,37 @@ public class ArticleService {
489 486
				}
490 487
			}
491 488
			return article.getArticleId();
492
		}else{
489
		} else {
493 490
			throw new JfwBaseException(-2, "bad parameter:articleId");
494 491
		}
495 492
	}
496
	
493

497 494
	@Post
498 495
	@Path("/timing")
499
	public String timingPublish(@JdbcConn(true) Connection con,Article article,@Nullable String[] professors,
500
			@Nullable String[] resources,@Nullable String[] orgs) throws SQLException, IOException, JfwBaseException{
501
		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) {
502 499
			throw new JfwBaseException(-3, "no parameter found:publishTime");
503 500
		}
504
		if(article.getArticleId() == null){
501
		if (article.getArticleId() == null) {
505 502
			String articleId = StringUtil.buildUUID();
506
			if(article.getArticleImg() != null){
503
			if (article.getArticleImg() != null) {
507 504
				this.saveArtImg(article.getArticleImg(), articleId);
508
				article.setArticleImg(this.createDate()+"/"+articleId+"."+JPG);
505
				article.setArticleImg(this.createDate() + "/" + articleId + "." + JPG);
509 506
			}
510 507
			article.setArticleId(articleId);
511 508
			article.setArticleAgree(0);
512 509
			article.setPageViews(0);
513 510
			article.setStatus("2");
514
			if(article.getProfessorId() != null && article.getOrgId() == null){
511
			if (article.getProfessorId() != null && article.getOrgId() == null) {
515 512
				article.setArticleType("1");
516
			}else if(article.getProfessorId() == null && article.getOrgId() != null){
513
			} else if (article.getProfessorId() == null && article.getOrgId() != null) {
517 514
				article.setArticleType("2");
518
			}else{
515
			} else {
519 516
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
520 517
			}
521 518
			this.articleDao.insert(con, article);
522
			if(professors != null){
519
			if (professors != null) {
523 520
				for (String professor : professors) {
524 521
					ArticlePro articlePro = new ArticlePro();
525 522
					articlePro.setArticleId(articleId);
@ -527,7 +524,7 @@ public class ArticleService {
527 524
					this.articleProDao.insert(con, articlePro);
528 525
				}
529 526
			}
530
			if(resources != null){
527
			if (resources != null) {
531 528
				for (String resource : resources) {
532 529
					ArticleRes articleRes = new ArticleRes();
533 530
					articleRes.setArticleId(articleId);
@ -535,8 +532,8 @@ public class ArticleService {
535 532
					this.articleResDao.insert(con, articleRes);
536 533
				}
537 534
			}
538
			if(orgs!=null && orgs.length>0){
539
				for(String org:orgs){
535
			if (orgs != null && orgs.length > 0) {
536
				for (String org : orgs) {
540 537
					ArticleOrg articleOrg = new ArticleOrg();
541 538
					articleOrg.setArticleId(articleId);
542 539
					articleOrg.setOrgId(org);
@ -544,19 +541,19 @@ public class ArticleService {
544 541
				}
545 542
			}
546 543
			return articleId;
547
		}else if(article.getArticleId().trim().length() == 32){
548
			if(article.getArticleImg() != null){
544
		} else if (article.getArticleId().trim().length() == 32) {
545
			if (article.getArticleImg() != null) {
549 546
				this.saveArtImg(article.getArticleImg(), article.getArticleId());
550
				article.setArticleImg(this.createDate()+"/"+article.getArticleId()+"."+JPG);
547
				article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
551 548
			}
552 549
			this.articleDao.update(con, article);
553 550
			this.articleDao.updatePublishTime(con, article.getArticleId(), "2", article.getPublishTime());
554
			this.keyWordService.refreshArticle(con,article.getArticleId(), null);
551
			this.keyWordService.refreshArticle(con, article.getArticleId(), null);
555 552
			this.articleResDao.delete(con, article.getArticleId());
556 553
			this.articleProDao.delete(con, article.getArticleId());
557 554
			this.articleOrgDao.delete(con, article.getArticleId());
558
			
559
			if(professors != null){
555

556
			if (professors != null) {
560 557
				for (String professor : professors) {
561 558
					ArticlePro articlePro = new ArticlePro();
562 559
					articlePro.setArticleId(article.getArticleId());
@ -564,7 +561,7 @@ public class ArticleService {
564 561
					this.articleProDao.insert(con, articlePro);
565 562
				}
566 563
			}
567
			if(resources != null){
564
			if (resources != null) {
568 565
				for (String resource : resources) {
569 566
					ArticleRes articleRes = new ArticleRes();
570 567
					articleRes.setArticleId(article.getArticleId());
@ -572,8 +569,8 @@ public class ArticleService {
572 569
					this.articleResDao.insert(con, articleRes);
573 570
				}
574 571
			}
575
			if(orgs!=null && orgs.length>0){
576
				for(String org:orgs){
572
			if (orgs != null && orgs.length > 0) {
573
				for (String org : orgs) {
577 574
					ArticleOrg articleOrg = new ArticleOrg();
578 575
					articleOrg.setArticleId(article.getArticleId());
579 576
					articleOrg.setOrgId(org);
@ -581,177 +578,179 @@ public class ArticleService {
581 578
				}
582 579
			}
583 580
			return article.getArticleId();
584
		}else{
581
		} else {
585 582
			throw new JfwBaseException(-2, "bad parameter:articleId");
586 583
		}
587 584
	}
588
	
585

589 586
	@Post
590 587
	@Path("/updateArt")
591
	public void update(@JdbcConn(true) Connection con, Article article) 
592
			throws SQLException, JfwBaseException, IOException{
593
		if(article.getArticleImg() != null){
588
	public void update(@JdbcConn(true) Connection con, Article article) throws SQLException, JfwBaseException, IOException {
589
		if (article.getArticleImg() != null) {
594 590
			this.saveArtImg(article.getArticleImg(), article.getArticleId());
595
			article.setArticleImg(this.createDate()+"/"+article.getArticleId()+"."+JPG);
591
			article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
596 592
		}
597 593
		this.articleDao.update(con, article);
598 594
	}
599
	
595

600 596
	@Post
601 597
	@Path("/pageViews")
602
	public void pageViews(@JdbcConn(true) Connection con,String articleId) throws SQLException{
598
	public void pageViews(@JdbcConn(true) Connection con, String articleId) throws SQLException {
603 599
		this.articleDao.incPageViews(con, articleId);
604 600
	}
605
	
601

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

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

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

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

640 636
	@Post
641 637
	@Path("/agree")
642
	public void agree(@JdbcConn(true) Connection con,String operateId,String articleId)throws SQLException{
643
		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) {
644 640
			ArticleAgree articleAgree = new ArticleAgree();
645 641
			articleAgree.setOperateId(operateId);
646 642
			articleAgree.setArticleId(articleId);
647 643
			this.articleAgreeDao.insert(con, articleAgree);
648 644
		}
649 645
	}
650
	
646

651 647
	@Post
652 648
	@Path("/unAgree")
653
	public void unAgree(@JdbcConn(true) Connection con,String operateId,String articleId)throws SQLException{
654
		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) {
655 651
			this.articleAgreeDao.deleteAgree(con, operateId, articleId);
656 652
		}
657 653
	}
658
	
654

659 655
	@Get
660 656
	@Path("/isAgree")
661
	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 {
662 658
		return this.articleAgreeDao.queryOne(con, operateId, articleId);
663 659
	}
664
	
660

665 661
	@Get
666 662
	@Path("/agreeList")
667
	public List<ArticleAgree> queryAgreeList(@JdbcConn Connection con,String articleId)throws SQLException{
663
	public List<ArticleAgree> queryAgreeList(@JdbcConn Connection con, String articleId) throws SQLException {
668 664
		return this.articleAgreeDao.query(con, articleId);
669 665
	}
670
	
666

671 667
	@Get
672 668
	@Path("/qaPro")
673
	public List<Article> queryPro(@JdbcConn Connection con, String professorId) throws SQLException{
669
	public List<Article> queryPro(@JdbcConn Connection con, String professorId) throws SQLException {
674 670
		return this.articleDao.queryPro(con, professorId);
675 671
	}
676
	
672

677 673
	@Get
678 674
	@Path("/qaProPublish")
679
	public List<Article> queryProPublish(@JdbcConn Connection con, String professorId) throws SQLException{
675
	public List<Article> queryProPublish(@JdbcConn Connection con, String professorId) throws SQLException {
680 676
		return this.articleDao.queryProPublish(con, professorId);
681 677
	}
682
	
678

683 679
	@Get
684 680
	@Path("/pqProPublish")
685
	public PageQueryResult<Article> pageQueryProPublish(@JdbcConn Connection con, String professorId,@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo) throws SQLException{
686
		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);
687 684
	}
688
	
685

689 686
	@Get
690 687
	@Path("/qaForDesk")
691
	public List<Article> queryForDesk(@JdbcConn Connection con, String professorId) throws SQLException{
688
	public List<Article> queryForDesk(@JdbcConn Connection con, String professorId) throws SQLException {
692 689
		return this.articleDao.queryForDesk(con, professorId);
693 690
	}
694
	
691

695 692
	@Get
696 693
	@Path("/qaOrg")
697
	public List<Article> queryOrg(@JdbcConn Connection con,String orgId)throws SQLException{
694
	public List<Article> queryOrg(@JdbcConn Connection con, String orgId) throws SQLException {
698 695
		return this.articleDao.queryOrg(con, orgId);
699 696
	}
700
	
697

701 698
	@Get
702 699
	@Path("/qaOrgPublish")
703
	public List<Article> queryOrgPublish(@JdbcConn Connection con,String orgId)throws SQLException{
700
	public List<Article> queryOrgPublish(@JdbcConn Connection con, String orgId) throws SQLException {
704 701
		return this.articleDao.queryOrgPublish(con, orgId);
705 702
	}
706
	
703

707 704
	@Get
708 705
	@Path("/pqOrgPublish")
709
	public PageQueryResult<Article> pageQueryOrgPublish(@JdbcConn Connection con,String orgId,@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
710
		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);
711 709
	}
712
	
710

713 711
	@Get
714 712
	@Path("/qlOrg")
715
	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 {
716 715
		return this.articleDao.queryLimit(con, orgId, modifyTime, rows);
717 716
	}
718
	
717

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

725 724
	@Get
726 725
	@Path("/pqpublish")
727
	public PageQueryResult<Article> queryPagePublish(@JdbcConn Connection con,@Nullable String articleTitle,
728
			@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
729
		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) {
730 729
			articleTitle = "%" + articleTitle + "%";
731 730
		}
732 731
		return this.articleDao.queryPageForPublish(con, articleTitle, pageSize, pageNo);
733 732
	}
734
	
733

735 734
	@Get
736 735
	@Path("/firstpq")
737
	public PageQueryResult<Article> firstPageQuery(@JdbcConn Connection con,@Nullable String key,
738
			@DefaultValue("20") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
739
		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) {
740 739
			key = "%" + key + "%";
741 740
		}
742 741
		PageQueryResult<Article> queryResult = this.articleDao.firstPageQuery(con, key, pageSize, pageNo);
743 742
		List<Article> articles = queryResult.getData();
744
		if(!articles.isEmpty()){
743
		if (!articles.isEmpty()) {
745 744
			for (Article article : articles) {
746
				if("1".equals(article.getArticleType())){
745
				if ("1".equals(article.getArticleType())) {
747 746
					EditProfessor professor = this.professorDao.queryBaseInfo(con, article.getProfessorId());
748
					if(professor != null){
747
					if (professor != null) {
749 748
						professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
750 749
					}
751 750
					article.setProfessor(professor);
752
				}else if("2".equals(article.getArticleType())){
751
				} else if ("2".equals(article.getArticleType())) {
753 752
					EditOrganization organization = this.orgDao.queryEditOrg(con, article.getOrgId());
754
					if(organization != null){
753
					if (organization != null) {
755 754
						organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
756 755
					}
757 756
					article.setEditOrganization(organization);
@ -760,44 +759,45 @@ public class ArticleService {
760 759
		}
761 760
		return queryResult;
762 761
	}
763
	
762

764 763
	@Get
765 764
	@Path("/pqself")
766
	public PageQueryResult<Article> queryPageSelf(@JdbcConn Connection con,@Nullable String professorId,@Nullable String orgId,
767
			@Nullable String articleTitle,@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
768
		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) {
769 768
			articleTitle = "%" + articleTitle + "%";
770 769
		}
771 770
		return this.articleDao.queryPageForSelf(con, professorId, orgId, articleTitle, pageSize, pageNo);
772 771
	}
773
	
772

774 773
	@Get
775 774
	@Path("/pqFind")
776
	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 {
777 776
		PageQueryResult<FindInfo> queryResult = this.articleDao.queryPage(con, pageSize, pageNo);
778 777
		List<FindInfo> findInfos = queryResult.getData();
779 778
		for (FindInfo findInfo : findInfos) {
780
			if("3".equals(findInfo.getType())){
779
			if ("3".equals(findInfo.getType())) {
781 780
				List<Image> images = this.imagesService.queryRes(con, findInfo.getId());
782
				if(images.size() > 0){
783
					findInfo.setImage(findInfo.getId()+".jpg");
781
				if (images.size() > 0) {
782
					findInfo.setImage(findInfo.getId() + ".jpg");
784 783
				}
785 784
			}
786 785
		}
787 786
		queryResult.setData(findInfos);
788 787
		return queryResult;
789 788
	}
790
	
789

791 790
	@Get
792 791
	@Path("/findHot")
793
	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 {
794 794
		PageQueryResult<FindInfo> queryResult = this.articleDao.queryFindHot(con, pageSize, pageNo);
795 795
		List<FindInfo> findInfos = queryResult.getData();
796
		if(!findInfos.isEmpty()){
796
		if (!findInfos.isEmpty()) {
797 797
			for (FindInfo findInfo : findInfos) {
798
				if("3".equals(findInfo.getType()) || "4".equals(findInfo.getType())){
798
				if ("3".equals(findInfo.getType()) || "4".equals(findInfo.getType())) {
799 799
					List<Image> images = this.imagesService.queryRes(con, findInfo.getId());
800
					if(images.size() > 0){
800
					if (images.size() > 0) {
801 801
						findInfo.setImage(images.get(0).getImageSrc());
802 802
					}
803 803
				}
@ -806,62 +806,117 @@ public class ArticleService {
806 806
		}
807 807
		return queryResult;
808 808
	}
809
	
809

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

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

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

828 828
	@Get
829 829
	@Path("/ralateArticles")
830
	public List<Article> ralateArticles(@JdbcConn Connection con,@Nullable String[] keys,@Nullable String professorId,
831
			@Nullable String orgId,String articleId,@DefaultValue("5") int rows)throws SQLException{
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 832
		String[] ids = this.articleDao.queryArticleIdWithSameKeyWord(con, articleId, rows);
833
		if(ids!=null){
834
			return this.articleDao.query(con,ids);
833
		if (ids != null) {
834
			return this.articleDao.query(con, ids);
835 835
		}
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;
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();
877
		}
878

879
		return this.articleDao.limitQueryPublish(con, ids, rows);
848 880
	}
849 881
	
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
//	}
861
	
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);
898
	}
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

862 917
	@Path("/byShareId")
863 918
	@Get
864
	public Article query(@JdbcConn Connection con,long id) throws SQLException{
919
	public Article query(@JdbcConn Connection con, long id) throws SQLException {
865 920
		return this.articleDao.query(con, id);
866 921
	}
867 922


+ 15 - 5
src/main/java/com/ekexiu/portal/service/PpaperService.java

@ -20,6 +20,7 @@ import com.ekexiu.portal.dao.PpaperDao;
20 20
import com.ekexiu.portal.po.PaperAgree;
21 21
import com.ekexiu.portal.po.PaperAuthor;
22 22
import com.ekexiu.portal.po.Ppaper;
23
import com.ekexiu.portal.po.Ppatent;
23 24
import com.ekexiu.portal.pojo.AssedPaper;
24 25

25 26
@Path("/ppaper")
@ -192,11 +193,11 @@ public class PpaperService {
192 193
		this.paperAgreeDao.insert(con, pa);		
193 194
	}
194 195
	
195
	@Post
196
	@Path("/unAgree")
197
	public void unAgree(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
198
		this.paperAgreeDao.delete(con,uid, id);
199
	}
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
//	}
200 201
	
201 202
	@Get
202 203
	@Path("/agree")
@ -208,4 +209,13 @@ public class PpaperService {
208 209
	public int agreeCount(@JdbcConn(false) Connection con,String id)throws SQLException{
209 210
		return this.paperAgreeDao.query(con,id);
210 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
	}
211 221
}

+ 17 - 5
src/main/java/com/ekexiu/portal/service/PpatentServcie.java

@ -14,9 +14,11 @@ import org.jfw.apt.web.annotation.operate.Post;
14 14
import org.jfw.apt.web.annotation.param.JdbcConn;
15 15
import org.jfw.util.PageQueryResult;
16 16

17
import com.ekexiu.portal.dao.PaperAuthorDao;
17 18
import com.ekexiu.portal.dao.PatentAgreeDao;
18 19
import com.ekexiu.portal.dao.PatentAuthorDao;
19 20
import com.ekexiu.portal.dao.PpatentDao;
21
import com.ekexiu.portal.po.PaperAuthor;
20 22
import com.ekexiu.portal.po.PatentAgree;
21 23
import com.ekexiu.portal.po.PatentAuthor;
22 24
import com.ekexiu.portal.po.Ppatent;
@ -185,11 +187,11 @@ public class PpatentServcie {
185 187
		this.patentAgreeDao.insert(con, pa);		
186 188
	}
187 189
	
188
	@Post
189
	@Path("/unAgree")
190
	public void unAgree(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
191
		this.patentAgreeDao.delete(con,uid, id);
192
	}
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
//	}
193 195
	
194 196
	@Get
195 197
	@Path("/agree")
@ -201,4 +203,14 @@ public class PpatentServcie {
201 203
	public int agreeCount(@JdbcConn(false) Connection con,String id)throws SQLException{
202 204
		return this.patentAgreeDao.query(con,id);
203 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
	
204 216
}

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

@ -4,10 +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;
9 12
import java.util.Collections;
13
import java.util.HashMap;
10 14
import java.util.List;
15
import java.util.Map;
11 16

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

26 32
import com.ekexiu.portal.dao.ArticleDao;
27 33
import com.ekexiu.portal.dao.HonorDao;
@ -39,7 +45,6 @@ import com.ekexiu.portal.dao.ResearchAreaLogDao;
39 45
import com.ekexiu.portal.dao.ResourceDao;
40 46
import com.ekexiu.portal.dao.UserDao;
41 47
import com.ekexiu.portal.dao.WatchDao;
42
import com.ekexiu.portal.po.Article;
43 48
import com.ekexiu.portal.po.Professor;
44 49
import com.ekexiu.portal.po.Resource;
45 50
import com.ekexiu.portal.po.User;
@ -749,6 +754,41 @@ public class ProfessorService {
749 754
		}
750 755
		return Collections.<Professor>emptyList();
751 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
		}
790
	}
791
	
752 792
//	
753 793
//	
754 794
//	@Get