jiapeng 7 gadi atpakaļ
vecāks
revīzija
4fbf9b72d7

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

320
	}
320
	}
321
	@SelectList
321
	@SelectList
322
	public abstract List<Article> query(Connection con,@In String[] articleId) throws SQLException;
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
//	public List<Article> queryLimit(Connection con,String[] keys,String articleId,int rows) throws SQLException{
330
//	public List<Article> queryLimit(Connection con,String[] keys,String articleId,int rows) throws SQLException{
325
//		int index = 1;
331
//		int index = 1;

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

18
	@Insert
18
	@Insert
19
	int insert(Connection con,ArticleOrg org) throws SQLException;
19
	int insert(Connection con,ArticleOrg org) throws SQLException;
20
	@SelectList
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
	@DeleteWith
22
	@DeleteWith
23
	@From(ArticleOrg.class)
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
	@DeleteWith
29
	@DeleteWith
30
	@From(ArticlePro.class)
30
	@From(ArticlePro.class)
31
	public abstract int delete(Connection con, String articleId) throws SQLException;
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
import org.jfw.apt.orm.annotation.dao.method.From;
11
import org.jfw.apt.orm.annotation.dao.method.From;
12
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
12
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
13
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
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
import com.ekexiu.portal.po.ArticleRes;
16
import com.ekexiu.portal.po.ArticleRes;
16

17

80
	@From(ArticleRes.class)
81
	@From(ArticleRes.class)
81
	public abstract int delete(Connection con, String articleId) throws SQLException;
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
	@Insert
21
	@Insert
22
	int insert(Connection con,PaperAgree pa) throws SQLException;
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
	@DeleteWith
28
	@DeleteWith
29
	@From(PaperAgree.class)
29
	@From(PaperAgree.class)

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

21
	@Insert
21
	@Insert
22
	int insert(Connection con,PatentAgree pa) throws SQLException;
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
	@DeleteWith
28
	@DeleteWith
29
	@From(PatentAgree.class)
29
	@From(PatentAgree.class)

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

96
		}
96
		}
97
		return ret.isEmpty()?null:ret.toArray(new String[ret.size()]);		
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
	@OrderBy(" ORDER BY ASS_TIME DESC,ID ASC")
52
	@OrderBy(" ORDER BY ASS_TIME DESC,ID ASC")
53
	public abstract PageQueryResult<AssedPatent> pageQueryWithAuthor(Connection con,
53
	public abstract PageQueryResult<AssedPatent> pageQueryWithAuthor(Connection con,
54
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "A.NAME=?" }) String author,
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
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "P.NAME LIKE ?" }) String name, int pageSize, int pageNo) throws SQLException;
57
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "P.NAME LIKE ?" }) String name, int pageSize, int pageNo) throws SQLException;
57
	
58

58
	@From(Ppatent.class)
59
	@From(Ppatent.class)
59
	@UpdateWith
60
	@UpdateWith
60
	@SetSentence("PAGE_VIEWS = PAGE_VIEWS + 1")
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
	@PageSelect
64
	@PageSelect
65
	@OrderBy(" ORDER BY SORT_NUM DESC,CREATE_TIME DESC,ID DESC")
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
	@PageSelect
68
	@PageSelect
69
	@OrderBy(" ORDER BY SORT_NUM DESC,CREATE_TIME DESC,ID DESC")
69
	@OrderBy(" ORDER BY SORT_NUM DESC,CREATE_TIME DESC,ID DESC")
70
	@Or
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
	@SelectOne
74
	@SelectOne
74
	@Nullable
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
		List<String> ret = new ArrayList<String>();
79
		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
		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
		PreparedStatement ps = con.prepareStatement(sql);
