jiapeng vor 7 Jahren
Ursprung
Commit
964ee4fbcb

+ 53 - 0
src/main/java/com/ekexiu/portal/found/Service.java

@ -0,0 +1,53 @@
1
package com.ekexiu.portal.found;
2

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

9
import org.jfw.apt.annotation.DefaultValue;
10
import org.jfw.apt.web.annotation.Path;
11
import org.jfw.apt.web.annotation.operate.Get;
12
import org.jfw.apt.web.annotation.param.JdbcConn;
13
import org.jfw.util.jdbc.JdbcUtil;
14
import org.jfw.util.jdbc.PreparedStatementConfig;
15

16
@Path("/found")
17
public class Service {
18
/**
19
 * 查询新发现(含提问)
20
 * @param con
21
 * @param time 下拉加载上一次返回的最后一条数据的tm,首次不传
22
 * @param id 下拉加载上一次返回的最后一条数据的id,首次不传
23
 * @param rows 下拉加载返回的数据条数,默认20
24
 * @param ex 排除的文章ID
25
 * @return [{ctype:"1:专家文章,2:企业文章  3, 提问"
26
 *                 id:"文章id 或  提问ID ",
27
 *                 uid:"专家ID 或 企业id 或 提问人ID ",
28
 *                 tm:"文章发布时间 或 提问时间,
29
 *                 num:0 ,//提问回答数
30
 *                 img:"图片",
31
 *                 col:0,//文章栏目
32
 *                  }....]
33
 * @throws SQLException
34
 */
35
	@Get
36
	@Path("/index")
37
	public List<Map<String,Object>> query(@JdbcConn Connection con,@DefaultValue("\"9\"") final String time,@DefaultValue("\"0\"") final String id,@DefaultValue("20") final int rows,final String ex)throws SQLException{
38
		return JdbcUtil.queryMaps(con, "SELECT * FROM 	( "+
39
		"SELECT ID id,'3' ctype,uid uid,title title,	last_reply_time tm,reply_count num,img img,null col	FROM question where state='1' UNION ALL "+
40
		"SELECT ARTICLE_ID id,	'1' ctype,professor_id uid,article_title title,publish_time tm,	0 num,article_img img,col_num col FROM article WHERE status = '1' AND article_type = '1' AND article_id <>? UNION ALL "+
41
		"SELECT ARTICLE_ID id,	'2' ctype,org_id uid,article_title title,publish_time tm,0 num,article_img img,col_num col FROM article WHERE status = '1' AND article_type = '2' AND article_id <>? 	) T "+
42
        "WHERE T.tm <= ? AND T.id > ? ORDER BY tm DESC LIMIT ?", new PreparedStatementConfig() {
43
			@Override
44
			public void config(PreparedStatement ps) throws SQLException {
45
				ps.setString(1,ex);
46
				ps.setString(2, ex);
47
				ps.setString(3, time);
48
				ps.setString(4, id);
49
				ps.setInt(5,rows);
50
			}
51
		});
52
	}
53
}

+ 6 - 6
src/main/java/com/ekexiu/portal/leavemsg/LeaveMsg.java

