jiapeng 7 years ago
parent
commit
39205943a3

+ 35 - 18
src/main/java/com/ekexiu/portal/leavemsg/Service.java

@ -125,7 +125,7 @@ public class Service {
125 125
	}
126 126

127 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)
128
	public void notify(Connection con, String type, String id, String reciver, String uid, String uname, String lid, boolean agree, List<Runnable> runs)
129 129
			throws SQLException, JfwBaseException {
130 130
		if (type.equals("1")) {
131 131
			Article article = this.articleDao.queryOne(con, id);
@ -134,9 +134,15 @@ public class Service {
134 134
			}
135 135
			if (article.getArticleType().equals("1")) {
136 136
				if (reciver == null) {
137
					this.notifyService.notify(con, article.getProfessorId(), uid, uname, lid, article.getArticleTitle(), NotifyType.LEAVE_MSG_AT_ARTICLE, runs);
137
					if (!uid.equals(article.getProfessorId())) {
138
						this.notifyService.notify(con, article.getProfessorId(), uid, uname, lid, article.getArticleTitle(), NotifyType.LEAVE_MSG_AT_ARTICLE,
139
								runs);
140
					}
138 141
				} 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);
142
					if (!uid.equals(reciver)) {
143
						this.notifyService.notify(con, reciver, uid, uname, lid, article.getArticleTitle(),
144
								agree ? NotifyType.AGREE_LEAVE_MSG_AT_ARTICLE : NotifyType.REPLY_LEAVE_MSG_AT_ARTICLE, runs);
145
					}
140 146
				}
141 147
			}
142 148

@ -147,12 +153,15 @@ public class Service {
147 153
			}
148 154
			if (reciver == null) {
149 155
				for (PaperAuthor pa : this.paperAuthorDao.query(con, id)) {
150
					if (!pa.getProfessorId().startsWith("#")) {
156
					if (!pa.getProfessorId().startsWith("#") && (!uid.equals(pa.getProfessorId()))) {
151 157
						this.notifyService.notify(con, pa.getProfessorId(), uid, uname, lid, paper.getName(), NotifyType.LEAVE_MSG_AT_PAPER, runs);
152 158
					}
153 159
				}
154 160
			} 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);
161
				if (!uid.equals(reciver)) {
162
					this.notifyService.notify(con, reciver, uid, uname, lid, paper.getName(),
163
							agree ? NotifyType.AGREE_LEAVE_MSG_AT_PAPER : NotifyType.REPLY_LEAVE_MSG_AT_PAPER, runs);
164
				}
156 165
			}
157 166
		} else if (type.equals("3")) {
158 167
			Ppatent patent = this.ppatentDao.query(con, id);
@ -161,16 +170,19 @@ public class Service {
161 170
			}
162 171
			if (reciver == null) {
163 172
				for (PatentAuthor pa : this.patentAuthorDao.query(con, id)) {
164
					if (!pa.getProfessorId().startsWith("#")) {
173
					if (!pa.getProfessorId().startsWith("#") && (!uid.equals(pa.getProfessorId()))) {
165 174
						this.notifyService.notify(con, pa.getProfessorId(), uid, uname, lid, patent.getName(), NotifyType.LEAVE_MSG_AT_PARENT, runs);
166 175
					}
167 176
				}
168 177
			} 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);
178
				if (!uid.equals(reciver)) {
179
					this.notifyService.notify(con, reciver, uid, uname, lid, patent.getName(),
180
							agree ? NotifyType.AGREE_LEAVE_MSG_AT_PARENT : NotifyType.REPLY_LEAVE_MSG_AT_PARENT, runs);
181
				}
170 182
			}
171 183
		} else if (type.equals("4")) {
172 184
			Answer a = this.questionDao.queryAnswer(con, id);
173
			if(a ==null){
185
			if (a == null) {
174 186
				throw new JfwBaseException(50000, "answer[" + id + "] not found");
175 187
			}
176 188
			Question q = this.questionDao.query(con, a.getQid());
@ -178,9 +190,14 @@ public class Service {
178 190
				throw new JfwBaseException(50000, "answer[" + id + "]'question not found");
179 191
			}
180 192
			if (reciver == null) {
181
				this.notifyService.notify(con,a.getUid(), uid, uname, lid, q.getTitle(), NotifyType.LEAVE_MSG_AT_ANSWER, runs);
193
				if (!uid.equals(a.getUid())) {
194
					this.notifyService.notify(con, a.getUid(), uid, uname, lid, q.getTitle(), NotifyType.LEAVE_MSG_AT_ANSWER, runs);
195
				}
182 196
			} 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);
197
				if (!uid.equals(reciver)) {
198
					this.notifyService.notify(con, reciver, uid, uname, lid, q.getTitle(),
199
							agree ? NotifyType.AGREE_LEAVE_MSG_AT_ANSWER : NotifyType.REPLY_LEAVE_MSG_AT_ANSWER, runs);
200
				}
184 201
			}