81
		try{
82
		try {
82
			ps.setString(1, id);
83
			ps.setString(1, id);
83
			ps.setString(2, id);
84
			ps.setString(2, id);
84
			ps.setInt(3, rows);
85
			ps.setInt(3, rows);
85
			ResultSet rs = ps.executeQuery();
86
			ResultSet rs = ps.executeQuery();
86
			try{
87
				while(rs.next()){
87
			try {
88
				while (rs.next()) {
88
					ret.add(rs.getString(1));
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
	private File articlePath;
54
	private File articlePath;
55
	private String dateFormat = "yyyyMMdd";
55
	private String dateFormat = "yyyyMMdd";
56
	private String timeFormat = "yyyyMMddHHmmss";
56
	private String timeFormat = "yyyyMMddHHmmss";
57
	private int artMaxLen=70;
57
	private int artMaxLen = 70;
58
	private static final String JPG = "jpg";
58
	private static final String JPG = "jpg";
59
	public static final String MAX_MODIFYTIME = "9";
59
	public static final String MAX_MODIFYTIME = "9";
60
	@Autowrie
60
	@Autowrie
81
	private ArticleProDao articleProDao;
81
	private ArticleProDao articleProDao;
82
	@Autowrie
82
	@Autowrie
83
	private ArticleResDao articleResDao;
83
	private ArticleResDao articleResDao;
84
	
84

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

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

90

93
	public KeyWordService getKeyWordService() {
91
	public KeyWordService getKeyWordService() {
94
		return keyWordService;
92
		return keyWordService;
153
	public void setArticleDao(ArticleDao articleDao) {
151
	public void setArticleDao(ArticleDao articleDao) {
154
		this.articleDao = articleDao;
152
		this.articleDao = articleDao;
155
	}
153
	}
156
	
154

157
	public ArticleAgreeDao getArticleAgreeDao() {
155
	public ArticleAgreeDao getArticleAgreeDao() {
158
		return articleAgreeDao;
156
		return articleAgreeDao;
159
	}
157
	}
249
		out.flush();
247
		out.flush();
250
		return out.toByteArray();
248
		return out.toByteArray();
251
	}
249
	}
252
	
250

253
	private byte[] readTmpFile(String fn) throws JfwBaseException {
251
	private byte[] readTmpFile(String fn) throws JfwBaseException {
254
		File file = new File(this.tmpPath, fn);
252
		File file = new File(this.tmpPath, fn);
255
		if (!file.exists())
253
		if (!file.exists())
263
			throw new JfwBaseException(91, "read temp resource image error", e);
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
		byte[] src = this.readTmpFile(fn);
266
		byte[] src = this.readTmpFile(fn);
269
		src = JpgUtil.read(src);
267
		src = JpgUtil.read(src);
270
		byte[] shareResImage = this.resImage(src, this.artMaxLen);
268
		byte[] shareResImage = this.resImage(src, this.artMaxLen);
277
		IoUtil.saveStream(new FileOutputStream(new File(dateFile, id + "." + JPG)), src, true);
275
		IoUtil.saveStream(new FileOutputStream(new File(dateFile, id + "." + JPG)), src, true);
278
		IoUtil.saveStream(new FileOutputStream(new File(dateFile, id + "_s." + JPG)), shareResImage, true);
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
		SimpleDateFormat df = new SimpleDateFormat(this.dateFormat);
280
		SimpleDateFormat df = new SimpleDateFormat(this.dateFormat);
283
		String date = df.format(new Date());
281
		String date = df.format(new Date());
284
		return date;
282
		return date;
285
	}
283
	}
286
	
287
	private String publishTime(){
284

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

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

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

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

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

556
			if (professors != null) {
560
				for (String professor : professors) {
557
				for (String professor : professors) {
561
					ArticlePro articlePro = new ArticlePro();
558
					ArticlePro articlePro = new ArticlePro();
562
					articlePro.setArticleId(article.getArticleId());
559
					articlePro.setArticleId(article.getArticleId());
564
					this.articleProDao.insert(con, articlePro);
561
					this.articleProDao.insert(con, articlePro);
565
				}
562
				}
566
			}
563
			}
567
			if(resources != null){
564
			if (resources != null) {
568
				for (String resource : resources) {
565
				for (String resource : resources) {
569
					ArticleRes articleRes = new ArticleRes();
566
					ArticleRes articleRes = new ArticleRes();
570
					articleRes.setArticleId(article.getArticleId());
567
					articleRes.setArticleId(article.getArticleId());
572
					this.articleResDao.insert(con, articleRes);
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
					ArticleOrg articleOrg = new ArticleOrg();
574
					ArticleOrg articleOrg = new ArticleOrg();
578
					articleOrg.setArticleId(article.getArticleId());
575
					articleOrg.setArticleId(article.getArticleId());
579
					articleOrg.setOrgId(org);
576
					articleOrg.setOrgId(org);
581
				}
578
				}
582
			}
579
			}
583
			return article.getArticleId();
580
			return article.getArticleId();
584
		}else{
581
		} else {
585
			throw new JfwBaseException(-2, "bad parameter:articleId");
582
			throw new JfwBaseException(-2, "bad parameter:articleId");
586
		}
583
		}
587
	}
584
	}
588
	
585

589
	@Post
586
	@Post
590
	@Path("/updateArt")
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
			this.saveArtImg(article.getArticleImg(), article.getArticleId());
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
		this.articleDao.update(con, article);
593
		this.articleDao.update(con, article);
598
	}
594
	}
599
	
595

600
	@Post
596
	@Post
601
	@Path("/pageViews")
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
		this.articleDao.incPageViews(con, articleId);
599
		this.articleDao.incPageViews(con, articleId);
604
	}
600
	}
605
	
601

606
	@Post
602
	@Post
607
	@Path("/updateDraft")
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
		this.articleDao.updateStatus(con, articleId, "0");
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
	@Post
610
	@Post