@ -23,7 +23,7 @@ public class LeaveMsg implements CreateTimeSupported,ModifyTimeSupported {
23 23
	private String createTime;
24 24
	private String modifyTime;
25 25
	private String state;
26
	private long  acceptCount;
26
	private long  agreeCount;
27 27
	
28 28
	/**
29 29
	 * id
@ -59,7 +59,7 @@ public class LeaveMsg implements CreateTimeSupported,ModifyTimeSupported {
59 59
		this.refId = refId;
60 60
	}
61 61
	/**
62
	 * 留言主体类型,1:文章   2:论文   3:专利      4:提问
62
	 * 留言主体类型,1:文章   2:论文   3:专利      4:回答
63 63
	 * @return
64 64
	 */
65 65
	@Column(DE.singleChar)
@ -141,10 +141,10 @@ public class LeaveMsg implements CreateTimeSupported,ModifyTimeSupported {
141 141
	 * @return
142 142
	 */
143 143
	@Column(DE.long_de)
144
	public long getAcceptCount() {
145
		return acceptCount;
144
	public long getAgreeCount() {
145
		return agreeCount;
146 146
	}
147
	public void setAcceptCount(long acceptCount) {
148
		this.acceptCount = acceptCount;
147
	public void setAgreeCount(long agreeCount) {
148
		this.agreeCount = agreeCount;
149 149
	}
150 150
}

+ 1 - 1
src/main/java/com/ekexiu/portal/leavemsg/LeaveMsgApRec.java

@ -9,7 +9,7 @@ import com.ekexiu.portal.basepo.CreateTimeSupported;
9 9

10 10
@Table
11 11
@PrimaryKey({"id","uid"})
12
public class LeaveMsgApRec  implements CreateTimeSupported{
12
public class LeaveMsgAgreeRec  implements CreateTimeSupported{
13 13

14 14
	private String id;
15 15
	private String uid;

+ 4 - 4
src/main/java/com/ekexiu/portal/leavemsg/LeaveMsgDao.java

@ -39,9 +39,9 @@ public interface LeaveMsgDao {
39 39

40 40
	@UpdateWith
41 41
	@From(LeaveMsg.class)
42
	@SetSentence("ACCEPT_COUNT = ACCEPT_COUNT + 1")
42
	@SetSentence("AGREE_COUNT = AGREE_COUNT + 1")
43 43
	@IncludeFixSet
44
	int incAccept(Connection con, String id) throws SQLException;
44
	int incAgree(Connection con, String id) throws SQLException;
45 45

46 46
	@LimitSelect
47 47
	@Where("STATE='1'")
@ -53,11 +53,11 @@ public interface LeaveMsgDao {
53 53
	LeaveMsg query(Connection con, String id) throws SQLException;
54 54

55 55
	@Insert
56
	int insert(Connection con, LeaveMsgApRec rec) throws SQLException;
56
	int insert(Connection con, LeaveMsgAgreeRec rec) throws SQLException;
57 57

58 58
	@Nullable
59 59
	@SelectOne
60
	LeaveMsgApRec queryAcceptRec(Connection con, String id, String uid) throws SQLException;
60
	LeaveMsgAgreeRec queryAgreeRec(Connection con, String id, String uid) throws SQLException;
61 61

62 62
	@LimitSelect
63 63
	@OrderBy("ORDER BY GREATE_TIME ASC,ID ASC")

+ 166 - 39
src/main/java/com/ekexiu/portal/leavemsg/Service.java

@ -21,11 +21,101 @@ import org.jfw.util.exception.JfwBaseException;
21 21
import org.jfw.util.jdbc.JdbcUtil;
22 22
import org.jfw.util.jdbc.PreparedStatementConfig;
23 23

24
import com.ekexiu.portal.dao.ArticleDao;
25
import com.ekexiu.portal.dao.PaperAuthorDao;
26
import com.ekexiu.portal.dao.PatentAuthorDao;
27
import com.ekexiu.portal.dao.PpaperDao;
28
import com.ekexiu.portal.dao.PpatentDao;
29
import com.ekexiu.portal.notify.NotifyService;
30
import com.ekexiu.portal.notify.NotifyType;
31
import com.ekexiu.portal.po.Article;
32
import com.ekexiu.portal.po.PaperAuthor;
33
import com.ekexiu.portal.po.PatentAuthor;
34
import com.ekexiu.portal.po.Ppaper;
35
import com.ekexiu.portal.po.Ppatent;
36
import com.ekexiu.portal.question.Answer;
37
import com.ekexiu.portal.question.Question;
38
import com.ekexiu.portal.question.QuestionDao;
39

24 40
@Path("/leavemsg")
25 41
public class Service {
26 42
	@Autowrie
27 43
	private LeaveMsgDao leaveMsgDao;
28 44

45
	@Autowrie
46
	private ArticleDao articleDao;
47

48
	@Autowrie
49
	private PpatentDao ppatentDao;
50
	@Autowrie
51
	private PpaperDao ppaperDao;
52
	@Autowrie
53
	private QuestionDao questionDao;
54

55
	@Autowrie
56
	private NotifyService notifyService;
57

58
	@Autowrie
59
	private PaperAuthorDao paperAuthorDao;
60
	@Autowrie
61
	private PatentAuthorDao patentAuthorDao;
62

63
	public PaperAuthorDao getPaperAuthorDao() {
64
		return paperAuthorDao;
65
	}
66

67
	public void setPaperAuthorDao(PaperAuthorDao paperAuthorDao) {
68
		this.paperAuthorDao = paperAuthorDao;
69
	}
70

71
	public PatentAuthorDao getPatentAuthorDao() {
72
		return patentAuthorDao;
73
	}
74

75
	public void setPatentAuthorDao(PatentAuthorDao patentAuthorDao) {
76
		this.patentAuthorDao = patentAuthorDao;
77
	}
78

79
	public ArticleDao getArticleDao() {
80
		return articleDao;
81
	}
82

83
	public void setArticleDao(ArticleDao articleDao) {
84
		this.articleDao = articleDao;
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 PpaperDao getPpaperDao() {
96
		return ppaperDao;
97
	}
98

99
	public void setPpaperDao(PpaperDao ppaperDao) {
100
		this.ppaperDao = ppaperDao;
101
	}
102

103
	public QuestionDao getQuestionDao() {
104
		return questionDao;
105
	}
106

107
	public void setQuestionDao(QuestionDao questionDao) {
108
		this.questionDao = questionDao;
109
	}
110

111
	public NotifyService getNotifyService() {
112
		return notifyService;
113
	}
114

115
	public void setNotifyService(NotifyService notifyService) {
116
		this.notifyService = notifyService;
117
	}
118

29 119
	public LeaveMsgDao getLeaveMsgDao() {
30 120
		return leaveMsgDao;
31 121
	}
@ -34,8 +124,67 @@ public class Service {
34 124
		this.leaveMsgDao = leaveMsgDao;
35 125
	}
36 126

37
	public String getSubjectTitle(Connection con, String type, String id) throws SQLException {
38
		return null;
127
	// 1:文章 2:论文 3:专利 4:回答
128
	public void notify(Connection con, String type, String id, String reciver, String uid, String uname, String lid,boolean agree, List<Runnable> runs)
129
			throws SQLException, JfwBaseException {
130
		if (type.equals("1")) {
131
			Article article = this.articleDao.queryOne(con, id);
132
			if (article == null) {
133
				throw new JfwBaseException(50000, "article[" + id + "] not found");
134
			}
135
			if (article.getArticleType().equals("1")) {
136
				if (reciver == null) {
137
					this.notifyService.notify(con, article.getProfessorId(), uid, uname, lid, article.getArticleTitle(), NotifyType.LEAVE_MSG_AT_ARTICLE, runs);
138
				} else {
139
					this.notifyService.notify(con, reciver, uid, uname, lid, article.getArticleTitle(),agree?NotifyType.AGREE_LEAVE_MSG_AT_ARTICLE: NotifyType.REPLY_LEAVE_MSG_AT_ARTICLE, runs);
140
				}
141
			}
142

143
		} else if (type.equals("2")) {
144
			Ppaper paper = this.ppaperDao.query(con, id);
145
			if (paper == null) {
146
				throw new JfwBaseException(50000, "paper[" + id + "] not found");
147
			}
148
			if (reciver == null) {
149
				for (PaperAuthor pa : this.paperAuthorDao.query(con, id)) {
150
					if (!pa.getProfessorId().startsWith("#")) {
151
						this.notifyService.notify(con, pa.getProfessorId(), uid, uname, lid, paper.getName(), NotifyType.LEAVE_MSG_AT_PAPER, runs);
152
					}
153
				}
154
			} else {
155
				this.notifyService.notify(con, reciver, uid, uname, lid, paper.getName(),agree?NotifyType.AGREE_LEAVE_MSG_AT_PAPER: NotifyType.REPLY_LEAVE_MSG_AT_PAPER, runs);
156
			}
157
		} else if (type.equals("3")) {
158
			Ppatent patent = this.ppatentDao.query(con, id);
159
			if (patent == null) {
160
				throw new JfwBaseException(50000, "patent[" + id + "] not found");
161
			}
162
			if (reciver == null) {
163
				for (PatentAuthor pa : this.patentAuthorDao.query(con, id)) {
164
					if (!pa.getProfessorId().startsWith("#")) {
165
						this.notifyService.notify(con, pa.getProfessorId(), uid, uname, lid, patent.getName(), NotifyType.LEAVE_MSG_AT_PARENT, runs);
166
					}
167
				}
168
			} else {
169
				this.notifyService.notify(con, reciver, uid, uname, lid, patent.getName(),agree?NotifyType.AGREE_LEAVE_MSG_AT_PARENT: NotifyType.REPLY_LEAVE_MSG_AT_PARENT, runs);
170
			}
171
		} else if (type.equals("4")) {
172
			Answer a = this.questionDao.queryAnswer(con, id);
173
			if(a ==null){
174
				throw new JfwBaseException(50000, "answer[" + id + "] not found");
175
			}
176
			Question q = this.questionDao.query(con, a.getQid());
177
			if (q == null) {
178
				throw new JfwBaseException(50000, "answer[" + id + "]'question not found");
179
			}
180
			if (reciver == null) {
181
				this.notifyService.notify(con,a.getUid(), uid, uname, lid, q.getTitle(), NotifyType.LEAVE_MSG_AT_ANSWER, runs);
182
			} else {
183
				this.notifyService.notify(con, reciver, uid, uname, lid, q.getTitle(),agree?NotifyType.AGREE_LEAVE_MSG_AT_ANSWER: NotifyType.REPLY_LEAVE_MSG_AT_ANSWER, runs);
184
			}
185
		} else {
186
			throw new IllegalArgumentException();
187
		}
39 188
	}
40 189

41 190
	/**
@ -51,27 +200,22 @@ public class Service {
51 200
	 * @param runs
52 201
	 * @return
53 202
	 * @throws SQLException
203
	 * @throws JfwBaseException
54 204
	 */
55 205
	@Path()
56 206
	@Post
57 207
	public String save(@JdbcConn(true) Connection con,
58 208
			@RequestParam(fields = { @FieldParam(value = "cnt", valueClass = String.class), @FieldParam(value = "refId", valueClass = String.class),
59 209
					@FieldParam(value = "refType", valueClass = String.class), @FieldParam(value = "sender", valueClass = String.class) }) LeaveMsg msg,
60
			String title, String uname, @AfterCommit List<Runnable> runs) throws SQLException {
61

210
			 String uname, @AfterCommit List<Runnable> runs) throws SQLException, JfwBaseException {
62 211
		String id = StringUtil.buildUUID();
63 212
		msg.setId(id);
64 213
		msg.setTop(id);
65 214
		msg.setState("1");
66 215
		msg.setParent(null);
67
		msg.setAcceptCount(0);
68
		runs.add(new Runnable() {
69
			@Override
70
			public void run() {
71
				// TODO: send notify
72
			}
73
		});
216
		msg.setAgreeCount(0);
74 217
		leaveMsgDao.insert(con, msg);
218
		this.notify(con, msg.getRefType(), msg.getRefId(), null, msg.getSender(), uname, id,false, runs);
75 219
		return id;
76 220
	}
77 221

@ -96,7 +240,7 @@ public class Service {
96 240
	 */
97 241
	@Path("/reply")
98 242
	@Post
99
	public String reply(@JdbcConn(true) Connection con, String cnt, String id, String uid, @Nullable String title, String uname,
243
	public String reply(@JdbcConn(true) Connection con, String cnt, String id, String uid, String uname,
100 244
			@AfterCommit List<Runnable> runs) throws SQLException, JfwBaseException {
101 245
		final LeaveMsg msg = leaveMsgDao.query(con, id);
102 246
		if (msg == null)
@ -111,20 +255,8 @@ public class Service {
111 255
		msg.setState("1");
112 256
		msg.setCnt(cnt);
113 257
		msg.setId(nid);
114
		msg.setAcceptCount(0);
115
		if (title == null) {
116
			title = this.getSubjectTitle(con, msg.getRefType(), msg.getRefId());
117
			if (title == null || title.isEmpty()) {
118
				title = "<<丢失的数据>>";
119
			}
120
		}
121
		runs.add(new Runnable() {
122
			@Override
123
			public void run() {
124
				// TODO: send notify
125
			}
126
		});
127 258
		leaveMsgDao.insert(con, msg);
259
		this.notify(con, msg.getRefType(), msg.getRefId(), msg.getReciver(), uid, uname, id,false, runs);
128 260
		return nid;
129 261
	}
130 262

@ -209,14 +341,14 @@ public class Service {
209 341
	 * @throws JfwBaseException
210 342
	 */
211 343
	@Post
212
	@Path("/accept")
213
	public void accept(@JdbcConn(true) Connection con, String id, String uid, String uname, @AfterCommit List<Runnable> runs)
344
	@Path("/agree")
345
	public void agree(@JdbcConn(true) Connection con, String id, String uid, String uname, @AfterCommit List<Runnable> runs)
214 346
			throws SQLException, JfwBaseException {
215 347
		LeaveMsg msg = leaveMsgDao.query(con, id);
216 348
		if (msg == null) {
217 349
			throw new JfwBaseException(50000, "leave message[id:" + id + "] not found");
218 350
		}
219
		LeaveMsgApRec lmar = new LeaveMsgApRec();
351
		LeaveMsgAgreeRec lmar = new LeaveMsgAgreeRec();
220 352
		lmar.setId(id);
221 353
		lmar.setUid(uid);
222 354
		try {
@ -224,17 +356,12 @@ public class Service {
224 356
		} catch (SQLException e) {
225 357
			if ("23505".equals(e.getSQLState())) {
226 358
				con.rollback();
227
				throw new JfwBaseException(50001, "leave message  duplicate accept");
359
				throw new JfwBaseException(50001, "leave message  duplicate agree");
228 360
			}
229 361
			throw e;
230 362
		}
231
		if (leaveMsgDao.incAccept(con, id) > 0) {
232
			runs.add(new Runnable() {
233
				@Override
234
				public void run() {
235
					// TODO: send notify
236
				}
237
			});
363
		if (leaveMsgDao.incAgree(con, id) > 0) {
364
			this.notify(con, msg.getRefType(), msg.getRefId(), msg.getSender(), uid, uname, msg.getId(), true, runs);
238 365
		}
239 366
	}
240 367

@ -250,9 +377,9 @@ public class Service {
250 377
	 * @throws SQLException
251 378
	 */
252 379
	@Get
253
	@Path("/accept")
254
	public boolean accept(@JdbcConn Connection con, String id, String uid) throws SQLException {
255
		return null != leaveMsgDao.queryAcceptRec(con, id, uid);
380
	@Path("/agree")
381
	public boolean agree(@JdbcConn Connection con, String id, String uid) throws SQLException {
382
		return null != leaveMsgDao.queryAgreeRec(con, id, uid);
256 383
	}
257 384

258 385
	/**

+ 78 - 0
src/main/java/com/ekexiu/portal/notify/NotifyMsgCnt.java

@ -0,0 +1,78 @@
1
package com.ekexiu.portal.notify;
2

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

8
@Table
9
@PrimaryKey("id")
10
public class NotifyMsgCnt{
11

12
	private String id;
13
	private String cnt;
14
	private String reciver;
15
	private boolean readed;
16
	private String pid;
17
	private String uid;
18
	private String createTime;
19
	private int opType;
20
	@Column(DE.id_32)
21
	public String getId() {
22
		return id;
23
	}
24
	public void setId(String id) {
25
		this.id = id;
26
	}
27
	@Column(DE.text_de)
28
	public String getCnt() {
29
		return cnt;
30
	}
31
	public void setCnt(String cnt) {
32
		this.cnt = cnt;
33
	}
34
	@Column(DE.text_de)
35
	public String getReciver() {
36
		return reciver;
37
	}
38
	public void setReciver(String reciver) {
39
		this.reciver = reciver;
40
	}
41
	@Column(DE.boolean_de)
42
	public boolean isReaded() {
43
		return readed;
44
	}
45
	public void setReaded(boolean readed) {
46
		this.readed = readed;
47
	}
48
	@Column(DE.text_de)
49
	public String getPid() {
50
		return pid;
51
	}
52
	public void setPid(String pid) {
53
		this.pid = pid;
54
	}
55
	@Column(DE.text_de)
56
	public String getUid() {
57
		return uid;
58
	}
59
	public void setUid(String uid) {
60
		this.uid = uid;
61
	}
62
	@Column(DE.text_de)
63
	public String getCreateTime() {
64
		return createTime;
65
	}
66
	public void setCreateTime(String createTime) {
67
		this.createTime = createTime;
68
	}
69
	@Column(DE.int_de)
70
	public int getOpType() {
71
		return opType;
72
	}
73
	public void setOpType(int opType) {
74
		this.opType = opType;
75
	}
76

77
	
78
}

+ 52 - 0
src/main/java/com/ekexiu/portal/notify/NotifyMsgDao.java

@ -0,0 +1,52 @@
1
package com.ekexiu.portal.notify;
2

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

7
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.orm.annotation.dao.DAO;
9
import org.jfw.apt.orm.annotation.dao.method.From;
10
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
11
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
12
import org.jfw.apt.orm.annotation.dao.method.Where;
13
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
14
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
15
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
16
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
17
import org.jfw.apt.orm.annotation.dao.param.GreaterThan;
18
import org.jfw.apt.orm.annotation.dao.param.GtEq;
19
import org.jfw.apt.orm.annotation.dao.param.LtEq;
20
import org.jfw.apt.orm.annotation.dao.param.Set;
21

22
@DAO
23
public interface NotifyMsgDao {
24

25
	@Insert
26
	int insert(Connection con,NotifyMsgIdx msg)throws SQLException;
27
	@Insert
28
	int insert(Connection con,NotifyMsgCnt msg)throws SQLException;
29
	@UpdateWith
30
	@From(NotifyMsgIdx.class)
31
	@SetSentence("UN_READ = UN_READ +1")
32
	int updateIdx(Connection con,@Set String lastCnt,@Set String lastTime,String reciver ) throws SQLException;
33
	
34
	@UpdateWith
35
	@From(NotifyMsgIdx.class)
36
	int decUnRead(Connection con,String reciver, @Set(" = UN_READ - ?") int unRead ) throws SQLException;
37
	
38
	@SelectOne
39
	@Nullable
40
	NotifyMsgIdx queryIdx(Connection con,String reciver)throws SQLException;
41
	
42
	
43
	@LimitSelect
44
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
45
	List<NotifyMsgCnt> queryCnt(Connection con,String reciver,@LtEq String createTime,@GreaterThan String id,int rows)throws SQLException;
46
	
47
	@UpdateWith
48
	@From(NotifyMsgCnt.class)
49
	@SetSentence("READED='1'")
50
	@Where("READED<>'1'")
51
	int readed(Connection con,String reciver ,@LtEq String createTime,@GtEq String id)throws SQLException; 
52
}

+ 44 - 0
src/main/java/com/ekexiu/portal/notify/NotifyMsgIdx.java

@ -0,0 +1,44 @@
1
package com.ekexiu.portal.notify;
2

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

8
@Table
9
@PrimaryKey("reciver")
10
public class NotifyMsgIdx {
11
	private String reciver;
12
	private String lastCnt;
13
	private String lastTime;
14
	private int unRead;
15
	@Column(DE.text_de)
16
	public String getReciver() {
17
		return reciver;
18
	}
19
	public void setReciver(String reciver) {
20
		this.reciver = reciver;
21
	}
22
	@Column(DE.text_de)
23
	public String getLastCnt() {
24
		return lastCnt;
25
	}
26
	public void setLastCnt(String lastCnt) {
27
		this.lastCnt = lastCnt;
28
	}
29
	@Column(DE.text_de)
30
	public String getLastTime() {
31
		return lastTime;
32
	}
33
	public void setLastTime(String lastTime) {
34
		this.lastTime = lastTime;
35
	}
36
	@Column(DE.int_de)
37
	public int getUnRead() {
38
		return unRead;
39
	}
40
	public void setUnRead(int unRead) {
41
		this.unRead = unRead;
42
	}
43
	
44
}

+ 100 - 0
src/main/java/com/ekexiu/portal/notify/NotifyService.java

@ -0,0 +1,100 @@
1
package com.ekexiu.portal.notify;
2

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

7
import org.jfw.apt.annotation.Autowrie;
8
import org.jfw.apt.annotation.DefaultValue;
9
import org.jfw.apt.web.annotation.Path;
10
import org.jfw.apt.web.annotation.operate.Get;
11
import org.jfw.apt.web.annotation.operate.Post;
12
import org.jfw.apt.web.annotation.param.JdbcConn;
13
import org.jfw.util.DateUtil;
14
import org.jfw.util.StringUtil;
15
import org.jfw.util.json.JsonService;
16

17
import com.ekexiu.portal.util.WebMsgSocketServlet;
18
import com.ekexiu.push.service.PushService;
19

20
@Path("/notify")
21
public class NotifyService {
22

23
	@Autowrie
24
	private NotifyMsgDao notifyMsgDao;
25
	@Autowrie
26
	private PushService pushService;
27

28
	public NotifyMsgDao getNotifyMsgDao() {
29
		return notifyMsgDao;
30
	}
31

32
	public void setNotifyMsgDao(NotifyMsgDao notifyMsgDao) {
33
		this.notifyMsgDao = notifyMsgDao;
34
	}
35

36
	public PushService getPushService() {
37
		return pushService;
38
	}
39

40
	public void setPushService(PushService pushService) {
41
		this.pushService = pushService;
42
	}
43

44
	public void notify(Connection con, final String rid, String uid, String uname, String pid, String pname, NotifyType type,List<Runnable> runs) throws SQLException {
45
		String time = DateUtil.formatDateTime(System.currentTimeMillis());
46
		String id = StringUtil.buildUUID();
47
		String tCnt = type.format(uname, pname);
48
		final NotifyMsgCnt cnt = new NotifyMsgCnt();
49
		cnt.setId(id);
50
		cnt.setCnt(tCnt);
51
		cnt.setCreateTime(time);
52
		cnt.setOpType(type.getType());
53
		cnt.setPid(pid);
54
		cnt.setReaded(false);
55
		cnt.setReciver(rid);
56
		cnt.setUid(uid);
57
		notifyMsgDao.insert(con, cnt);
58
		final NotifyMsgIdx idx = new NotifyMsgIdx();
59
		idx.setLastCnt(tCnt);
60
		idx.setLastTime(time);
61
		idx.setReciver(rid);
62
		idx.setUnRead(1);
63
		if (notifyMsgDao.updateIdx(con, tCnt, time, rid) < 1) {
64
			notifyMsgDao.insert(con, idx);
65
		}
66

67
		final Runnable ret = new Runnable() {
68
			public void run() {
69
				WebMsgSocketServlet.sendMessage(rid, JsonService.toJson(cnt));
70
				try {
71
					pushService.pushWithAlias("通知", "您收到了一条通知", "msgsend", rid);
72
				} catch (Throwable thr) {
73
				}
74
			}
75
		};
76
		runs.add(ret);
77
	}
78

79
	@Path("/idx")
80
	@Get
81
	public NotifyMsgIdx query(@JdbcConn Connection con, String id) throws SQLException {
82
		return notifyMsgDao.queryIdx(con, id);
83
	}
84

85
	@Path()
86
	@Get
87
	public List<NotifyMsgCnt> query(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String mid,
88
			@DefaultValue("20") int rows) throws SQLException {
89
		return notifyMsgDao.queryCnt(con, uid, time, mid, rows);
90
	}
91
	@Post
92
	@Path("/readed")
93
	public int read(@JdbcConn(true) Connection con,String uid,String time,String mid)throws SQLException{
94
		int num = this.notifyMsgDao.readed(con, uid,time, mid);
95
		if(num>0){
96
			this.notifyMsgDao.decUnRead(con, uid,num);
97
		}
98
		return num;
99
	}
100
}

+ 57 - 0
src/main/java/com/ekexiu/portal/notify/NotifyType.java

@ -0,0 +1,57 @@
1
package com.ekexiu.portal.notify;
2

3
public enum NotifyType {
4
	AGREE_LEAVE_MSG_AT_ANSWER("%s  点赞了您在回答 <span>%s</span> 下的留言",19, 2) ,
5
	AGREE_LEAVE_MSG_AT_PAPER("%s  点赞了您在论文 <span>%s</span> 下的留言",18, 2) ,
6
	AGREE_LEAVE_MSG_AT_PARENT("%s  点赞了您在专利 <span>%s</span> 下的留言",17, 2) ,
7
	AGREE_LEAVE_MSG_AT_ARTICLE("%s  点赞了您在文章 <span>%s</span> 下的留言",16, 2) ,
8
	REPLY_LEAVE_MSG_AT_ANSWER("%s  回复了您在回答 <span>%s</span> 下的留言",15, 2) ,
9
	REPLY_LEAVE_MSG_AT_PAPER("%s  回复了您在论文 <span>%s</span> 下的留言",14, 2) ,
10
	REPLY_LEAVE_MSG_AT_PARENT("%s  回复了您在专利 <span>%s</span> 下的留言",13, 2) ,
11
	REPLY_LEAVE_MSG_AT_ARTICLE("%s  回复了您在文章 <span>%s</span> 下的留言",12, 2) ,
12
	LEAVE_MSG_AT_ANSWER("%s  给您的回答 <span>%s</span> 留言了",11, 2) ,
13
	LEAVE_MSG_AT_PAPER("%s  给您的论文 <span>%s</span> 留言了",10, 2) ,
14
	LEAVE_MSG_AT_PARENT("%s  给您的专利 <span>%s</span> 留言了", 9, 2) ,
15
	LEAVE_MSG_AT_ARTICLE("%s  给您的文章 <span>%s</span> 留言了", 8, 2) ,
16
	AGREE_PAPER("%s 点赞了您的论文 <span>%s</span>", 7, 2) ,
17
	AGREE_PATENT("%s 点赞了您的专利 <span>%s</span>", 6, 2) ,
18
	INVITE_ANSWER("%s 邀请您回答问题 <span>%s</span>", 5, 2) ,
19
	ACCEPT_ANSWER("%s 点赞了您在问题 <span>%s</span> 下的回答", 4, 2) ,
20
	ANSWER_QUESTION("%s 回答了您的提问 <span>%s</span>", 3, 2) ,
21
	AGREE_ARTICLE("%s 点赞了您的文章 <span>%s</span>", 2, 2) ,
22
	AGREE_RESEARCH_AREA("%s 点赞了您的研究方向 <span>%s</span>", 1, 2) ,
23
	WATCH_USER("<span>%s</span> 关注了您", 0, 1);
24

25
	private String template;
26
	private int type;
27
	private int paramSize;
28

29
	NotifyType(String template, int type, int paramSize) {
30
		this.template = template;
31
		this.type = type;
32
		this.paramSize = paramSize;
33
	}
34

35
	public String getTemplate() {
36
		return template;
37
	}
38

39
	public int getType() {
40
		return type;
41
	}
42

43
	public String format(String user, String title) {
44
		return paramSize == 1 ? String.format(this.template, html(user)) : String.format(this.template, html(user), html(title));
45
	}
46

47
	private static String html(String html) {
48
		html = html.replaceAll("&", "&amp;");
49
		html = html.replace("\"", "&quot;"); // "
50
		html = html.replace("\t", "&nbsp;&nbsp;");// 替换跳格
51
		html = html.replace(" ", "&nbsp;");// 替换空格
52
		html = html.replace("<", "&lt;");
53
		html = html.replaceAll(">", "&gt;");
54
		return html;
55
	}
56

57
}

+ 5 - 5
src/main/java/com/ekexiu/portal/question/Answer.java

@ -19,7 +19,7 @@ public class Answer  implements CreateTimeSupported,ModifyTimeSupported{
19 19
	private String state;
20 20
	private String cnt;
21 21
	
22
	private long accept;
22
	private long agree;
23 23
	private long  ballot;
24 24
	private String createTime;
25 25
	private String modifyTime;
@ -82,11 +82,11 @@ public class Answer  implements CreateTimeSupported,ModifyTimeSupported{
82 82
	 * 点赞数量
83 83
	 */
84 84
	@Column(DE.long_de)
85
	public long getAccept() {
86
		return accept;
85
	public long getAgree() {
86
		return agree;
87 87
	}
88
	public void setAccept(long accept) {
89
		this.accept = accept;
88
	public void setAgree(long agree) {
89
		this.agree = agree;
90 90
	}
91 91
	/**
92 92
	 * 总数投票数

+ 1 - 1
src/main/java/com/ekexiu/portal/question/AnswerAcceptRec.java

@ -7,7 +7,7 @@ import org.jfw.apt.orm.core.enums.DE;
7 7

8 8
@PrimaryKey({"uid","aid"})
9 9
@Table
10
public class AnswerAcceptRec{
10
public class AnswerAgreeRec{
11 11

12 12
	private String uid;
13 13
	private String aid;

+ 16 - 7
src/main/java/com/ekexiu/portal/question/QuestionDao.java

@ -56,9 +56,18 @@ public interface QuestionDao {
56 56
	@SelectOne
57 57
	@Nullable
58 58
	Question query(Connection con, String id) throws SQLException;
59
	
60
	@SelectOne
61
	@Nullable
62
	Answer queryAnswer(Connection con,String id)throws SQLException;
59 63

60 64
	@SelectList
61 65
	List<Question> query(Connection con, @In String[] id) throws SQLException;
66
	
67
	@LimitSelect
68
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
69
	@Where("QID IN(SELECT ID FROM QUESTION WHERE STATE='1') AND STATE='1'")
70
	List<Answer> answer(Connection con,@LtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
62 71

63 72
	@LimitSelect
64 73
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
@ -78,24 +87,24 @@ public interface QuestionDao {
78 87
	List<Answer> byQes(Connection con, String qid, @LtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
79 88
	@LimitQuery
80 89
	@OrderBy("ORDER BY SCORE DESC,ID ASC")
81
	List<SortedAnswwer> byQes(Connection con, String qid, @SqlColumn(handlerClass = IntHandler.class, value = { "10000 * ACCEPT / BALLOT <= ?  " }) int score, @GreaterThan String id, int rows) throws SQLException;
90
	List<SortedAnswwer> byQes(Connection con, String qid, @SqlColumn(handlerClass = IntHandler.class, value = { "10000 * AGREE / BALLOT <= ?  " }) int score, @GreaterThan String id, int rows) throws SQLException;
82 91

83 92
	@Insert
84
	int insert(Connection con,AnswerAcceptRec aar)throws SQLException;
93
	int insert(Connection con,AnswerAgreeRec aar)throws SQLException;
85 94
	@UpdateWith
86
	@From(AnswerAcceptRec.class)
95
	@From(AnswerAgreeRec.class)
87 96
	@Where("FLAG<>'1'")
88 97
	@SetSentence("FLAG='1'")
89
	int accept(Connection con,String uid,String aid)throws SQLException;
98
	int agree(Connection con,String uid,String aid)throws SQLException;
90 99
	@UpdateWith
91
	@From(AnswerAcceptRec.class)
100
	@From(AnswerAgreeRec.class)
92 101
	@Where("FLAG='1'")
93 102
	@SetSentence("FLAG='0'")
94
	int unAccept(Connection con,String uid,String aid)throws SQLException;
103
	int unAgree(Connection con,String uid,String aid)throws SQLException;
95 104
	
96 105
	@UpdateWith
97 106
	@From(Answer.class)
98
	int update(Connection con,String id, @Set( " = ACCEPT +?" ) long accept,@Set("=BALLOT+?") long ballot)throws SQLException;
107
	int update(Connection con,String id, @Set( " = AGREE +?" ) long agree,@Set("=BALLOT+?") long ballot)throws SQLException;
99 108
	
100 109
	
101 110
	@Insert

+ 93 - 50
src/main/java/com/ekexiu/portal/question/Service.java

@ -31,6 +31,8 @@ import org.jfw.util.jdbc.PreparedStatementConfig;
31 31
import org.jfw.util.web.fileupload.Item;
32 32
import org.jfw.util.web.fileupload.UploadItemIterator;
33 33

34
import com.ekexiu.portal.notify.NotifyService;
35
import com.ekexiu.portal.notify.NotifyType;
34 36
import com.ekexiu.portal.util.SqlUtil;
35 37

36 38
@Path("/question")
@ -41,8 +43,19 @@ public class Service {
41 43
	@Autowrie
42 44
	private QuestionDao questionDao;
43 45

46
	@Autowrie
47
	private NotifyService notifyService;
48

44 49
	private File imgPath;
45 50

51
	public NotifyService getNotifyService() {
52
		return notifyService;
53
	}
54

55
	public void setNotifyService(NotifyService notifyService) {
56
		this.notifyService = notifyService;
57
	}
58

46 59
	public File getImgPath() {
47 60
		return imgPath;
48 61
	}
@ -179,7 +192,7 @@ public class Service {
179 192
	 * 邀请专家回答提问
180 193
	 * 
181 194
	 * @param con
182
	 * @param id
195
	 * @param qid
183 196
	 *            提问id
184 197
	 * @param pid
185 198
	 *            专家id(被邀请人)
@ -193,12 +206,12 @@ public class Service {
193 206
	 */
194 207
	@Post
195 208
	@Path("/invite")
196
	public boolean invite(@JdbcConn Connection con, String id, String pid, String uid, String uname) throws SQLException, JfwBaseException {
197
		Question q = questionDao.query(con, id);
209
	public boolean invite(@JdbcConn(true) Connection con, String qid, String pid, String uid, String uname,@AfterCommit List<Runnable> runs) throws SQLException, JfwBaseException {
210
		Question q = questionDao.query(con, qid);
198 211
		if (q == null) {
199
			throw new JfwBaseException(50000, "question[" + id + "] not found");
212
			throw new JfwBaseException(50000, "question[" +qid + "] not found");
200 213
		}
201
		// TODO: send notify
214
		this.notifyService.notify(con, pid, uid, uname, qid, q.getTitle(), NotifyType.INVITE_ANSWER, runs);
202 215
		return true;
203 216
	}
204 217

@ -220,7 +233,8 @@ public class Service {
220 233
	 */
221 234
	@Post
222 235
	@Path("/answer")
223
	public String answer(@JdbcConn(true) Connection con, String qid, String cnt, String uid, String uname) throws SQLException, JfwBaseException {
236
	public String answer(@JdbcConn(true) Connection con, String qid, String cnt, String uid, String uname, @AfterCommit List<Runnable> runs)
237
			throws SQLException, JfwBaseException {
224 238
		Question q = questionDao.query(con, qid);
225 239
		if (q == null) {
226 240
			throw new JfwBaseException(50000, "question[" + qid + "] not found");
@ -228,7 +242,7 @@ public class Service {
228 242
		String id = StringUtil.buildUUID();
229 243
		Answer a = new Answer();
230 244
		a.setId(id);
231
		a.setAccept(0);
245
		a.setAgree(0);
232 246
		a.setBallot(0);
233 247
		a.setCnt(cnt);
234 248
		a.setQid(qid);
@ -242,6 +256,7 @@ public class Service {
242 256
			}
243 257
			throw e;
244 258
		}
259
		notifyService.notify(con, q.getUid(), uid, uname, qid, q.getTitle(), NotifyType.ANSWER_QUESTION, runs);
245 260
		return id;
246 261
	}
247 262

@ -274,7 +289,7 @@ public class Service {
274 289

275 290
	@Get
276 291
	@Path("/qm")
277
	public List<Question> queryOne(@JdbcConn Connection con, String[] ids) throws SQLException {
292
	public List<Question> query(@JdbcConn Connection con, String[] ids) throws SQLException {
278 293
		return questionDao.query(con, ids);
279 294
	}
280 295

@ -358,7 +373,7 @@ public class Service {
358 373
	 * @throws SQLException
359 374
	 */
360 375
	@Get
361
	@Path("/answer/my")
376
	@Path("/answer/bySelf")
362 377
	public List<Answer> answerSelf(@JdbcConn Connection con, String uid, @DefaultValue("\"0\"") String time, @DefaultValue("\"0\"") String id,
363 378
			@DefaultValue("10000000") int rows) throws SQLException {
364 379
		return questionDao.answerSelf(con, uid, time, id, rows);
@ -380,11 +395,29 @@ public class Service {
380 395
	 * @throws SQLException
381 396
	 */
382 397
	@Get
383
	@Path("/answer/my")
398
	@Path("/answer/byWatch")
384 399
	public List<Answer> answerWatch(@JdbcConn Connection con, String uid, @DefaultValue("\"0\"") String time, @DefaultValue("\"0\"") String id,
385 400
			@DefaultValue("10000000") int rows) throws SQLException {
386 401
		return questionDao.watchAnswer(con, uid, time, id, rows);
387 402
	}
403
	
404
	/**
405
	 * 查询所有合法的回答(“发布中”的问题下的“发布中”的回答。);
406
	 * 按最新回答时间,由新到旧排序
407
	})
408
	 * @param con
409
	 * @param time
410
	 * @param id
411
	 * @param rows
412
	 * @return
413
	 * @throws SQLException
414
	 */
415
	@Get
416
	@Path("/answer/byTime")
417
	public List<Answer> answerByTime(@JdbcConn Connection con,@DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
418
			@DefaultValue("10000000") int rows) throws SQLException {
419
		return questionDao.answer(con,  time, id, rows);
420
	}
388 421
	/**
389 422
	 * 指定提问的回答(按最新回答时间,由新到旧排序)
390 423
	 * 
@ -406,6 +439,7 @@ public class Service {
406 439
			@DefaultValue("10000000") int rows) throws SQLException {
407 440
		return questionDao.byQes(con, qid, time, id, rows);
408 441
	}
442

409 443
	/**
410 444
	 * 指定提问的回答(按最新回答时间,由新到旧排序)
411 445
	 * 
@ -427,6 +461,8 @@ public class Service {
427 461
			@DefaultValue("10000000") int rows) throws SQLException {
428 462
		return questionDao.byQes(con, qid, score, id, rows);
429 463
	}
464
	
465
	
430 466

431 467
	/**
432 468
	 * 我的回答总点赞数
@ -438,82 +474,89 @@ public class Service {
438 474
	 * @throws SQLException
439 475
	 */
440 476
	@Get
441
	@Path("/answer/my/accept/count")
477
	@Path("/answer/my/agree/count")
442 478
	public int queryCountWithMyAnswer(@JdbcConn Connection con, final String id) throws SQLException {
443
		return JdbcUtil.queryInt(con, "SELECT COUNT(ACCEPT) FROM ANSWER WHERE UID=?", new PreparedStatementConfig() {
479
		return JdbcUtil.queryInt(con, "SELECT COUNT(AGREE) FROM ANSWER WHERE UID=?", new PreparedStatementConfig() {
444 480
			@Override
445 481
			public void config(PreparedStatement ps) throws SQLException {
446 482
				ps.setString(1, id);
447 483
			}
448 484
		}, 0);
449 485
	}
450
	
486

451 487
	@Post
452
	@Path("/answer/accept")
453
	public void accept(@JdbcConn(true) Connection con,String id,String uid,String uname,@AfterCommit List<Runnable> runs)throws SQLException, JfwBaseException{
454
		AnswerAcceptRec aar = new AnswerAcceptRec();
488
	@Path("/answer/agree")
489
	public void agree(@JdbcConn(true) Connection con, String id, String uid, String uname, @AfterCommit List<Runnable> runs)
490
			throws SQLException, JfwBaseException {
491
		Answer a = questionDao.queryAnswer(con, id);
492
		if (a == null)
493
			throw new JfwBaseException(50000, "answer[" + id + "] not found");
494

495
		String qid = a.getQid();
496
		Question q = questionDao.query(con, qid);
497
		if (q == null)
498
			throw new JfwBaseException(50000, "answer[" + id + "] ' question  not found");
499

500
		AnswerAgreeRec aar = new AnswerAgreeRec();
455 501
		aar.setAid(id);
456 502
		aar.setUid(uid);
457 503
		aar.setFlag(true);
458 504
		boolean inserted = false;
459
		try{
460
			questionDao.insert(con,aar);
461
			inserted=true;
462
		}catch(SQLException e){
463
			if(SqlUtil.unique(e)){
505
		try {
506
			questionDao.insert(con, aar);
507
			inserted = true;
508
		} catch (SQLException e) {
509
			if (SqlUtil.unique(e)) {
464 510
				con.rollback();
465 511
			}
466 512
			throw e;
467 513
		}
468
		if(inserted){
514
		if (inserted) {
469 515
			questionDao.update(con, id, 1, 1);
470
		}else{
471
			if(questionDao.accept(con, uid, id) >0){
472
				questionDao.update(con,id,1,0);
473
			}else{
474
				throw new JfwBaseException(50001,"duplicate answer accept");
516
		} else {
517
			if (questionDao.agree(con, uid, id) > 0) {
518
				questionDao.update(con, id, 1, 0);
519
			} else {
520
				throw new JfwBaseException(50001, "duplicate answer agree");
475 521
			}
476
			
477 522
		}
478
		runs.add(new Runnable(){
479

480
			@Override
481
			public void run() {
482
				// TODO send notify
483
			}});
523
		notifyService.notify(con, a.getUid(), uid, uname, a.getId(), q.getTitle(), NotifyType.ACCEPT_ANSWER, runs);
484 524
	}
525

485 526
	@Post
486
	@Path("/answer/unAccept")
487
	public void unAccept(@JdbcConn(true) Connection con,String id,String uid,String uname,@AfterCommit List<Runnable> runs)throws SQLException, JfwBaseException{
488
		AnswerAcceptRec aar = new AnswerAcceptRec();
527
	@Path("/answer/unAgree")
528
	public void unAgree(@JdbcConn(true) Connection con, String id, String uid, String uname, @AfterCommit List<Runnable> runs)
529
			throws SQLException, JfwBaseException {
530
		AnswerAgreeRec aar = new AnswerAgreeRec();
489 531
		aar.setAid(id);
490 532
		aar.setUid(uid);
491 533
		aar.setFlag(false);
492 534
		boolean inserted = false;
493
		try{
494
			questionDao.insert(con,aar);
495
			inserted=true;
496
		}catch(SQLException e){
497
			if(SqlUtil.unique(e)){
535
		try {
536
			questionDao.insert(con, aar);
537
			inserted = true;
538
		} catch (SQLException e) {
539
			if (SqlUtil.unique(e)) {
498 540
				con.rollback();
499 541
			}
500 542
			throw e;
501 543
		}
502
		if(inserted){
544
		if (inserted) {
503 545
			questionDao.update(con, id, 0, 1);
504
		}else{
505
			if(questionDao.unAccept(con, uid, id) >0){
506
				questionDao.update(con,id,-1,0);
507
			}else{
508
				throw new JfwBaseException(50001,"duplicate answer unaccept");
546
		} else {
547
			if (questionDao.unAgree(con, uid, id) > 0) {
548
				questionDao.update(con, id, -1, 0);
549
			} else {
550
				throw new JfwBaseException(50001, "duplicate answer unagree");
509 551
			}
510 552
		}
511
		runs.add(new Runnable(){
553
		runs.add(new Runnable() {
512 554

513 555
			@Override
514 556
			public void run() {
515 557
				// TODO send notify
516
			}});
558
			}
559
		});
517 560
	}
518 561

519 562
	public QetKeyWord[] build(String id, List<String> ss) {

+ 24 - 1
src/main/java/com/ekexiu/portal/service/ArticleService.java

@ -20,11 +20,13 @@ import org.jfw.apt.annotation.Nullable;
20 20
import org.jfw.apt.web.annotation.Path;
21 21
import org.jfw.apt.web.annotation.operate.Get;
22 22
import org.jfw.apt.web.annotation.operate.Post;
23
import org.jfw.apt.web.annotation.param.AfterCommit;
23 24
import org.jfw.apt.web.annotation.param.JdbcConn;
24 25
import org.jfw.util.DateUtil;
25 26
import org.jfw.util.JpgUtil;
26 27
import org.jfw.util.PageQueryResult;
27 28
import org.jfw.util.StringUtil;
29
import org.jfw.util.codec.JfwInvalidCodecKeyException;
28 30
import org.jfw.util.exception.JfwBaseException;
29 31
import org.jfw.util.io.IoUtil;
30 32

@ -41,6 +43,8 @@ import com.ekexiu.portal.dao.ProfessorDao;
41 43
import com.ekexiu.portal.dao.ResearchAreaDao;
42 44
import com.ekexiu.portal.dao.ResourceDao;
43 45
import com.ekexiu.portal.dao.WatchDao;
46
import com.ekexiu.portal.notify.NotifyService;
47
import com.ekexiu.portal.notify.NotifyType;
44 48
import com.ekexiu.portal.po.Article;
45 49
import com.ekexiu.portal.po.ArticleAgree;
46 50
import com.ekexiu.portal.po.ArticleOrg;
@ -95,6 +99,18 @@ public class ArticleService {
95 99

96 100
	@Autowrie
97 101
	private TemplateService templateService;
102
	
103
	@Autowrie
104
	private NotifyService notifyService;
105
	
106

107
	public NotifyService getNotifyService() {
108
		return notifyService;
109
	}
110

111
	public void setNotifyService(NotifyService notifyService) {
112
		this.notifyService = notifyService;
113
	}
98 114

99 115
	public TemplateService getTemplateService() {
100 116
		return templateService;
@ -747,12 +763,19 @@ public class ArticleService {
747 763

748 764
	@Post
749 765
	@Path("/agree")
750
	public void agree(@JdbcConn(true) Connection con, String operateId, String articleId) throws SQLException {
766
	public void agree(@JdbcConn(true) Connection con, String operateId, String articleId,String uname,@AfterCommit List<Runnable> runs) throws SQLException {
767
		final Article article = this.articleDao.queryOne(con, articleId);
768
		if(article==null){
769
			throw new IllegalArgumentException("not found article["+articleId+ "]");
770
		}
751 771
		if (this.articleDao.incAgree(con, articleId) > 0) {
752 772
			ArticleAgree articleAgree = new ArticleAgree();
753 773
			articleAgree.setOperateId(operateId);
754 774
			articleAgree.setArticleId(articleId);
755 775
			this.articleAgreeDao.insert(con, articleAgree);
776
			if(article.getArticleType().equals("1")){
777
				this.notifyService.notify(con, article.getProfessorId(), operateId, uname, articleId, article.getArticleTitle(), NotifyType.AGREE_ARTICLE, runs);
778
			}
756 779
		}
757 780
	}
758 781


+ 60 - 33
src/main/java/com/ekexiu/portal/service/PpaperService.java

@ -11,12 +11,16 @@ import org.jfw.apt.annotation.Nullable;
11 11
import org.jfw.apt.web.annotation.Path;
12 12
import org.jfw.apt.web.annotation.operate.Get;
13 13
import org.jfw.apt.web.annotation.operate.Post;
14
import org.jfw.apt.web.annotation.param.AfterCommit;
14 15
import org.jfw.apt.web.annotation.param.JdbcConn;
15 16
import org.jfw.util.PageQueryResult;
17
import org.jfw.util.exception.JfwBaseException;
16 18

17 19
import com.ekexiu.portal.dao.PaperAgreeDao;
18 20
import com.ekexiu.portal.dao.PaperAuthorDao;
19 21
import com.ekexiu.portal.dao.PpaperDao;
22
import com.ekexiu.portal.notify.NotifyService;
23
import com.ekexiu.portal.notify.NotifyType;
20 24
import com.ekexiu.portal.po.PaperAgree;
21 25
import com.ekexiu.portal.po.PaperAuthor;
22 26
import com.ekexiu.portal.po.Ppaper;
@ -29,15 +33,23 @@ public class PpaperService {
29 33
	private PpaperDao ppaperDao;
30 34
	@Autowrie
31 35
	private PaperAuthorDao paperAuthorDao;
32
	
36

33 37
	@Autowrie
34 38
	private KeyWordService keyWordService;
35
	
39

36 40
	@Autowrie
37 41
	private PaperAgreeDao paperAgreeDao;
38
	
39
	
40
	
42

43
	@Autowrie
44
	private NotifyService notifyService;
45

46
	public NotifyService getNotifyService() {
47
		return notifyService;
48
	}
49

50
	public void setNotifyService(NotifyService notifyService) {
51
		this.notifyService = notifyService;
52
	}
41 53

42 54
	public PaperAgreeDao getPaperAgreeDao() {
43 55
		return paperAgreeDao;
@ -164,57 +176,72 @@ public class PpaperService {
164 176
	@Path("/kw")
165 177
	public void update(@JdbcConn(true) Connection con, String id, @Nullable String keywords) throws SQLException {
166 178
		this.ppaperDao.update(con, id, keywords);
167
		this.keyWordService.refreshPaper(con, id, KeyWordService.splitKeyWord(keywords));		
179
		this.keyWordService.refreshPaper(con, id, KeyWordService.splitKeyWord(keywords));
168 180
	}
169 181

170 182
	@Get
171 183
	@Path("/byShareId")
172
	public Ppaper query(@JdbcConn Connection con,long id) throws SQLException{
173
		return this.ppaperDao.query(con,id);
184
	public Ppaper query(@JdbcConn Connection con, long id) throws SQLException {
185
		return this.ppaperDao.query(con, id);
174 186
	}
187

175 188
	@Get
176 189
	@Path("/ralatePapers")
177
	public List<Ppaper> ralatePapers(@JdbcConn Connection con,String paperId,@DefaultValue("5") int rows)throws SQLException{
190
	public List<Ppaper> ralatePapers(@JdbcConn Connection con, String paperId, @DefaultValue("5") int rows) throws SQLException {
178 191
		String[] ids = this.ppaperDao.queryPaperIdWithSameKeyWord(con, paperId, rows);
179
		if(ids!=null){
180
			return this.ppaperDao.query(con,ids);
192
		if (ids != null) {
193
			return this.ppaperDao.query(con, ids);
181 194
		}
182
		return Collections.<Ppaper>emptyList();
195
		return Collections.<Ppaper> emptyList();
183 196
	}
184
	
185
	
197

186 198
	@Post
187 199
	@Path("/agree")
188
	public void agree(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
200
	public void agree(@JdbcConn(true) Connection con, String id, String uid, String uname, @AfterCommit List<Runnable> runs) throws SQLException, JfwBaseException {
201
		Ppaper p = this.ppaperDao.query(con, id);
202
		if (p == null) {
203
			throw new JfwBaseException(50000, "paper[" + id + "] not found");
204
		}
189 205
		PaperAgree pa = new PaperAgree();
190 206
		pa.setOpId(uid);
191 207
		pa.setPaperId(id);
192
		this.paperAgreeDao.insert(con, pa);		
193
	}
194
	
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
//	}
200
	
208
		this.paperAgreeDao.insert(con, pa);
209

210
		List<PaperAuthor> pas = this.paperAuthorDao.query(con, id);
211
		for (PaperAuthor au : pas) {
212
			if (!au.getProfessorId().startsWith("#")) {
213
				this.notifyService.notify(con, au.getProfessorId(), uid, uname, id, p.getName(), NotifyType.AGREE_PAPER, runs);
214
			}
215
		}
216
	}
217

218
	// @Post
219
	// @Path("/unAgree")
220
	// public void unAgree(@JdbcConn(true) Connection con,String id,String
221
	// uid)throws SQLException{
222
	// this.paperAgreeDao.delete(con,uid, id);
223
	// }
224

201 225
	@Get
202 226
	@Path("/agree")
203
	public boolean hasAgree(@JdbcConn(false) Connection con,String id,String uid)throws SQLException{
204
		return null!= this.paperAgreeDao.query(con,uid, id);
227
	public boolean hasAgree(@JdbcConn(false) Connection con, String id, String uid) throws SQLException {
228
		return null != this.paperAgreeDao.query(con, uid, id);
205 229
	}
230

206 231
	@Get
207 232
	@Path("/agreeCount")
208
	public int agreeCount(@JdbcConn(false) Connection con,String id)throws SQLException{
209
		return this.paperAgreeDao.query(con,id);
233
	public int agreeCount(@JdbcConn(false) Connection con, String id) throws SQLException {
234
		return this.paperAgreeDao.query(con, id);
210 235
	}
211
	
236

212 237
	@Get
213 238
	@Path("/assPapers")
214
	public List<Ppaper> assPapers(@JdbcConn Connection con,String[] kws,@DefaultValue("5") int rows) throws SQLException{
215
		if(kws==null || kws.length==0) return Collections.<Ppaper>emptyList();		
239
	public List<Ppaper> assPapers(@JdbcConn Connection con, String[] kws, @DefaultValue("5") int rows) throws SQLException {
240
		if (kws == null || kws.length == 0)
241
			return Collections.<Ppaper> emptyList();
216 242
		String[] ids = this.ppaperDao.queryPatentIdWithKeyWord(con, kws, rows);
217
		if(ids==null || ids.length==0) return Collections.<Ppaper>emptyList();
218
		return this.ppaperDao.query(con, ids);		
243
		if (ids == null || ids.length == 0)
244
			return Collections.<Ppaper> emptyList();
245
		return this.ppaperDao.query(con, ids);
219 246
	}
220 247
}

+ 26 - 1
src/main/java/com/ekexiu/portal/service/PpatentServcie.java

@ -11,12 +11,16 @@ import org.jfw.apt.annotation.Nullable;
11 11
import org.jfw.apt.web.annotation.Path;
12 12
import org.jfw.apt.web.annotation.operate.Get;
13 13
import org.jfw.apt.web.annotation.operate.Post;
14
import org.jfw.apt.web.annotation.param.AfterCommit;
14 15
import org.jfw.apt.web.annotation.param.JdbcConn;
15 16
import org.jfw.util.PageQueryResult;
17
import org.jfw.util.exception.JfwBaseException;
16 18

17 19
import com.ekexiu.portal.dao.PatentAgreeDao;
18 20
import com.ekexiu.portal.dao.PatentAuthorDao;
19 21
import com.ekexiu.portal.dao.PpatentDao;
22
import com.ekexiu.portal.notify.NotifyService;
23
import com.ekexiu.portal.notify.NotifyType;
20 24
import com.ekexiu.portal.po.PatentAgree;
21 25
import com.ekexiu.portal.po.PatentAuthor;
22 26
import com.ekexiu.portal.po.Ppatent;
@ -36,8 +40,19 @@ public class PpatentServcie {
36 40
	@Autowrie
37 41
	private PatentAgreeDao patentAgreeDao;
38 42
	
43
	@Autowrie
44
	private NotifyService notifyService;
45
	
39 46
	
40 47

48
	public NotifyService getNotifyService() {
49
		return notifyService;
50
	}
51

52
	public void setNotifyService(NotifyService notifyService) {
53
		this.notifyService = notifyService;
54
	}
55

41 56
	public PatentAgreeDao getPatentAgreeDao() {
42 57
		return patentAgreeDao;
43 58
	}
@ -178,11 +193,21 @@ public class PpatentServcie {
178 193
	
179 194
	@Post
180 195
	@Path("/agree")
181
	public void agree(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
196
	public void agree(@JdbcConn(true) Connection con,String id,String uid,String uname,@AfterCommit List<Runnable> runs)throws SQLException, JfwBaseException{
197
		Ppatent p = ppatentDao.query(con, id);
198
		if(p==null){
199
			throw new JfwBaseException(50000, "patent["+id+"] not found");
200
		}
182 201
		PatentAgree pa = new PatentAgree();
183 202
		pa.setOpId(uid);
184 203
		pa.setPatentId(id);
185 204
		this.patentAgreeDao.insert(con, pa);		
205
		List<PatentAuthor> authors = this.patentAuthorDao.query(con,id);
206
		for(PatentAuthor pau:authors){
207
			if(!pau.getProfessorId().startsWith("#")){
208
				this.notifyService.notify(con,pau.getProfessorId(), uid, uname, id,p.getName(), NotifyType.AGREE_PATENT, runs);
209
			}
210
		}
186 211
	}
187 212
	
188 213
//	@Post

+ 17 - 1
src/main/java/com/ekexiu/portal/service/ResearchAreaService.java

@ -10,12 +10,15 @@ import org.jfw.apt.web.annotation.operate.Delete;
10 10
import org.jfw.apt.web.annotation.operate.Get;
11 11
import org.jfw.apt.web.annotation.operate.Post;
12 12
import org.jfw.apt.web.annotation.operate.Put;
13
import org.jfw.apt.web.annotation.param.AfterCommit;
13 14
import org.jfw.apt.web.annotation.param.JdbcConn;
14 15
import org.jfw.apt.web.annotation.param.PathVar;
15 16
import org.jfw.apt.web.annotation.param.RequestBody;
16 17
17 18
import com.ekexiu.portal.dao.ResearchAreaDao;
18 19
import com.ekexiu.portal.dao.ResearchAreaLogDao;
20
import com.ekexiu.portal.notify.NotifyService;
21
import com.ekexiu.portal.notify.NotifyType;
19 22
import com.ekexiu.portal.po.ResearchArea;
20 23
import com.ekexiu.portal.po.ResearchAreaLog;
21 24
@ -27,6 +30,18 @@ public class ResearchAreaService {
27 30
	@Autowrie
28 31
	private ResearchAreaLogDao researchAreaLogDao;
29 32
33
	@Autowrie
34
	private NotifyService notifyService;
35
	
36
	
37
	public NotifyService getNotifyService() {
38
		return notifyService;
39
	}
40
41
	public void setNotifyService(NotifyService notifyService) {
42
		this.notifyService = notifyService;
43
	}
44
30 45
	public ResearchAreaDao getResearchAreaDao() {
31 46
		return researchAreaDao;
32 47
	}
@ -51,7 +66,7 @@ public class ResearchAreaService {
51 66
52 67
	@Post
53 68
	@Path("/agree")
54
	public void agree(@JdbcConn(true) Connection con, String targetId, String targetCaption, String opId) throws SQLException {
69
	public void agree(@JdbcConn(true) Connection con, String targetId, String targetCaption, String opId,String uname,@AfterCommit List<Runnable> runs) throws SQLException {
55 70
56 71
		if (this.researchAreaDao.inc(con, targetId, targetCaption) > 0) {
57 72
			ResearchAreaLog log = new ResearchAreaLog();
@ -59,6 +74,7 @@ public class ResearchAreaService {
59 74
			log.setOpreteProfessorId(opId);
60 75
			log.setProfessorId(targetId);
61 76
			this.researchAreaLogDao.insert(con, log);
77
			this.notifyService.notify(con, targetId, opId, uname, targetId, targetCaption,NotifyType.AGREE_RESEARCH_AREA, runs);
62 78
		}
63 79
	}
64 80

+ 61 - 27
src/main/java/com/ekexiu/portal/service/WatchService.java

@ -9,6 +9,7 @@ import org.jfw.apt.annotation.DefaultValue;
9 9
import org.jfw.apt.web.annotation.Path;
10 10
import org.jfw.apt.web.annotation.operate.Get;
11 11
import org.jfw.apt.web.annotation.operate.Post;
12
import org.jfw.apt.web.annotation.param.AfterCommit;
12 13
import org.jfw.apt.web.annotation.param.JdbcConn;
13 14
import org.jfw.util.PageQueryResult;
14 15

@ -19,6 +20,8 @@ import com.ekexiu.portal.dao.ProfessorDao;
19 20
import com.ekexiu.portal.dao.ResearchAreaDao;
20 21
import com.ekexiu.portal.dao.ResourceDao;
21 22
import com.ekexiu.portal.dao.WatchDao;
23
import com.ekexiu.portal.notify.NotifyService;
24
import com.ekexiu.portal.notify.NotifyType;
22 25
import com.ekexiu.portal.po.Article;
23 26
import com.ekexiu.portal.po.Resource;
24 27
import com.ekexiu.portal.po.Watch;
@ -26,6 +29,7 @@ import com.ekexiu.portal.pojo.EditProfessor;
26 29

27 30
@Path("/watch")
28 31
public class WatchService {
32

29 33
	@Autowrie
30 34
	private WatchDao watchDao;
31 35
	@Autowrie
@ -42,113 +46,142 @@ public class WatchService {
42 46
	private OrgDao orgDao;
43 47
	@Autowrie
44 48
	private ImageDao imageDao;
45
	
49

50
	@Autowrie
51
	private NotifyService notifyService;
52

53
	public NotifyService getNotifyService() {
54
		return notifyService;
55
	}
56

57
	public void setNotifyService(NotifyService notifyService) {
58
		this.notifyService = notifyService;
59
	}
60

46 61
	public WatchDao getWatchDao() {
47 62
		return watchDao;
48 63
	}
64

49 65
	public void setWatchDao(WatchDao watchDao) {
50 66
		this.watchDao = watchDao;
51 67
	}
68

52 69
	public ProfessorDao getProfessorDao() {
53 70
		return professorDao;
54 71
	}
72

55 73
	public void setProfessorDao(ProfessorDao professorDao) {
56 74
		this.professorDao = professorDao;
57 75
	}
76

58 77
	public ResourceDao getResourceDao() {
59 78
		return resourceDao;
60 79
	}
80

61 81
	public void setResourceDao(ResourceDao resourceDao) {
62 82
		this.resourceDao = resourceDao;
63 83
	}
84

64 85
	public ImageService getImageService() {
65 86
		return imageService;
66 87
	}
88

67 89
	public void setImageService(ImageService imageService) {
68 90
		this.imageService = imageService;
69 91
	}
92

70 93
	public ResearchAreaDao getResearchAreaDao() {
71 94
		return researchAreaDao;
72 95
	}
96

73 97
	public void setResearchAreaDao(ResearchAreaDao researchAreaDao) {
74 98
		this.researchAreaDao = researchAreaDao;
75 99
	}
100

76 101
	public ArticleDao getArticleDao() {
77 102
		return articleDao;
78 103
	}
104

79 105
	public void setArticleDao(ArticleDao articleDao) {
80 106
		this.articleDao = articleDao;
81 107
	}
108

82 109
	public OrgDao getOrgDao() {
83 110
		return orgDao;
84 111
	}
112

85 113
	public void setOrgDao(OrgDao orgDao) {
86 114
		this.orgDao = orgDao;
87 115
	}
116

88 117
	public ImageDao getImageDao() {
89 118
		return imageDao;
90 119
	}
120

91 121
	public void setImageDao(ImageDao imageDao) {
92 122
		this.imageDao = imageDao;
93 123
	}
94
	
124

95 125
	@Post
96 126
	@Path
97
	public String insert(@JdbcConn(true) Connection con, Watch watch) throws SQLException{
127
	public String insert(@JdbcConn(true) Connection con, Watch watch, final String uname, @AfterCommit List<Runnable> runs) throws SQLException {
98 128
		this.watchDao.insert(con, watch);
129
		if (watch.getWatchType() == 1) {
130
			this.notifyService.notify(con, watch.getWatchObject(), watch.getProfessorId(), uname, watch.getWatchObject(), watch.getWatchObject(),
131
					NotifyType.WATCH_USER, runs);
132
		}
133

99 134
		return watch.getWatchObject();
100 135
	}
101
	
136

102 137
	@Post
103 138
	@Path("/delete")
104
	public void delete(@JdbcConn(true) Connection con, String professorId, String watchObject) throws SQLException{
139
	public void delete(@JdbcConn(true) Connection con, String professorId, String watchObject) throws SQLException {
105 140
		this.watchDao.delete(con, professorId, watchObject);
106 141
	}
107
	
142

108 143
	@Get
109 144
	@Path("/hasWatch")
110 145
	public Watch queryOne(@JdbcConn Connection con, String professorId, String watchObject) throws SQLException {
111 146
		return this.watchDao.queryOne(con, professorId, watchObject);
112 147
	}
113
	
114 148

115
	
116 149
	@Get
117 150
	@Path("/qaPro")
118
	public PageQueryResult<Watch> queryPro(@JdbcConn Connection con, String professorId, short watchType, 
119
			@DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
151
	public PageQueryResult<Watch> queryPro(@JdbcConn Connection con, String professorId, short watchType, @DefaultValue("10") int pageSize,
152
			@DefaultValue("1") int pageNo) throws SQLException {
120 153
		PageQueryResult<Watch> queryResult = this.watchDao.queryPro(con, professorId, watchType, pageSize, pageNo);
121 154
		List<Watch> watchs = queryResult.getData();
122
		if(1 == watchType){
155
		if (1 == watchType) {
123 156
			for (Watch watch : watchs) {
124 157
				EditProfessor professor = this.professorDao.queryBaseInfo(con, watch.getWatchObject());
125
				if(professor != null) {
158
				if (professor != null) {
126 159
					professor.setHasHeadImage(this.imageService.hasProfessorImage(watch.getWatchObject()));
127 160
					professor.setResearchAreas(this.researchAreaDao.query(con, watch.getWatchObject()));
128 161
					professor.setResources(this.resourceDao.queryList(con, watch.getWatchObject()));
129 162
				}
130 163
				watch.setProfessor(professor);
131 164
			}
132
		}else if(2 == watchType){
165
		} else if (2 == watchType) {
133 166
			for (Watch watch : watchs) {
134 167
				Resource resource = this.resourceDao.queryOne(con, watch.getWatchObject());
135
				if(resource != null) {
168
				if (resource != null) {
136 169
					resource.setImages(this.imageDao.queryRes(con, resource.getResourceId()));
137
					if("1".equals(resource.getResourceType())){
170
					if ("1".equals(resource.getResourceType())) {
138 171
						resource.setEditProfessor(this.professorDao.queryBaseInfo(con, resource.getProfessorId()));
139
					}else if("2".equals(resource.getResourceType())){
172
					} else if ("2".equals(resource.getResourceType())) {
140 173
						resource.setOrganization(this.orgDao.queryEditOrg(con, resource.getOrgId()));
141 174
					}
142 175
				}
143 176
				watch.setResource(resource);
144 177
			}
145
		}else if(3 == watchType){
178
		} else if (3 == watchType) {
146 179
			for (Watch watch : watchs) {
147 180
				Article article = this.articleDao.queryOne(con, watch.getWatchObject());
148
				if(article != null){
149
					if("1".equals(article.getArticleType())){
181
				if (article != null) {
182
					if ("1".equals(article.getArticleType())) {
150 183
						article.setProfessor(this.professorDao.queryBaseInfo(con, article.getProfessorId()));
151
					}else if("2".equals(article.getArticleType())){
184
					} else if ("2".equals(article.getArticleType())) {
152 185
						article.setOrganization(this.orgDao.query(con, article.getOrgId()));
153 186
					}
154 187
				}
@ -157,14 +190,14 @@ public class WatchService {
157 190
		}
158 191
		return queryResult;
159 192
	}
160
	
193

161 194
	@Get
162 195
	@Path("/qaWatch")
163
	public List<Watch> queryWatch(@JdbcConn Connection con, String watchObject) throws SQLException{
196
	public List<Watch> queryWatch(@JdbcConn Connection con, String watchObject) throws SQLException {
164 197
		List<Watch> watchs = this.watchDao.queryWatch(con, watchObject);
165 198
		for (Watch watch : watchs) {
166 199
			EditProfessor professor = this.professorDao.queryBaseInfo(con, watch.getProfessorId());
167
			if(professor != null) {
200
			if (professor != null) {
168 201
				professor.setHasHeadImage(this.imageService.hasProfessorImage(watch.getProfessorId()));
169 202
				professor.setResearchAreas(this.researchAreaDao.query(con, watch.getProfessorId()));
170 203
				professor.setResources(this.resourceDao.queryList(con, watch.getProfessorId()));
@ -173,16 +206,17 @@ public class WatchService {
173 206
		}
174 207
		return watchs;
175 208
	}
176
	
209

177 210
	@Get
178 211
	@Path("/countObject")
179
	public int countObject(@JdbcConn Connection con,String id,short type)throws SQLException{
212
	public int countObject(@JdbcConn Connection con, String id, short type) throws SQLException {
180 213
		return this.watchDao.countWatchObject(con, id, type);
181 214
	}
215

182 216
	@Get
183 217
	@Path("/countProfessor")
184
	public int countProfessor(@JdbcConn Connection con,String id,short type)throws SQLException{
218
	public int countProfessor(@JdbcConn Connection con, String id, short type) throws SQLException {
185 219
		return this.watchDao.countProfessor(con, id, type);
186 220
	}
187
	
221

188 222
}

+ 86 - 3
src/main/resources/database.sql

@ -2098,8 +2098,91 @@ COMMENT ON COLUMN WEB_MSG_CNT.SEND_TIME is '消息发送时间';
2098 2098
COMMENT ON COLUMN WEB_MSG_CNT.READED is '消息是否已读';
2099 2099

2100 2100

2101

2102

2103

2101
--modify begin at version2.20
2102
CREATE TABLE LEAVE_MSG (ID CHAR(32) NOT NULL,CNT TEXT NOT NULL,REF_ID TEXT NOT NULL,REF_TYPE CHAR(1) NOT NULL,
2103
TOP TEXT NOT NULL,PARENT TEXT,SENDER TEXT NOT NULL,RECIVER TEXT,STATE CHAR(1) NOT NULL,AGREE_COUNT BIGINT NOT NULL,CREATE_TIME CHAR(14) NOT NULL,MODIFY_TIME CHAR(14) NOT NULL);
2104
ALTER TABLE LEAVE_MSG ADD PRIMARY KEY (ID);
2105
COMMENT ON TABLE LEAVE_MSG is '留言表(新)';
2106
COMMENT ON COLUMN LEAVE_MSG.ID is '留言ID';
2107
COMMENT ON COLUMN LEAVE_MSG.CNT is '留言内容';
2108
COMMENT ON COLUMN LEAVE_MSG.REF_ID is '留言对象ID';
2109
COMMENT ON COLUMN LEAVE_MSG.REF_TYPE is '留言对象分类 1:文章 2:论文 3:专利 4:回答';
2110
COMMENT ON COLUMN LEAVE_MSG.TOP is '顶级留言(只针对对象不针对留言)';
2111
COMMENT ON COLUMN LEAVE_MSG.PARENT is '回复的留言ID';
2112
COMMENT ON COLUMN LEAVE_MSG.SENDER is '留言人ID';
2113
COMMENT ON COLUMN LEAVE_MSG.RECIVER is '被回复的留言人ID';
2114
COMMENT ON COLUMN LEAVE_MSG.STATE is '状态 1:发布中';
2115
COMMENT ON COLUMN LEAVE_MSG.AGREE_COUNT is '被点赞数量';
2116

2117
CREATE TABLE LEAVE_MSG_AGREE_REC (ID TEXT NOT NULL,UID TEXT NOT NULL,CREATE_TIME CHAR(14) NOT NULL);
2118
ALTER TABLE LEAVE_MSG_AGREE_REC ADD PRIMARY KEY (ID,UID);
2119
COMMENT ON TABLE LEAVE_MSG_AGREE_REC is '留言点赞记录表';
2120
COMMENT ON COLUMN LEAVE_MSG_AGREE_REC.ID is '留言ID';
2121
COMMENT ON COLUMN LEAVE_MSG_AGREE_REC.UID is '点赞人ID';
2122

2123

2124
CREATE TABLE QUESTION (ID CHAR(32) NOT NULL,TITLE TEXT NOT NULL,
2125
CNT TEXT,IMG TEXT,KEYS TEXT NOT NULL,
2126
UID TEXT NOT NULL,LAST_REPLY_TIME CHAR(14),
2127
REPLY_COUNT BIGINT NOT NULL,STATE CHAR(1) NOT NULL,CREATE_TIME CHAR(14) NOT NULL,MODIFY_TIME CHAR(14) NOT NULL);
2128
ALTER TABLE QUESTION ADD PRIMARY KEY (ID);
2129
COMMENT ON TABLE QUESTION is '提问表';
2130
COMMENT ON COLUMN QUESTION.ID is '提问ID';
2131
COMMENT ON COLUMN QUESTION.TITLE is '提问标题';
2132
COMMENT ON COLUMN QUESTION.CNT is '提问描述';
2133
COMMENT ON COLUMN QUESTION.IMG is '提问图片(英文逗号分隔)';
2134
COMMENT ON COLUMN QUESTION.KEYS is '提问关键词(英文逗号分隔)';
2135
COMMENT ON COLUMN QUESTION.UID is '提问人ID';
2136
COMMENT ON COLUMN QUESTION.LAST_REPLY_TIME is '最后回答时间';
2137
COMMENT ON COLUMN QUESTION.REPLY_COUNT is '回答次数';
2138
COMMENT ON COLUMN QUESTION.STATE is '状态 1:发布中';
2139

2140

2141

2142
CREATE TABLE ANSWER (ID CHAR(32) NOT NULL,QID TEXT NOT NULL,UID TEXT NOT NULL,STATE CHAR(1) NOT NULL,
2143
CNT TEXT NOT NULL,AGREE BIGINT NOT NULL,BALLOT BIGINT NOT NULL,CREATE_TIME CHAR(14) NOT NULL,MODIFY_TIME CHAR(14) NOT NULL);
2144
ALTER TABLE ANSWER ADD PRIMARY KEY (ID);
2145
ALTER TABLE ANSWER ADD UNIQUE (QID,UID);
2146
COMMENT ON TABLE ANSWER is '回答表';
2147
COMMENT ON COLUMN ANSWER.ID is '回答ID';
2148
COMMENT ON COLUMN ANSWER.QID is '提问ID';
2149
COMMENT ON COLUMN ANSWER.CNT is '回答内容';
2150
COMMENT ON COLUMN ANSWER.UID is '回答人ID';
2151
COMMENT ON COLUMN ANSWER.AGREE is '赞同票数';
2152
COMMENT ON COLUMN ANSWER.BALLOT is '总投票数';
2153
COMMENT ON COLUMN ANSWER.STATE is '状态 1:发布中';
2154

2155

2156

2157
CREATE TABLE ANSWER_AGREE_REC (UID TEXT NOT NULL,AID TEXT NOT NULL,FLAG CHAR(1) NOT NULL);
2158
ALTER TABLE ANSWER_AGREE_REC ADD PRIMARY KEY (UID,AID);
2159
COMMENT ON TABLE ANSWER_AGREE_REC is '回答投票表';
2160
COMMENT ON COLUMN ANSWER_AGREE_REC.AID is '回答ID';
2161
COMMENT ON COLUMN ANSWER_AGREE_REC.UID is '投票人ID';
2162
COMMENT ON COLUMN ANSWER_AGREE_REC.FLAG is '1:赞同票  0:反对票';
2163

2164
CREATE TABLE QET_KEY_WORD (ID TEXT NOT NULL,KW TEXT NOT NULL);
2165
ALTER TABLE QET_KEY_WORD ADD PRIMARY KEY (ID,KW);
2166

2167
CREATE TABLE NOTIFY_MSG_IDX (RECIVER TEXT NOT NULL,LAST_CNT TEXT NOT NULL,LAST_TIME TEXT NOT NULL,UN_READ INTEGER NOT NULL);
2168
ALTER TABLE NOTIFY_MSG_IDX ADD PRIMARY KEY (RECIVER);
2169
COMMENT ON TABLE NOTIFY_MSG_IDX is '通知索引表';
2170
COMMENT ON COLUMN NOTIFY_MSG_IDX.RECIVER is '接收人ID';
2171
COMMENT ON COLUMN NOTIFY_MSG_IDX.LAST_CNT is '最后通知内容';
2172
COMMENT ON COLUMN NOTIFY_MSG_IDX.LAST_TIME is '最后通知时间';
2173
COMMENT ON COLUMN NOTIFY_MSG_IDX.UN_READ is '未读通知数';
2174

2175
CREATE TABLE NOTIFY_MSG_CNT (ID CHAR(32) NOT NULL,CNT TEXT NOT NULL,RECIVER TEXT NOT NULL,READED CHAR(1) NOT NULL,
2176
PID TEXT NOT NULL,UID TEXT NOT NULL,CREATE_TIME TEXT NOT NULL,OP_TYPE INTEGER NOT NULL);
2177
ALTER TABLE NOTIFY_MSG_CNT ADD PRIMARY KEY (ID);
2178
COMMENT ON TABLE NOTIFY_MSG_CNT is '通知内容表';
2179
COMMENT ON COLUMN NOTIFY_MSG_CNT.ID is '通知ID';
2180
COMMENT ON COLUMN NOTIFY_MSG_CNT.CNT is '通知内容';
2181
COMMENT ON COLUMN NOTIFY_MSG_CNT.RECIVER is '接收人ID';
2182

2183
COMMENT ON COLUMN NOTIFY_MSG_CNT.READED is '是否已读,1:已读  0:未读';
2184
COMMENT ON COLUMN NOTIFY_MSG_CNT.PID is '参数ID';
2185
COMMENT ON COLUMN NOTIFY_MSG_CNT.UID is '通知触发人ID';
2186
COMMENT ON COLUMN NOTIFY_MSG_CNT.UID is '通知类型(详见文档)';
2104 2187

2105 2188