jiapeng 7 years ago
parent
commit
e7a1b4f547

+ 5 - 0
src/main/java/com/ekexiu/portal/cms/ContentType.java

@ -0,0 +1,5 @@
1
package com.ekexiu.portal.cms;
2

3
public enum ContentType {
4
	Article,Paper,Patent
5
}

+ 18 - 0
src/main/java/com/ekexiu/portal/cms/Node.java

@ -0,0 +1,18 @@
1
package com.ekexiu.portal.cms;
2

3
public class Node {
4
	private ContentType type;
5
	private Object key;
6
	public ContentType getType() {
7
		return type;
8
	}
9
	public void setType(ContentType type) {
10
		this.type = type;
11
	}
12
	public Object getKey() {
13
		return key;
14
	}
15
	public void setKey(Object key) {
16
		this.key = key;
17
	}
18
}

+ 230 - 22
src/main/java/com/ekexiu/portal/cms/TemplateService.java

@ -7,10 +7,30 @@ import java.io.OutputStream;
7 7
import java.io.OutputStreamWriter;
8 8
import java.io.Reader;
9 9
import java.io.StringReader;
10
import java.sql.Connection;
11
import java.sql.SQLException;
12
import java.util.HashMap;
10 13
import java.util.Map;
14
import java.util.Queue;
15
import java.util.concurrent.ConcurrentLinkedQueue;
11 16

17
import javax.sql.DataSource;
18

19
import org.jfw.apt.annotation.Autowrie;
12 20
import org.jfw.apt.web.annotation.Path;
21
import org.jfw.apt.web.annotation.operate.Get;
22
import org.jfw.apt.web.annotation.operate.Post;
13 23
import org.jfw.util.ConstData;
24
import org.jfw.util.json.JsonService;
25
import org.jfw.util.log.LogFactory;
26
import org.jfw.util.log.Logger;
27

28
import com.ekexiu.portal.dao.ArticleDao;
29
import com.ekexiu.portal.dao.PpaperDao;
30
import com.ekexiu.portal.dao.PpatentDao;
31
import com.ekexiu.portal.po.Article;
32
import com.ekexiu.portal.po.Ppaper;
33
import com.ekexiu.portal.po.Ppatent;
14 34

15 35
import freemarker.cache.TemplateLoader;
16 36
import freemarker.template.Configuration;
@ -20,9 +40,66 @@ import freemarker.template.TemplateExceptionHandler;
20 40