615
	@Path("/publish")
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
		this.articleDao.updateStatus(con, articleId, "1");
614
		this.articleDao.updateStatus(con, articleId, "1");
619
		Article a = this.articleDao.queryOne(con, articleId);
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
	@Post
621
	@Post
626
	@Path("/deleteArticle")
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
		this.articleDao.updateStatus(con, articleId, "3");
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
	@Post
629
	@Post
634
	@Path("/close")
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
		this.articleDao.updateStatus(con, articleId, "4");
633
		this.articleDao.updateStatus(con, articleId, "4");
638
	}
634
	}
639
	
635

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

651
	@Post
647
	@Post
652
	@Path("/unAgree")
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
			this.articleAgreeDao.deleteAgree(con, operateId, articleId);
651
			this.articleAgreeDao.deleteAgree(con, operateId, articleId);
656
		}
652
		}
657
	}
653
	}
658
	
654

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

665
	@Get
661
	@Get
666
	@Path("/agreeList")
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
		return this.articleAgreeDao.query(con, articleId);
664
		return this.articleAgreeDao.query(con, articleId);
669
	}
665
	}
670
	
666

671
	@Get
667
	@Get
672
	@Path("/qaPro")
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
		return this.articleDao.queryPro(con, professorId);
670
		return this.articleDao.queryPro(con, professorId);
675
	}
671
	}
676
	
672

677
	@Get
673
	@Get
678
	@Path("/qaProPublish")
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
		return this.articleDao.queryProPublish(con, professorId);
676
		return this.articleDao.queryProPublish(con, professorId);
681
	}
677
	}
682
	
678

683
	@Get
679
	@Get
684
	@Path("/pqProPublish")
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
	@Get
686
	@Get
690
	@Path("/qaForDesk")
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
		return this.articleDao.queryForDesk(con, professorId);
689
		return this.articleDao.queryForDesk(con, professorId);
693
	}
690
	}
694
	
691

695
	@Get
692
	@Get
696
	@Path("/qaOrg")
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
		return this.articleDao.queryOrg(con, orgId);
695
		return this.articleDao.queryOrg(con, orgId);
699
	}
696
	}
700
	
697

701
	@Get
698
	@Get
702
	@Path("/qaOrgPublish")
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
		return this.articleDao.queryOrgPublish(con, orgId);
701
		return this.articleDao.queryOrgPublish(con, orgId);
705
	}
702
	}
706
	
703

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

719
	@Get
718
	@Get
720
	@Path("/query")
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
		return this.articleDao.queryOne(con, articleId);
721
		return this.articleDao.queryOne(con, articleId);
723
	}
722
	}
724
	
723

725
	@Get
724
	@Get
726
	@Path("/pqpublish")
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
			articleTitle = "%" + articleTitle + "%";
729
			articleTitle = "%" + articleTitle + "%";
731
		}
730
		}
732
		return this.articleDao.queryPageForPublish(con, articleTitle, pageSize, pageNo);
731
		return this.articleDao.queryPageForPublish(con, articleTitle, pageSize, pageNo);
733
	}
732
	}
734
	
733

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

764
	@Get
763
	@Get
765
	@Path("/pqself")
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
			articleTitle = "%" + articleTitle + "%";
768
			articleTitle = "%" + articleTitle + "%";
770
		}
769
		}
771
		return this.articleDao.queryPageForSelf(con, professorId, orgId, articleTitle, pageSize, pageNo);
770
		return this.articleDao.queryPageForSelf(con, professorId, orgId, articleTitle, pageSize, pageNo);
772
	}
771
	}
773
	
772

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

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

810
	@Get
810
	@Get
811
	@Path("/ralatePro")
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
		return this.articleProDao.query(con, articleId);
813
		return this.articleProDao.query(con, articleId);
814
	}
814
	}
815
	
815

816
	@Get
816
	@Get
817
	@Path("/ralateRes")
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
		return this.articleResDao.query(con, articleId);
819
		return this.articleResDao.query(con, articleId);
820
	}
820
	}
821

821
	@Get
822
	@Get
822
	@Path("/ralateOrg")
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
		return this.articleOrgDao.query(con, articleId);
825
		return this.articleOrgDao.query(con, articleId);
825
	}	
826
	
827
	
826
	}
827

828
	@Get
828
	@Get
829
	@Path("/ralateArticles")
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
		String[] ids = this.articleDao.queryArticleIdWithSameKeyWord(con, articleId, rows);
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
	@Path("/byShareId")
917
	@Path("/byShareId")
863
	@Get
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
		return this.articleDao.query(con, id);
920
		return this.articleDao.query(con, id);
866
	}
921
	}
867

922


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