185 202
		} else {
186 203
			throw new IllegalArgumentException();
@ -207,7 +224,7 @@ public class Service {
207 224
	public String save(@JdbcConn(true) Connection con,
208 225
			@RequestParam(fields = { @FieldParam(value = "cnt", valueClass = String.class), @FieldParam(value = "refId", valueClass = String.class),
209 226
					@FieldParam(value = "refType", valueClass = String.class), @FieldParam(value = "sender", valueClass = String.class) }) LeaveMsg msg,
210
			 String uname, @AfterCommit List<Runnable> runs) throws SQLException, JfwBaseException {
227
			String uname, @AfterCommit List<Runnable> runs) throws SQLException, JfwBaseException {
211 228
		String id = StringUtil.buildUUID();
212 229
		String time = DateUtil.formatDateTime(System.currentTimeMillis());
213 230
		msg.setId(id);
@ -216,9 +233,9 @@ public class Service {
216 233
		msg.setParent(null);
217 234
		msg.setAgreeCount(0);
218 235
		msg.setCreateTime(time);
219
		msg.setTimeDesc(time+id);
236
		msg.setTimeDesc(time + id);
220 237
		leaveMsgDao.insert(con, msg);
221
		this.notify(con, msg.getRefType(), msg.getRefId(), null, msg.getSender(), uname, id,false, runs);
238
		this.notify(con, msg.getRefType(), msg.getRefId(), null, msg.getSender(), uname, id, false, runs);
222 239
		return id;
223 240
	}
224 241

@ -243,8 +260,8 @@ public class Service {
243 260
	 */
244 261
	@Path("/reply")
245 262
	@Post
246
	public String reply(@JdbcConn(true) Connection con, String cnt, String id, String uid, String uname,
247
			@AfterCommit List<Runnable> runs) throws SQLException, JfwBaseException {
263
	public String reply(@JdbcConn(true) Connection con, String cnt, String id, String uid, String uname, @AfterCommit List<Runnable> runs)
264
			throws SQLException, JfwBaseException {
248 265
		final LeaveMsg msg = leaveMsgDao.query(con, id);
249 266
		if (msg == null)
250 267
			throw new JfwBaseException(50000, "leave message[id:" + id + "] not found");
@ -260,9 +277,9 @@ public class Service {
260 277
		msg.setId(nid);
261 278
		String time = DateUtil.formatDateTime(System.currentTimeMillis());
262 279
		msg.setCreateTime(time);
263
		msg.setTimeDesc(time+nid);
280
		msg.setTimeDesc(time + nid);
264 281
		leaveMsgDao.insert(con, msg);
265
		this.notify(con, msg.getRefType(), msg.getRefId(), msg.getReciver(), uid, uname, id,false, runs);
282
		this.notify(con, msg.getRefType(), msg.getRefId(), msg.getReciver(), uid, uname, id, false, runs);
266 283
		return nid;
267 284
	}
268 285

@ -287,7 +304,7 @@ public class Service {
287 304
	@Path("/subject")
288 305
	public List<LeaveMsg> query(@JdbcConn Connection con, String stype, String sid, @DefaultValue("\"0\"") String time, @DefaultValue("\"0\"") String id,
289 306
			int rows) throws SQLException {
290
		return leaveMsgDao.query(con, sid, stype, time+id, rows);
307
		return leaveMsgDao.query(con, sid, stype, time + id, rows);
291 308
	}
292 309

293 310
	@Get

+ 19 - 20
src/main/java/com/ekexiu/portal/question/Service.java

@ -185,7 +185,7 @@ public class Service {
185 185
	 *            title 标题 ,cnt 描述 img 图片 以英文逗号分隔, keys 关键字 以英文逗号分隔 ,uid 用户ID
186 186
	 * @return
187 187
	 * @throws SQLException
188
	 * @throws IOException 
188
	 * @throws IOException
189 189
	 */
190 190
	@Path()
191 191
	@Post
@ -289,8 +289,9 @@ public class Service {
289 289
			}
290 290
			throw e;
291 291
		}
292

293
		this.notifyService.notify(con, pid, uid, uname, qid, q.getTitle(), NotifyType.INVITE_ANSWER, runs);
292
		if (!pid.equals(uid)) {
293
			this.notifyService.notify(con, pid, uid, uname, qid, q.getTitle(), NotifyType.INVITE_ANSWER, runs);
294
		}
294 295
		return true;
295 296
	}
296 297

@ -346,7 +347,9 @@ public class Service {
346 347
			throw e;
347 348
		}
348 349
		questionDao.incQuestionReply(con, qid);
349
		notifyService.notify(con, q.getUid(), uid, uname,id+":"+qid, q.getTitle(), NotifyType.ANSWER_QUESTION, runs);
350
		if (!uid.equals(q.getUid())) {
351
			notifyService.notify(con, q.getUid(), uid, uname, id + ":" + qid, q.getTitle(), NotifyType.ANSWER_QUESTION, runs);
352
		}
350 353
		return id;
351 354
	}
352 355

@ -441,10 +444,10 @@ public class Service {
441 444
			@DefaultValue("10000000") int rows) throws SQLException {
442 445
		return questionDao.query(con, "1", uid, time + id, rows);
443 446
	}
444
	
447

445 448
	@Get
446 449
	@Path("/answer/count")
447
	public long answerCount(@JdbcConn Connection con,@Nullable String qid,@Nullable String uid,@Nullable String state) throws SQLException{
450
	public long answerCount(@JdbcConn Connection con, @Nullable String qid, @Nullable String uid, @Nullable String state) throws SQLException {
448 451
		return questionDao.answerCount(con, uid, qid, state);
449 452
	}
450 453

@ -634,40 +637,37 @@ public class Service {
634 637
				throw new JfwBaseException(50001, "duplicate answer agree");
635 638
			}
636 639
		}
637
		notifyService.notify(con, a.getUid(), uid, uname, a.getId()+":"+qid, q.getTitle(), NotifyType.ACCEPT_ANSWER, runs);
640
		if (!uid.equals(a.getUid())) {
641
			notifyService.notify(con, a.getUid(), uid, uname, a.getId() + ":" + qid, q.getTitle(), NotifyType.ACCEPT_ANSWER, runs);
642
		}
638 643
	}
639
	
640
	
644

641 645
	@Post
642 646
	@Path("/answer/agree/cancle")
643
	public int unAgree(@JdbcConn(true) Connection con, String id, String uid, String uname)
644
			throws SQLException, JfwBaseException {
647
	public int unAgree(@JdbcConn(true) Connection con, String id, String uid, String uname) throws SQLException, JfwBaseException {
645 648
		Answer a = questionDao.queryAnswer(con, id);
646 649
		if (a == null)
647 650
			throw new JfwBaseException(50000, "answer[" + id + "] not found");
648 651

649
		
650
		if(questionDao.deleteAnswerAgreeRec(con, uid, id, true)>0){
652
		if (questionDao.deleteAnswerAgreeRec(con, uid, id, true) > 0) {
651 653
			questionDao.update(con, id, -1, -1);
652 654
			return 1;
653 655
		}
654 656
		return 0;
655 657
	}
658

656 659
	@Post
657 660
	@Path("/answer/oppose/cancle")
658
	public int unOpp(@JdbcConn(true) Connection con, String id, String uid, String uname)
659
			throws SQLException, JfwBaseException {
661
	public int unOpp(@JdbcConn(true) Connection con, String id, String uid, String uname) throws SQLException, JfwBaseException {
660 662
		Answer a = questionDao.queryAnswer(con, id);
661 663
		if (a == null)
662 664
			throw new JfwBaseException(50000, "answer[" + id + "] not found");
663
		if(questionDao.deleteAnswerAgreeRec(con, uid, id, false)>0){
665
		if (questionDao.deleteAnswerAgreeRec(con, uid, id, false) > 0) {
664 666
			questionDao.update(con, id, 0, -1);
665 667
			return 1;
666 668
		}
667 669
		return 0;
668 670
	}
669
	
670
	
671 671

672 672
	@Get
673 673
	@Path("/answer/agree")
@ -697,8 +697,7 @@ public class Service {
697 697

698 698
	@Post
699 699
	@Path("/answer/oppose")
700
	public void oppose(@JdbcConn(true) Connection con, String id, String uid, String uname)
701
			throws SQLException, JfwBaseException {
700
	public void oppose(@JdbcConn(true) Connection con, String id, String uid, String uname) throws SQLException, JfwBaseException {
702 701
		AnswerAgreeRec aar = new AnswerAgreeRec();
703 702
		aar.setAid(id);
704 703
		aar.setUid(uid);

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

@ -773,7 +773,7 @@ public class ArticleService {
773 773
			articleAgree.setOperateId(operateId);
774 774
			articleAgree.setArticleId(articleId);
775 775
			this.articleAgreeDao.insert(con, articleAgree);
776
			if(article.getArticleType().equals("1")){
776
			if(article.getArticleType().equals("1")  && (!operateId.equals(article.getProfessorId()))){
777 777
				this.notifyService.notify(con, article.getProfessorId(), operateId, uname, articleId, article.getArticleTitle(), NotifyType.AGREE_ARTICLE, runs);
778 778
			}
779 779
		}

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

@ -209,7 +209,7 @@ public class PpaperService {
209 209

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

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

@ -204,7 +204,7 @@ public class PpatentServcie {
204 204
		this.patentAgreeDao.insert(con, pa);		
205 205
		List<PatentAuthor> authors = this.patentAuthorDao.query(con,id);
206 206
		for(PatentAuthor pau:authors){
207
			if(!pau.getProfessorId().startsWith("#")){
207
			if(!pau.getProfessorId().startsWith("#") &&(!uid.equals(pau.getProfessorId()))){
208 208
				this.notifyService.notify(con,pau.getProfessorId(), uid, uname, id,p.getName(), NotifyType.AGREE_PATENT, runs);
209 209
			}
210 210
		}

+ 9 - 7
src/main/java/com/ekexiu/portal/service/ResearchAreaService.java

@ -32,8 +32,7 @@ public class ResearchAreaService {
32 32
33 33
	@Autowrie
34 34
	private NotifyService notifyService;
35
	
36
	
35
37 36
	public NotifyService getNotifyService() {
38 37
		return notifyService;
39 38
	}
@ -60,13 +59,14 @@ public class ResearchAreaService {
60 59
61 60
	@Get
62 61
	@Path("/{professorId}")
63
	public List<ResearchArea> query(@JdbcConn Connection con,@PathVar String professorId) throws SQLException {
62
	public List<ResearchArea> query(@JdbcConn Connection con, @PathVar String professorId) throws SQLException {
64 63
		return this.researchAreaDao.query(con, professorId);
65 64
	}
66 65
67 66
	@Post
68 67
	@Path("/agree")
69
	public void agree(@JdbcConn(true) Connection con, String targetId, String targetCaption, String opId,String uname,@AfterCommit List<Runnable> runs) throws SQLException {
68
	public void agree(@JdbcConn(true) Connection con, String targetId, String targetCaption, String opId, String uname, @AfterCommit List<Runnable> runs)
69
			throws SQLException {
70 70
71 71
		if (this.researchAreaDao.inc(con, targetId, targetCaption) > 0) {
72 72
			ResearchAreaLog log = new ResearchAreaLog();
@ -74,7 +74,9 @@ public class ResearchAreaService {
74 74
			log.setOpreteProfessorId(opId);
75 75
			log.setProfessorId(targetId);
76 76
			this.researchAreaLogDao.insert(con, log);
77
			this.notifyService.notify(con, targetId, opId, uname, targetId, targetCaption,NotifyType.AGREE_RESEARCH_AREA, runs);
77
			if (!targetId .equals(opId)) {
78
				this.notifyService.notify(con, targetId, opId, uname, targetId, targetCaption, NotifyType.AGREE_RESEARCH_AREA, runs);
79
			}
78 80
		}
79 81
	}
80 82
@ -87,13 +89,13 @@ public class ResearchAreaService {
87 89
		}
88 90
	}
89 91
90
	
91 92
	@Delete
92 93
	@Path("/{professorId}")
93
	public void delete(@JdbcConn(true) Connection con,@PathVar String professorId) throws SQLException{
94
	public void delete(@JdbcConn(true) Connection con, @PathVar String professorId) throws SQLException {
94 95
		this.researchAreaDao.delete(con, professorId);
95 96
		this.researchAreaLogDao.delete(con, professorId);
96 97
	}
98
97 99
	@Put
98 100
	@Path
99 101
	public void saveResearchArea(@JdbcConn(true) Connection con, @RequestBody List<ResearchArea> areas) throws SQLException {

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

@ -126,7 +126,7 @@ public class WatchService {
126 126
	@Path
127 127
	public String insert(@JdbcConn(true) Connection con, Watch watch, final String uname, @AfterCommit List<Runnable> runs) throws SQLException {
128 128
		this.watchDao.insert(con, watch);
129
		if (watch.getWatchType() == 1) {
129
		if (watch.getWatchType() == 1 && (!watch.getWatchObject().equals(watch.getProfessorId()))) {
130 130
			this.notifyService.notify(con, watch.getWatchObject(), watch.getProfessorId(), uname, watch.getWatchObject(), watch.getWatchObject(),
131 131
					NotifyType.WATCH_USER, runs);
132 132
		}