21 41
@Path("/cms")
22 42
public class TemplateService {
23
	
43
	private static final Logger log = LogFactory.getLog(TemplateService.class);
44

45
	private final Queue<Node> queue = new ConcurrentLinkedQueue<Node>();
46

47
	@SuppressWarnings("unused")
24 48
	private File source;
25
	private Configuration cfg =  new Configuration(Configuration.VERSION_2_3_26);
49

50
	private Configuration cfg = new Configuration(Configuration.VERSION_2_3_26);
51

52
	private long rate = 10000;
53

54
	@Autowrie
55
	private ArticleDao articleDao;
56
	@Autowrie
57
	private PpaperDao ppaperDao;
58
	@Autowrie
59
	private PpatentDao ppatentDao;
60

61
	private File dir;
62

63
	public File getDir() {
64
		return dir;
65
	}
66

67
	public void setDir(File dir) {
68
		this.dir = dir;
69
	}
70

71
	public ArticleDao getArticleDao() {
72
		return articleDao;
73
	}
74

75
	public void setArticleDao(ArticleDao articleDao) {
76
		this.articleDao = articleDao;
77
	}
78

79
	public PpaperDao getPpaperDao() {
80
		return ppaperDao;
81
	}
82

83
	public void setPpaperDao(PpaperDao ppaperDao) {
84
		this.ppaperDao = ppaperDao;
85
	}
86

87
	public PpatentDao getPpatentDao() {
88
		return ppatentDao;
89
	}
90

91
	public void setPpatentDao(PpatentDao ppatentDao) {
92
		this.ppatentDao = ppatentDao;
93
	}
94

95
	public long getRate() {
96
		return rate;
97
	}
98

99
	public void setRate(long rate) {
100
		this.rate = rate;
101
	}
102

26 103
	public void setSource(File source) {
27 104
		this.source = source;
28 105
		try {
@ -32,20 +109,20 @@ public class TemplateService {
32 109
			this.cfg.setTemplateLoader(new TemplateLoader() {
33 110
				@Override
34 111
				public Reader getReader(Object templateSource, String encoding) throws IOException {
35
					StringReader reader = new StringReader("TemplateService'source is invalid dir,so "+templateSource.toString()+" can't read");
112
					StringReader reader = new StringReader("TemplateService'source is invalid dir,so " + templateSource.toString() + " can't read");
36 113
					return reader;
37 114
				}
38
				
115

39 116
				@Override
40 117
				public long getLastModified(Object templateSource) {
41 118
					return 0;
42 119
				}
43
				
120

44 121
				@Override
45 122
				public Object findTemplateSource(String name) throws IOException {
46 123
					return name;
47 124
				}
48
				
125

49 126
				@Override
50 127
				public void closeTemplateSource(Object templateSource) throws IOException {
51 128
				}
@ -53,15 +130,18 @@ public class TemplateService {
53 130
		}
54 131
		cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
55 132
	}
56
	
57
	
58
	public void genCnt(String templateName,File dest,Map<String,Object> root) throws IOException, TemplateException{
59
		if(dest.exists()){
60
			if(!dest.delete()){
61
				throw new IOException("delete file["+dest.getAbsolutePath()+"] error");
133

134
	public void genCnt(String templateName, File dest, Map<String, Object> root) throws IOException, TemplateException {
135
		if (dest.exists()) {
136
			if (!dest.delete()) {
137
				throw new IOException("delete file[" + dest.getAbsolutePath() + "] error");
62 138
			}
63 139
		}
64
		Template template = this.cfg.getTemplate(templateName,"UTF-8");
140
		File parent = dest.getParentFile();
141
		if(!parent.exists()){
142
			parent.mkdirs();
143
		}
144
		Template template = this.cfg.getTemplate(templateName, "UTF-8");
65 145
		OutputStream out = new FileOutputStream(dest);
66 146
		try {
67 147
			template.process(root, new OutputStreamWriter(out, ConstData.UTF8));
@ -70,15 +150,143 @@ public class TemplateService {
70 150
			out.close();
71 151
		}
72 152
	}
73
	
74
	
75
	
76 153

77
	
78
	
79
	
80
	
81
	
82
	
154
	public void push(ContentType type, Object key) {
155
		Node node = new Node();
156
		node.setType(type);
157
		node.setKey(key);
158
		this.queue.add(node);
159
	}
160

161
	@Get
162
	@Post
163
	@Path()
164
	public void push(String t, String k) {
165
		ContentType type = null;
166
		try {
167
			type = ContentType.valueOf(t);
168
		} catch (Throwable thr) {
169
		}
170
		if (type != null) {
171
			this.push(type, k);
172
		}
173
	}
174

175
	public void handle(DataSource ds) {
176
		Connection con;
177
		try {
178
			con = ds.getConnection();
179
		} catch (SQLException e1) {
180
			return;
181
		}
182
		try {
183
			for (;;) {
184
				if (!this.handle(con))
185
					break;
186
			}
187
		} finally {
188
			if (con != null) {
189
				try {
190
					con.close();
191
				} catch (Exception e) {
192
				}
193
			}
194
		}
195

196
	}
197

198
	public boolean handle(Connection con) {
199
		Node node = this.queue.peek();
200
		if (node == null)
201
			return false;
202
		try {
203
			ContentType type = node.getType();
204
			Object key = node.getKey();
205
			if (type != null) {
206
				switch (type) {
207
				case Article:
208
					this.staticArticle(con, key);
209
					break;
210
				case Paper:
211
					this.staticPaper(con, key);
212
					break;
213
				case Patent:
214
					this.staticPatent(con, key);
215
					break;
216
				default:
217
					break;
218
				}
219
			}
220
		} finally {
221
			if (node != null) {
222
				this.queue.poll();
223
			}
224
		}
225
		return true;
226
	}
227

228
	private void staticArticle(Connection con, Object key) {
229
		try {
230
			Article article = articleDao.queryOne(con, (String) key);
231
			if (article == null)
232
				return;
233
			String dir = article.getCreateTime().substring(0, 8);
234
			File file = new File(this.dir, dir + "/a/" + article.getShareId() + ".html");
235
			if (file.exists()) {
236
				file.delete();
237
			}
238
			Map<String, Object> data = new HashMap<String, Object>();
239
			data.put("data", article);
240
			data.put("jsonData", JsonService.toJson(article));
241
			if (article.getStatus().equals("1")) {
242
				this.genCnt("article.html", file, data);
243
			}
244
		} catch (Exception e) {
245
			log.error("static article[" + key + "]error", e);
246
		}
247
	}
248

249
	private void staticPaper(Connection con, Object key) {
250
		try {
251
			Ppaper page = this.ppaperDao.query(con, (String) key);
252
			if (page == null)
253
				return;
254
			String dir = page.getCreateTime().substring(0, 8);
255
			File file = new File(this.dir, dir + "/p/" + page.getShareId() + ".html");
256
			if (file.exists()) {
257
				file.delete();
258
			}
259
			Map<String, Object> data = new HashMap<String, Object>();
260
			data.put("data", page);
261
			data.put("jsonData", JsonService.toJson(page));
262
			this.genCnt("paper.html", file, data);
263
		} catch (Exception e) {
264
			log.error("static paper[" + key + "]error", e);
265
		}
266
	}
267

268
	private void staticPatent(Connection con, Object key) {
269
		try {
270
			Ppatent page = this.ppatentDao.query(con, (String) key);
271
			if (page == null)
272
				return;
273
			String dir = page.getCreateTime().substring(0, 8);
274
			File file = new File(this.dir, dir + "/p/" + page.getShareId() + ".html");
275
			if (file.exists()) {
276
				file.delete();
277
			}
278
			Map<String, Object> data = new HashMap<String, Object>();
279
			data.put("data", page);
280
			data.put("jsonData", JsonService.toJson(page));
281
			this.genCnt("patent.html", file, data);
282
		} catch (Exception e) {
283
			log.error("static patent[" + key + "]error", e);
284
		}
285
	}
286

287
	public static void main(String[] args) throws Exception {
288
		System.out.println(ContentType.valueOf("Article"));
289

290
	}
83 291

84 292
}

+ 47 - 31
src/main/java/com/ekexiu/portal/job/TaskJob.java

@ -7,57 +7,65 @@ import java.util.Date;
7 7
import java.util.concurrent.ScheduledExecutorService;
8 8
import java.util.concurrent.TimeUnit;
9 9

10
import javax.sql.DataSource;
11

10 12
import org.jfw.apt.annotation.Bean;
11 13
import org.jfw.util.bean.AfterBeanFactory;
12 14
import org.jfw.util.bean.BeanFactory;
13 15
import org.jfw.util.context.JfwAppContext;
14 16

17
import com.ekexiu.portal.cms.TemplateService;
15 18
import com.ekexiu.portal.service.WeixinService;
16 19
import com.ekexiu.push.service.PushService;
17 20

18 21
@Bean
19 22
public class TaskJob implements AfterBeanFactory {
20 23
	private ScheduledExecutorService service;
21
	
24
	private DataSource dataSource;
25

22 26
	@Override
23 27
	public void handle(BeanFactory bf) throws Throwable {
24
	
28
		this.dataSource =(DataSource) bf.getBean("dataSource");
25 29
		ArticleTaskJobEntry atje = (ArticleTaskJobEntry) bf.getBean("com_ekexiu_portal_job_ArticleTaskJobEntry");
26 30
		TaskJobEntry tje = (TaskJobEntry) bf.getBean("com_ekexiu_portal_job_TaskJobEntry");
27 31
		ProScoreTaskJobEntry pstje = (ProScoreTaskJobEntry) bf.getBean("com_ekexiu_portal_job_ProScoreTaskJobEntry");
28
//		UserLogTaskJobEntry ultje = (UserLogTaskJobEntry) bf.getBean("com_ekexiu_portal_job_UserLogTaskJobEntry");
32
		// UserLogTaskJobEntry ultje = (UserLogTaskJobEntry)
33
		// bf.getBean("com_ekexiu_portal_job_UserLogTaskJobEntry");
29 34
		DictTaskJobEntry dtje = (DictTaskJobEntry) bf.getBean("com_ekexiu_portal_job_DictTaskJobEntry");
30 35
		HotKeyJobEntry hkje = (HotKeyJobEntry) bf.getBean("com_ekexiu_portal_job_HotKeyJobEntry");
31
		final WeixinService weixin =(WeixinService)bf.getBean("com_ekexiu_portal_service_WeixinService");
32
		final PushService pushService =(PushService)bf.getBean("com_ekexiu_push_service_PushService");
33
		
34
		DemandInvalidJob dij = (DemandInvalidJob)bf.getBean("com_ekexiu_portal_job_DemandInvalidJob");
35
		
36
		final WeixinService weixin = (WeixinService) bf.getBean("com_ekexiu_portal_service_WeixinService");
37
		final PushService pushService = (PushService) bf.getBean("com_ekexiu_push_service_PushService");
38

39
		final TemplateService templateService = (TemplateService) bf.getBean("com_ekexiu_portal_cms_TemplateService");
40

41
		DemandInvalidJob dij = (DemandInvalidJob) bf.getBean("com_ekexiu_portal_job_DemandInvalidJob");
42

36 43
		long delayTime = tje.getDelayTime();
37 44
		long task = getTimeMillis(tje.getTaskTime());
38 45
		long taskTime = task - System.currentTimeMillis();
39 46
		taskTime = taskTime > 0 ? taskTime : delayTime + taskTime;
40
		
41
        this.service = JfwAppContext.getScheduledExecutorService();
42
        // 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间  
43
        service.scheduleAtFixedRate(atje, 1, atje.getDelayTime(), TimeUnit.SECONDS);
47

48
		this.service = JfwAppContext.getScheduledExecutorService();
49
		// 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间
50
		service.scheduleAtFixedRate(atje, 1, atje.getDelayTime(), TimeUnit.SECONDS);
44 51
		service.scheduleAtFixedRate(tje, taskTime, delayTime, TimeUnit.MILLISECONDS);
45
		
52

46 53
		long pstjeTask = getTimeMillis(pstje.getTaskTime());
47 54
		long pstjeTaskTime = pstjeTask - System.currentTimeMillis();
48 55
		pstjeTaskTime = pstjeTaskTime > 0 ? pstjeTaskTime : pstjeTaskTime + pstje.getDelayTime();
49 56
		service.scheduleAtFixedRate(pstje, pstjeTaskTime, pstje.getDelayTime(), TimeUnit.MILLISECONDS);
50
//		service.scheduleAtFixedRate(ultje, taskTime, delayTime, TimeUnit.MILLISECONDS);
57
		// service.scheduleAtFixedRate(ultje, taskTime, delayTime,
58
		// TimeUnit.MILLISECONDS);
51 59
		service.scheduleAtFixedRate(dtje, 1, dtje.getDelayTime(), TimeUnit.SECONDS);
52
		
60

53 61
		long hkjeTask = getTimeMillis(hkje.getTaskTime());
54 62
		long hkjeTaskTime = hkjeTask - System.currentTimeMillis();
55 63
		hkjeTaskTime = hkjeTaskTime > 0 ? hkjeTaskTime : hkjeTaskTime + hkje.getDelayTime();
56 64
		service.scheduleAtFixedRate(hkje, hkjeTaskTime, hkje.getDelayTime(), TimeUnit.MILLISECONDS);
57
		if(hkjeTaskTime>300*1000){
65
		if (hkjeTaskTime > 300 * 1000) {
58 66
			service.submit(hkje);
59 67
		}
60
		
68

61 69
		service.scheduleAtFixedRate(new Runnable() {
62 70
			@Override
63 71
			public void run() {
@ -67,21 +75,29 @@ public class TaskJob implements AfterBeanFactory {
67 75
		service.scheduleAtFixedRate(new Runnable() {
68 76
			@Override
69 77
			public void run() {
70
				pushService.refresh();				
78
				pushService.refresh();
79
			}
80
		}, 0, 2, TimeUnit.SECONDS);
81
		service.scheduleAtFixedRate(dij, 0, 5, TimeUnit.MINUTES);
82
		service.scheduleWithFixedDelay(new Runnable() {
83
			@Override
84
			public void run() {
85
				templateService.handle(dataSource);
71 86
			}
72
		}, 0, 2,TimeUnit.SECONDS);		
73
		service.scheduleAtFixedRate(dij, 0, 5,TimeUnit.MINUTES);
87
		}, 0, templateService.getRate(), TimeUnit.MILLISECONDS);
88

74 89
	}
75
	private static long getTimeMillis(String time) {  
76
	    try {  
77
	        DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss");  
78
	        DateFormat dayFormat = new SimpleDateFormat("yy-MM-dd");  
79
	        Date curDate = dateFormat.parse(dayFormat.format(new Date()) + " " + time);  
80
	        return curDate.getTime();  
81
	    } catch (ParseException e) {  
82
	        e.printStackTrace();  
83
	    }  
84
	    return 0;  
90

91
	private static long getTimeMillis(String time) {
92
		try {
93
			DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
94
			DateFormat dayFormat = new SimpleDateFormat("yy-MM-dd");
95
			Date curDate = dateFormat.parse(dayFormat.format(new Date()) + " " + time);
96
			return curDate.getTime();
97
		} catch (ParseException e) {
98
			e.printStackTrace();
99
		}
100
		return 0;
85 101
	}
86
	
102

87 103
}

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

@ -28,6 +28,8 @@ import org.jfw.util.StringUtil;
28 28
import org.jfw.util.exception.JfwBaseException;
29 29
import org.jfw.util.io.IoUtil;
30 30

31
import com.ekexiu.portal.cms.ContentType;
32
import com.ekexiu.portal.cms.TemplateService;
31 33
import com.ekexiu.portal.dao.ArticleAgreeDao;
32 34
import com.ekexiu.portal.dao.ArticleDao;
33 35
import com.ekexiu.portal.dao.ArticleOrgDao;
@ -59,6 +61,7 @@ public class ArticleService {
59 61
	private int artMaxLen = 70;
60 62
	private static final String JPG = "jpg";
61 63
	public static final String MAX_MODIFYTIME = "9";
64

62 65
	@Autowrie
63 66
	private ArticleDao articleDao;
64 67
	@Autowrie
@ -90,6 +93,17 @@ public class ArticleService {
90 93
	@Autowrie
91 94
	private KeyWordService keyWordService;
92 95

96
	@Autowrie
97
	private TemplateService templateService;
98

99
	public TemplateService getTemplateService() {
100
		return templateService;
101
	}
102

103
	public void setTemplateService(TemplateService templateService) {
104
		this.templateService = templateService;
105
	}
106

93 107
	public KeyWordService getKeyWordService() {
94 108
		return keyWordService;
95 109
	}
@ -292,34 +306,9 @@ public class ArticleService {
292 306

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

317
	@Post
318
	@Path("/save")
319
	public String saveArticle(@JdbcConn(true) Connection con, Article article, @Nullable String[] professors, @Nullable String[] resources,
320
			@Nullable String[] orgs) throws SQLException, IOException, JfwBaseException {
321
		if (article.getArticleId() == null) {
322
			String articleId = StringUtil.buildUUID();
311
		try {
323 312
			if (article.getArticleImg() != null) {
324 313
				this.saveArtImg(article.getArticleImg(), articleId);
325 314
				article.setArticleImg(this.createDate() + "/" + articleId + "." + JPG);
@ -337,262 +326,344 @@ public class ArticleService {
337 326
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
338 327
			}
339 328
			this.articleDao.insert(con, article);
340
			this.keyWordService.refreshArticle(con, articleId, KeyWordService.splitKeyWord(article.getSubject()));
341
			if (professors != null) {
342
				for (String professor : professors) {
343
					ArticlePro articlePro = new ArticlePro();
344
					articlePro.setArticleId(articleId);
345
					articlePro.setProfessorId(professor);
346
					this.articleProDao.insert(con, articlePro);
347
				}
329
			con.commit();
330
			this.templateService.push(ContentType.Article, article.getArticleId());
331
		} catch (SQLException e) {
332
			try {
333
				con.rollback();
334
			} catch (SQLException ee) {
348 335
			}
349
			if (resources != null) {
350
				for (String resource : resources) {
351
					ArticleRes articleRes = new ArticleRes();
352
					articleRes.setArticleId(articleId);
353
					articleRes.setResourceId(resource);
354
					this.articleResDao.insert(con, articleRes);
336
			throw e;
337
		}
338

339
		return articleId;
340
	}
341

342
	@Post
343
	@Path("/save")
344
	public String saveArticle(@JdbcConn(false) Connection con, Article article, @Nullable String[] professors, @Nullable String[] resources,
345
			@Nullable String[] orgs) throws SQLException, IOException, JfwBaseException {
346
		String articleId = null;
347
		try {
348

349
			if (article.getArticleId() == null) {
350
				articleId = StringUtil.buildUUID();
351
				if (article.getArticleImg() != null) {
352
					this.saveArtImg(article.getArticleImg(), articleId);
353
					article.setArticleImg(this.createDate() + "/" + articleId + "." + JPG);
355 354
				}
356
			}
357
			if (orgs != null && orgs.length > 0) {
358
				for (String org : orgs) {
359
					ArticleOrg articleOrg = new ArticleOrg();
360
					articleOrg.setArticleId(articleId);
361
					articleOrg.setOrgId(org);
362
					this.articleOrgDao.insert(con, articleOrg);
355
				article.setArticleId(articleId);
356
				article.setArticleAgree(0);
357
				article.setPageViews(0);
358
				article.setStatus("1");
359
				article.setPublishTime(this.publishTime());
360
				if (article.getProfessorId() != null && article.getOrgId() == null) {
361
					article.setArticleType("1");
362
				} else if (article.getProfessorId() == null && article.getOrgId() != null) {
363
					article.setArticleType("2");
364
				} else {
365
					throw new JfwBaseException(-1, "错误参数:文章发布者ID");
363 366
				}
364
			}
365
			return articleId;
366
		} else if (article.getArticleId().trim().length() == 32) {
367
			if (article.getArticleImg() != null) {
368
				this.saveArtImg(article.getArticleImg(), article.getArticleId());
369
				article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
370
			}
371
			this.articleDao.update(con, article);
372
			this.articleDao.updatePublishTime(con, article.getArticleId(), "1", this.publishTime());
373
			this.keyWordService.refreshArticle(con, article.getArticleId(), KeyWordService.splitKeyWord(article.getSubject()));
374
			this.articleProDao.delete(con, article.getArticleId());
375
			this.articleResDao.delete(con, article.getArticleId());
376
			this.articleOrgDao.delete(con, article.getArticleId());
377
			if (professors != null) {
378
				for (String professor : professors) {
379
					ArticlePro articlePro = new ArticlePro();
380
					articlePro.setArticleId(article.getArticleId());
381
					articlePro.setProfessorId(professor);
382
					this.articleProDao.insert(con, articlePro);
367
				this.articleDao.insert(con, article);
368
				this.keyWordService.refreshArticle(con, articleId, KeyWordService.splitKeyWord(article.getSubject()));
369
				if (professors != null) {
370
					for (String professor : professors) {
371
						ArticlePro articlePro = new ArticlePro();
372
						articlePro.setArticleId(articleId);
373
						articlePro.setProfessorId(professor);
374
						this.articleProDao.insert(con, articlePro);
375
					}
383 376
				}
384
			}
385
			if (resources != null) {
386
				for (String resource : resources) {
387
					ArticleRes articleRes = new ArticleRes();
388
					articleRes.setArticleId(article.getArticleId());
389
					articleRes.setResourceId(resource);
390
					this.articleResDao.insert(con, articleRes);
377
				if (resources != null) {
378
					for (String resource : resources) {
379
						ArticleRes articleRes = new ArticleRes();
380
						articleRes.setArticleId(articleId);
381
						articleRes.setResourceId(resource);
382
						this.articleResDao.insert(con, articleRes);
383
					}
391 384
				}
392
			}
393
			if (orgs != null && orgs.length > 0) {
394
				for (String org : orgs) {
395
					ArticleOrg articleOrg = new ArticleOrg();
396
					articleOrg.setArticleId(article.getArticleId());
397
					articleOrg.setOrgId(org);
398
					this.articleOrgDao.insert(con, articleOrg);
385
				if (orgs != null && orgs.length > 0) {
386
					for (String org : orgs) {
387
						ArticleOrg articleOrg = new ArticleOrg();
388
						articleOrg.setArticleId(articleId);
389
						articleOrg.setOrgId(org);
390
						this.articleOrgDao.insert(con, articleOrg);
391
					}
399 392
				}
393
			} else if (article.getArticleId().trim().length() == 32) {
394
				articleId = article.getArticleId();
395
				if (article.getArticleImg() != null) {
396
					this.saveArtImg(article.getArticleImg(), article.getArticleId());
397
					article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
398
				}
399
				this.articleDao.update(con, article);
400
				this.articleDao.updatePublishTime(con, article.getArticleId(), "1", this.publishTime());
401
				this.keyWordService.refreshArticle(con, article.getArticleId(), KeyWordService.splitKeyWord(article.getSubject()));
402
				this.articleProDao.delete(con, article.getArticleId());
403
				this.articleResDao.delete(con, article.getArticleId());
404
				this.articleOrgDao.delete(con, article.getArticleId());
405
				if (professors != null) {
406
					for (String professor : professors) {
407
						ArticlePro articlePro = new ArticlePro();
408
						articlePro.setArticleId(article.getArticleId());
409
						articlePro.setProfessorId(professor);
410
						this.articleProDao.insert(con, articlePro);
411
					}
412
				}
413
				if (resources != null) {
414
					for (String resource : resources) {
415
						ArticleRes articleRes = new ArticleRes();
416
						articleRes.setArticleId(article.getArticleId());
417
						articleRes.setResourceId(resource);
418
						this.articleResDao.insert(con, articleRes);
419
					}
420
				}
421
				if (orgs != null && orgs.length > 0) {
422
					for (String org : orgs) {
423
						ArticleOrg articleOrg = new ArticleOrg();
424
						articleOrg.setArticleId(article.getArticleId());
425
						articleOrg.setOrgId(org);
426
						this.articleOrgDao.insert(con, articleOrg);
427
					}
428
				}
429
			} else {
430
				throw new JfwBaseException(-2, "bad parameter:articleId");
400 431
			}
401
			return article.getArticleId();
402
		} else {
403
			throw new JfwBaseException(-2, "bad parameter:articleId");
432
			con.commit();
433
			this.templateService.push(ContentType.Article, article.getArticleId());
434
		} catch (SQLException | IOException | JfwBaseException e) {
435
			try {
436
				con.rollback();
437
			} catch (SQLException ee) {
438
			}
439
			throw e;
404 440
		}
441
		return articleId;
405 442
	}
406 443

407 444
	@Post
408 445
	@Path("/draft")
409
	public String draft(@JdbcConn(true) Connection con, Article article, @Nullable String[] professors, @Nullable String[] resources, @Nullable String[] orgs)
446
	public String draft(@JdbcConn(false) Connection con, Article article, @Nullable String[] professors, @Nullable String[] resources, @Nullable String[] orgs)
410 447
			throws SQLException, IOException, JfwBaseException {
411
		if (article.getArticleId() == null) {
412
			String articleId = StringUtil.buildUUID();
413
			if (article.getArticleImg() != null) {
414
				this.saveArtImg(article.getArticleImg(), articleId);
415
				article.setArticleImg(this.createDate() + "/" + articleId + "." + JPG);
416
			}
417
			article.setArticleId(articleId);
418
			article.setArticleAgree(0);
419
			article.setPageViews(0);
420
			article.setStatus("0");
421
			if (article.getProfessorId() != null && article.getOrgId() == null) {
422
				article.setArticleType("1");
423
			} else if (article.getProfessorId() == null && article.getOrgId() != null) {
424
				article.setArticleType("2");
425
			} else {
426
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
427
			}
428
			this.articleDao.insert(con, article);
429
			this.keyWordService.refreshArticle(con, articleId, null);
430
			if (professors != null) {
431
				for (String professor : professors) {
432
					ArticlePro articlePro = new ArticlePro();
433
					articlePro.setArticleId(articleId);
434
					articlePro.setProfessorId(professor);
435
					this.articleProDao.insert(con, articlePro);
448

449
		String articleId = null;
450
		try {
451
			if (article.getArticleId() == null) {
452
				articleId = StringUtil.buildUUID();
453
				if (article.getArticleImg() != null) {
454
					this.saveArtImg(article.getArticleImg(), articleId);
455
					article.setArticleImg(this.createDate() + "/" + articleId + "." + JPG);
436 456
				}
437
			}
438
			if (resources != null) {
439
				for (String resource : resources) {
440
					ArticleRes articleRes = new ArticleRes();
441
					articleRes.setArticleId(articleId);
442
					articleRes.setResourceId(resource);
443
					this.articleResDao.insert(con, articleRes);
457
				article.setArticleId(articleId);
458
				article.setArticleAgree(0);
459
				article.setPageViews(0);
460
				article.setStatus("0");
461
				if (article.getProfessorId() != null && article.getOrgId() == null) {
462
					article.setArticleType("1");
463
				} else if (article.getProfessorId() == null && article.getOrgId() != null) {
464
					article.setArticleType("2");
465
				} else {
466
					throw new JfwBaseException(-1, "错误参数:文章发布者ID");
444 467
				}
445
			}
446
			if (orgs != null && orgs.length > 0) {
447
				for (String org : orgs) {
448
					ArticleOrg articleOrg = new ArticleOrg();
449
					articleOrg.setArticleId(articleId);
450
					articleOrg.setOrgId(org);
451
					this.articleOrgDao.insert(con, articleOrg);
468
				this.articleDao.insert(con, article);
469
				this.keyWordService.refreshArticle(con, articleId, null);
470
				if (professors != null) {
471
					for (String professor : professors) {
472
						ArticlePro articlePro = new ArticlePro();
473
						articlePro.setArticleId(articleId);
474
						articlePro.setProfessorId(professor);
475
						this.articleProDao.insert(con, articlePro);
476
					}
452 477
				}
453
			}
454
			return articleId;
455
		} else if (article.getArticleId().trim().length() == 32) {
456
			if (article.getArticleImg() != null) {
457
				this.saveArtImg(article.getArticleImg(), article.getArticleId());
458
				article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
459
			}
460
			this.articleDao.update(con, article);
461
			this.articleDao.updateStatus(con, article.getArticleId(), "0");
462
			this.keyWordService.refreshArticle(con, article.getArticleId(), null);
463
			this.articleProDao.delete(con, article.getArticleId());
464
			this.articleResDao.delete(con, article.getArticleId());
465
			this.articleOrgDao.delete(con, article.getArticleId());
466
			if (professors != null) {
467
				for (String professor : professors) {
468
					ArticlePro articlePro = new ArticlePro();
469
					articlePro.setArticleId(article.getArticleId());
470
					articlePro.setProfessorId(professor);
471
					this.articleProDao.insert(con, articlePro);
478
				if (resources != null) {
479
					for (String resource : resources) {
480
						ArticleRes articleRes = new ArticleRes();
481
						articleRes.setArticleId(articleId);
482
						articleRes.setResourceId(resource);
483
						this.articleResDao.insert(con, articleRes);
484
					}
472 485
				}
473
			}
474
			if (resources != null) {
475
				for (String resource : resources) {
476
					ArticleRes articleRes = new ArticleRes();
477
					articleRes.setArticleId(article.getArticleId());
478
					articleRes.setResourceId(resource);
479
					this.articleResDao.insert(con, articleRes);
486
				if (orgs != null && orgs.length > 0) {
487
					for (String org : orgs) {
488
						ArticleOrg articleOrg = new ArticleOrg();
489
						articleOrg.setArticleId(articleId);
490
						articleOrg.setOrgId(org);
491
						this.articleOrgDao.insert(con, articleOrg);
492
					}
480 493
				}
481
			}
482
			if (orgs != null && orgs.length > 0) {
483
				for (String org : orgs) {
484
					ArticleOrg articleOrg = new ArticleOrg();
485
					articleOrg.setArticleId(article.getArticleId());
486
					articleOrg.setOrgId(org);
487
					this.articleOrgDao.insert(con, articleOrg);
494
			} else if (article.getArticleId().trim().length() == 32) {
495
				articleId = article.getArticleId();
496
				if (article.getArticleImg() != null) {
497
					this.saveArtImg(article.getArticleImg(), article.getArticleId());
498
					article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
499
				}
500
				this.articleDao.update(con, article);
501
				this.articleDao.updateStatus(con, article.getArticleId(), "0");
502
				this.keyWordService.refreshArticle(con, article.getArticleId(), null);
503
				this.articleProDao.delete(con, article.getArticleId());
504
				this.articleResDao.delete(con, article.getArticleId());
505
				this.articleOrgDao.delete(con, article.getArticleId());
506
				if (professors != null) {
507
					for (String professor : professors) {
508
						ArticlePro articlePro = new ArticlePro();
509
						articlePro.setArticleId(article.getArticleId());
510
						articlePro.setProfessorId(professor);
511
						this.articleProDao.insert(con, articlePro);
512
					}
488 513
				}
514
				if (resources != null) {
515
					for (String resource : resources) {
516
						ArticleRes articleRes = new ArticleRes();
517
						articleRes.setArticleId(article.getArticleId());
518
						articleRes.setResourceId(resource);
519
						this.articleResDao.insert(con, articleRes);
520
					}
521
				}
522
				if (orgs != null && orgs.length > 0) {
523
					for (String org : orgs) {
524
						ArticleOrg articleOrg = new ArticleOrg();
525
						articleOrg.setArticleId(article.getArticleId());
526
						articleOrg.setOrgId(org);
527
						this.articleOrgDao.insert(con, articleOrg);
528
					}
529
				}
530
			} else {
531
				throw new JfwBaseException(-2, "bad parameter:articleId");
489 532
			}
490
			return article.getArticleId();
491
		} else {
492
			throw new JfwBaseException(-2, "bad parameter:articleId");
533
			con.commit();
534
			this.templateService.push(ContentType.Article, articleId);
535
		} catch (SQLException | IOException | JfwBaseException e) {
536
			try {
537
				con.rollback();
538
			} catch (SQLException ee) {
539
			}
540
			throw e;
493 541
		}
542
		return articleId;
494 543
	}
495 544

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

558
			if (professors != null) {
559
				for (String professor : professors) {
560
					ArticlePro articlePro = new ArticlePro();
561
					articlePro.setArticleId(article.getArticleId());
562
					articlePro.setProfessorId(professor);
563
					this.articleProDao.insert(con, articlePro);
580
				if (resources != null) {
581
					for (String resource : resources) {
582
						ArticleRes articleRes = new ArticleRes();
583
						articleRes.setArticleId(articleId);
584
						articleRes.setResourceId(resource);
585
						this.articleResDao.insert(con, articleRes);
586
					}
564 587
				}
565
			}
566
			if (resources != null) {
567
				for (String resource : resources) {
568
					ArticleRes articleRes = new ArticleRes();
569
					articleRes.setArticleId(article.getArticleId());
570
					articleRes.setResourceId(resource);
571
					this.articleResDao.insert(con, articleRes);
588
				if (orgs != null && orgs.length > 0) {
589
					for (String org : orgs) {
590
						ArticleOrg articleOrg = new ArticleOrg();
591
						articleOrg.setArticleId(articleId);
592
						articleOrg.setOrgId(org);
593
						this.articleOrgDao.insert(con, articleOrg);
594
					}
572 595
				}
573
			}
574
			if (orgs != null && orgs.length > 0) {
575
				for (String org : orgs) {
576
					ArticleOrg articleOrg = new ArticleOrg();
577
					articleOrg.setArticleId(article.getArticleId());
578
					articleOrg.setOrgId(org);
579
					this.articleOrgDao.insert(con, articleOrg);
596
			} else if (article.getArticleId().trim().length() == 32) {
597
				articleId = article.getArticleId();
598
				if (article.getArticleImg() != null) {
599
					this.saveArtImg(article.getArticleImg(), article.getArticleId());
600
					article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
601
				}
602
				this.articleDao.update(con, article);
603
				this.articleDao.updatePublishTime(con, article.getArticleId(), "2", article.getPublishTime());
604
				this.keyWordService.refreshArticle(con, article.getArticleId(), null);
605
				this.articleResDao.delete(con, article.getArticleId());
606
				this.articleProDao.delete(con, article.getArticleId());
607
				this.articleOrgDao.delete(con, article.getArticleId());
608

609
				if (professors != null) {
610
					for (String professor : professors) {
611
						ArticlePro articlePro = new ArticlePro();
612
						articlePro.setArticleId(article.getArticleId());
613
						articlePro.setProfessorId(professor);
614
						this.articleProDao.insert(con, articlePro);
615
					}
580 616
				}
617
				if (resources != null) {
618
					for (String resource : resources) {
619
						ArticleRes articleRes = new ArticleRes();
620
						articleRes.setArticleId(article.getArticleId());
621
						articleRes.setResourceId(resource);
622
						this.articleResDao.insert(con, articleRes);
623
					}
624
				}
625
				if (orgs != null && orgs.length > 0) {
626
					for (String org : orgs) {
627
						ArticleOrg articleOrg = new ArticleOrg();
628
						articleOrg.setArticleId(article.getArticleId());
629
						articleOrg.setOrgId(org);
630
						this.articleOrgDao.insert(con, articleOrg);
631
					}
632
				}
633
				return article.getArticleId();
634
			} else {
635
				throw new JfwBaseException(-2, "bad parameter:articleId");
581 636
			}
582
			return article.getArticleId();
583
		} else {
584
			throw new JfwBaseException(-2, "bad parameter:articleId");
637
			con.commit();
638
			this.templateService.push(ContentType.Article, articleId);
639
		} catch (SQLException | IOException | JfwBaseException e) {
640
			try {
641
				con.rollback();
642
			} catch (SQLException ee) {
643
			}
644
			throw e;
585 645
		}
646
		return articleId;
586 647
	}
587 648

588 649
	@Post
589 650
	@Path("/updateArt")
590
	public void update(@JdbcConn(true) Connection con, Article article) throws SQLException, JfwBaseException, IOException {
591
		if (article.getArticleImg() != null) {
592
			this.saveArtImg(article.getArticleImg(), article.getArticleId());
593
			article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
651
	public void update(@JdbcConn(false) Connection con, Article article) throws SQLException, JfwBaseException, IOException {
652
		try {
653
			if (article.getArticleImg() != null) {
654
				this.saveArtImg(article.getArticleImg(), article.getArticleId());
655
				article.setArticleImg(this.createDate() + "/" + article.getArticleId() + "." + JPG);
656
			}
657
			this.articleDao.update(con, article);
658
			con.commit();
659
			this.templateService.push(ContentType.Article, article.getArticleId());
660
		} catch (SQLException | IOException | JfwBaseException e) {
661
			try {
662
				con.rollback();
663
			} catch (SQLException ee) {
664
			}
665
			throw e;
594 666
		}
595
		this.articleDao.update(con, article);
596 667
	}
597 668

598 669
	@Post
@ -603,36 +674,76 @@ public class ArticleService {
603 674

604 675
	@Post
605 676
	@Path("/updateDraft")
606
	public void updateDraft(@JdbcConn(true) Connection con, String articleId) throws SQLException {
677
	public void updateDraft(@JdbcConn(false) Connection con, String articleId) throws SQLException {
607 678
		// 修改文章状态为草稿
608
		this.articleDao.updateStatus(con, articleId, "0");
609
		this.keyWordService.refreshArticle(con, articleId, null);
679
		try {
680
			this.articleDao.updateStatus(con, articleId, "0");
681
			this.keyWordService.refreshArticle(con, articleId, null);
682
			con.commit();
683
			this.templateService.push(ContentType.Article, articleId);
684
		} catch (SQLException e) {
685
			try {
686
				con.rollback();
687
			} catch (SQLException ee) {
688
			}
689
			throw e;
690
		}
610 691
	}
611 692

612 693
	@Post
613 694
	@Path("/publish")
614
	public void publish(@JdbcConn(true) Connection con, String articleId) throws SQLException {
695
	public void publish(@JdbcConn(false) Connection con, String articleId) throws SQLException {
615 696
		// 修改文章状态为发布
616
		this.articleDao.updateStatus(con, articleId, "1");
617
		Article a = this.articleDao.queryOne(con, articleId);
618
		if (a != null) {
619
			this.keyWordService.refreshArticle(con, articleId, KeyWordService.splitKeyWord(a.getSubject()));
697
		try {
698
			this.articleDao.updateStatus(con, articleId, "1");
699
			Article a = this.articleDao.queryOne(con, articleId);
700
			if (a != null) {
701
				this.keyWordService.refreshArticle(con, articleId, KeyWordService.splitKeyWord(a.getSubject()));
702
			}
703
			con.commit();
704
			this.templateService.push(ContentType.Article, articleId);
705
		} catch (SQLException e) {
706
			try {
707
				con.rollback();
708
			} catch (SQLException ee) {
709
			}
710
			throw e;
620 711
		}
621 712
	}
622 713

623 714
	@Post
624 715
	@Path("/deleteArticle")
625
	public void deleteArticle(@JdbcConn(true) Connection con, String articleId) throws SQLException {
716
	public void deleteArticle(@JdbcConn(false) Connection con, String articleId) throws SQLException {
626 717
		// 修改文章状态为删除
627
		this.articleDao.updateStatus(con, articleId, "3");
628
		this.keyWordService.refreshArticle(con, articleId, null);
718
		try {
719
			this.articleDao.updateStatus(con, articleId, "3");
720
			this.keyWordService.refreshArticle(con, articleId, null);
721
			con.commit();
722
			this.templateService.push(ContentType.Article, articleId);
723
		} catch (SQLException e) {
724
			try {
725
				con.rollback();
726
			} catch (SQLException ee) {
727
			}
728
			throw e;
729
		}
629 730
	}
630 731

631 732
	@Post
632 733
	@Path("/close")
633 734
	public void closeArticle(@JdbcConn(true) Connection con, String articleId) throws SQLException {
634 735
		// 修改文章状态为关闭
736
		try{
635 737
		this.articleDao.updateStatus(con, articleId, "4");
738
		con.commit();
739
		this.templateService.push(ContentType.Article,articleId);
740
		} catch (SQLException  e) {
741
			try {
742
				con.rollback();
743
			} catch (SQLException ee) {
744
			}
745
			throw e;
746
		}
636 747
	}
637 748

638 749
	@Post
@ -764,8 +875,8 @@ public class ArticleService {
764 875

765 876
	@Get
766 877
	@Path("/pqself")
767
	public PageQueryResult<SelfArticle> queryPageSelf(@JdbcConn Connection con, @Nullable String professorId, @Nullable String orgId, @Nullable String articleTitle,
768
			@DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
878
	public PageQueryResult<SelfArticle> queryPageSelf(@JdbcConn Connection con, @Nullable String professorId, @Nullable String orgId,
879
			@Nullable String articleTitle, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
769 880
		if (articleTitle != null) {
770 881
			articleTitle = "%" + articleTitle + "%";
771 882
		}
@ -855,7 +966,7 @@ public class ArticleService {
855 966

856 967
		return this.articleDao.limitQueryPublish(con, ids, rows);
857 968
	}
858
	
969

859 970
	@Get
860 971
	@Path("/byAssOrg")
861 972
	public List<Article> byAssOrg(@JdbcConn Connection con, String id, @DefaultValue("5") int rows) throws SQLException {
@ -873,6 +984,7 @@ public class ArticleService {
873 984

874 985
		return this.articleDao.limitQueryPublish(con, ids, rows);
875 986
	}
987

876 988
	@Get
877 989
	@Path("/byAssResource")
878 990
	public List<Article> byAssResource(@JdbcConn Connection con, String id, @DefaultValue("5") int rows) throws SQLException {
@ -896,23 +1008,25 @@ public class ArticleService {
896 1008
	public Article query(@JdbcConn Connection con, long id) throws SQLException {
897 1009
		return this.articleDao.query(con, id);
898 1010
	}
899
	
900
	
1011

901 1012
	@Path("/find")
902 1013
	@Get
903
	public PageQueryResult<Article> find(@JdbcConn Connection con,@DefaultValue("0") int col,@Nullable String[] exclude,@DefaultValue("20") int pageSize,@DefaultValue("1") int pageNo) throws SQLException{
904
			return this.articleDao.queryFind(con,col>0?col:null,exclude, pageSize, pageNo);
1014
	public PageQueryResult<Article> find(@JdbcConn Connection con, @DefaultValue("0") int col, @Nullable String[] exclude, @DefaultValue("20") int pageSize,
1015
			@DefaultValue("1") int pageNo) throws SQLException {
1016
		return this.articleDao.queryFind(con, col > 0 ? col : null, exclude, pageSize, pageNo);
905 1017
	}
1018

906 1019
	@Path("/lastestPublished")
907 1020
	@Get
908
	public List<Article> lastet(@JdbcConn Connection con,@Nullable String time,@DefaultValue("10") int rows) throws SQLException{
909
		if(time==null){
910
			time = DateUtil.formatDate(System.currentTimeMillis() - 7*24*60*60*1000)+"000000";
1021
	public List<Article> lastet(@JdbcConn Connection con, @Nullable String time, @DefaultValue("10") int rows) throws SQLException {
1022
		if (time == null) {
1023
			time = DateUtil.formatDate(System.currentTimeMillis() - 7 * 24 * 60 * 60 * 1000) + "000000";
911 1024
		}
912
		return this.articleDao.lasterByPublishTime(con,time,rows);		
1025
		return this.articleDao.lasterByPublishTime(con, time, rows);
913 1026
	}
914 1027

915
	public static void main(String[] args){
916
		System.out.println( DateUtil.formatDate(System.currentTimeMillis() - 7*24*60*60*1000));
1028
	public static void main(String[] args) {
1029
		System.out.println(DateUtil.formatDate(System.currentTimeMillis() - 7 * 24 * 60 * 60 * 1000));
917 1030
	}
1031

918 1032
}

+ 1 - 1
src/main/java/com/ekexiu/push/service/PushService.java

@ -61,7 +61,7 @@ public class PushService {
61 61
	private String appId = "TUdvbnxu1c97r6Fb6cUy57";
62 62
	private int timeout = 0;
63 63
	private boolean enable = false;
64
	private String tokenUrl = "http://192.168.2.233/ajax/push/token";
64
	private String tokenUrl = "http://192.168.3.233/ajax/push/token";
65 65
	private String lastLoadToken = null;
66 66

67 67
	private String token = null;

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

@ -273,4 +273,6 @@ com_ekexiu_portal_oauth_OAuthService.handlers-ref=oauthService_handlers
273 273
oauthService_handlers::map=java.util.HashMap
274 274
oauthService_handlers.map-key-1=weixin
275 275
oauthService_handlers.map-val-1-ref=com_ekexiu_portal_oauth_weixin_WeiXinHandler
276
com_ekexiu_push_service_PushService.enable::boolean=false
276
com_ekexiu_push_service_PushService.enable::boolean=false
277
com_ekexiu_portal_cms_TemplateService.source::java.io.File=/kexiu/www/html1/fw_template_r3254
278
com_ekexiu_portal_cms_TemplateService.dir::java.io.File=/kexiu/webdata1/shtml;

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

@ -273,4 +273,6 @@ com_ekexiu_portal_oauth_OAuthService.handlers-ref=oauthService_handlers
273 273
oauthService_handlers::map=java.util.HashMap
274 274
oauthService_handlers.map-key-1=weixin
275 275
oauthService_handlers.map-val-1-ref=com_ekexiu_portal_oauth_weixin_WeiXinHandler
276
com_ekexiu_push_service_PushService.enable::boolean=true
276
com_ekexiu_push_service_PushService.enable::boolean=true
277
com_ekexiu_portal_cms_TemplateService.source::java.io.File=/kexiu/www/html/fw_template_r3254
278
com_ekexiu_portal_cms_TemplateService.dir::java.io.File=/kexiu/webdata/shtml;

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

@ -275,4 +275,5 @@ com_ekexiu_push_service_PushService.enable::boolean=true
275 275
com_ekexiu_push_service_PushService.secret=QewoTEuuOGAkWnBKqrbfj8
276 276
com_ekexiu_push_service_PushService.appKey=xXqSF9Gmb69SG37XVT3lL2
277 277
com_ekexiu_push_service_PushService.appId=vGS5OBXtmV6SrDVJDQ8dGA
278
278
com_ekexiu_portal_cms_TemplateService.source::java.io.File=/kexiu/www/html/fw_template_r3254
279
com_ekexiu_portal_cms_TemplateService.dir::java.io.File=/kexiu/webdata/shtml;