20
import com.ekexiu.portal.po.PaperAgree;
20
import com.ekexiu.portal.po.PaperAgree;
21
import com.ekexiu.portal.po.PaperAuthor;
21
import com.ekexiu.portal.po.PaperAuthor;
22
import com.ekexiu.portal.po.Ppaper;
22
import com.ekexiu.portal.po.Ppaper;
23
import com.ekexiu.portal.po.Ppatent;
23
import com.ekexiu.portal.pojo.AssedPaper;
24
import com.ekexiu.portal.pojo.AssedPaper;
24

25

25
@Path("/ppaper")
26
@Path("/ppaper")
192
		this.paperAgreeDao.insert(con, pa);		
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
	@Get
202
	@Get
202
	@Path("/agree")
203
	@Path("/agree")
208
	public int agreeCount(@JdbcConn(false) Connection con,String id)throws SQLException{
209
	public int agreeCount(@JdbcConn(false) Connection con,String id)throws SQLException{
209
		return this.paperAgreeDao.query(con,id);
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
import org.jfw.apt.web.annotation.param.JdbcConn;
14
import org.jfw.apt.web.annotation.param.JdbcConn;
15
import org.jfw.util.PageQueryResult;
15
import org.jfw.util.PageQueryResult;
16

16

17
import com.ekexiu.portal.dao.PaperAuthorDao;
17
import com.ekexiu.portal.dao.PatentAgreeDao;
18
import com.ekexiu.portal.dao.PatentAgreeDao;
18
import com.ekexiu.portal.dao.PatentAuthorDao;
19
import com.ekexiu.portal.dao.PatentAuthorDao;
19
import com.ekexiu.portal.dao.PpatentDao;
20
import com.ekexiu.portal.dao.PpatentDao;
21
import com.ekexiu.portal.po.PaperAuthor;
20
import com.ekexiu.portal.po.PatentAgree;
22
import com.ekexiu.portal.po.PatentAgree;
21
import com.ekexiu.portal.po.PatentAuthor;
23
import com.ekexiu.portal.po.PatentAuthor;
22
import com.ekexiu.portal.po.Ppatent;
24
import com.ekexiu.portal.po.Ppatent;
185
		this.patentAgreeDao.insert(con, pa);		
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
	@Get
196
	@Get
195
	@Path("/agree")
197
	@Path("/agree")
201
	public int agreeCount(@JdbcConn(false) Connection con,String id)throws SQLException{
203
	public int agreeCount(@JdbcConn(false) Connection con,String id)throws SQLException{
202
		return this.patentAgreeDao.query(con,id);
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
import java.math.BigDecimal;
4
import java.math.BigDecimal;
5
import java.net.URLEncoder;
5
import java.net.URLEncoder;
6
import java.sql.Connection;
6
import java.sql.Connection;
7
import java.sql.PreparedStatement;
8
import java.sql.ResultSet;
7
import java.sql.SQLException;
9
import java.sql.SQLException;
8
import java.text.DecimalFormat;
10
import java.text.DecimalFormat;
11
import java.util.ArrayList;
9
import java.util.Collections;
12
import java.util.Collections;
13
import java.util.HashMap;
10
import java.util.List;
14
import java.util.List;
15
import java.util.Map;
11

16

12
import org.jfw.apt.annotation.Autowrie;
17
import org.jfw.apt.annotation.Autowrie;
13
import org.jfw.apt.annotation.DefaultValue;
18
import org.jfw.apt.annotation.DefaultValue;
22
import org.jfw.apt.web.annotation.param.RequestBody;
27
import org.jfw.apt.web.annotation.param.RequestBody;
23
import org.jfw.util.PageQueryResult;
28
import org.jfw.util.PageQueryResult;
24
import org.jfw.util.StringUtil;
29
import org.jfw.util.StringUtil;
30
import org.jfw.util.jdbc.JdbcUtil;
25

31

26
import com.ekexiu.portal.dao.ArticleDao;
32
import com.ekexiu.portal.dao.ArticleDao;
27
import com.ekexiu.portal.dao.HonorDao;
33
import com.ekexiu.portal.dao.HonorDao;
39
import com.ekexiu.portal.dao.ResourceDao;
45
import com.ekexiu.portal.dao.ResourceDao;
40
import com.ekexiu.portal.dao.UserDao;
46
import com.ekexiu.portal.dao.UserDao;
41
import com.ekexiu.portal.dao.WatchDao;
47
import com.ekexiu.portal.dao.WatchDao;
42
import com.ekexiu.portal.po.Article;
43
import com.ekexiu.portal.po.Professor;
48
import com.ekexiu.portal.po.Professor;
44
import com.ekexiu.portal.po.Resource;
49
import com.ekexiu.portal.po.Resource;
45
import com.ekexiu.portal.po.User;
50
import com.ekexiu.portal.po.User;
749
		}
754
		}
750
		return Collections.<Professor>emptyList();
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
//	@Get
794
//	@Get