jiapeng vor 7 Jahren
Ursprung
Commit
f689e69e6c

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

@ -166,6 +166,9 @@ public interface QuestionDao {
166 166
	
167 167
	@SelectOne
168 168
	@Nullable
169
	@Where("FLAG='1'")
170
	AnswerAgreeRec isAgree(Connection con,String uid,String aid)throws SQLException;
169
	AnswerAgreeRec queryAswerAgreRec(Connection con,String uid,String aid)throws SQLException;
170
	
171
	@DeleteWith
172
	@From(AnswerAgreeRec.class)
173
	int deleteAnswerAgreeRec(Connection con,String uid,String aid,boolean flag)throws SQLException;
171 174
}

+ 37 - 12
src/main/java/com/ekexiu/portal/question/Service.java

@ -630,11 +630,43 @@ public class Service {
630 630
		}
631 631
		notifyService.notify(con, a.getUid(), uid, uname, a.getId(), q.getTitle(), NotifyType.ACCEPT_ANSWER, runs);
632 632
	}
633
	
634
	
635
	@Post
636
	@Path("/answer/aagree/cancle")
637
	public int unAgree(@JdbcConn(true) Connection con, String id, String uid, String uname)
638
			throws SQLException, JfwBaseException {
639
		Answer a = questionDao.queryAnswer(con, id);
640
		if (a == null)
641
			throw new JfwBaseException(50000, "answer[" + id + "] not found");
642

643
		
644
		if(questionDao.deleteAnswerAgreeRec(con, uid, id, true)>0){
645
			questionDao.update(con, id, -1, -1);
646
			return 1;
647
		}
648
		return 0;
649
	}
650
	@Post
651
	@Path("/answer/oppose/cancle")
652
	public int unOpp(@JdbcConn(true) Connection con, String id, String uid, String uname)
653
			throws SQLException, JfwBaseException {
654
		Answer a = questionDao.queryAnswer(con, id);
655
		if (a == null)
656
			throw new JfwBaseException(50000, "answer[" + id + "] not found");
657
		if(questionDao.deleteAnswerAgreeRec(con, uid, id, false)>0){
658
			questionDao.update(con, id, 0, -1);
659
			return 1;
660
		}
661
		return 0;
662
	}
663
	
664
	
633 665

634 666
	@Get
635 667
	@Path("/answer/agree")
636
	public boolean isAgree(@JdbcConn Connection con, String aid, String uid) throws SQLException {
637
		return null != questionDao.isAgree(con, uid, aid);
668
	public AnswerAgreeRec isAgree(@JdbcConn Connection con, String aid, String uid) throws SQLException {
669
		return questionDao.queryAswerAgreRec(con, uid, aid);
638 670
	}
639 671

640 672
	@Get
@ -658,8 +690,8 @@ public class Service {
658 690
	}
659 691

660 692
	@Post
661
	@Path("/answer/unAgree")
662
	public void unAgree(@JdbcConn(true) Connection con, String id, String uid, String uname, @AfterCommit List<Runnable> runs)
693
	@Path("/answer/oppose")
694
	public void oppose(@JdbcConn(true) Connection con, String id, String uid, String uname)
663 695
			throws SQLException, JfwBaseException {
664 696
		AnswerAgreeRec aar = new AnswerAgreeRec();
665 697
		aar.setAid(id);
@ -682,16 +714,9 @@ public class Service {
682 714
			if (questionDao.unAgree(con, uid, id) > 0) {
683 715
				questionDao.update(con, id, -1, 0);
684 716
			} else {
685
				throw new JfwBaseException(50001, "duplicate answer unagree");
717
				throw new JfwBaseException(50001, "duplicate answer oppose");
686 718
			}
687 719
		}
688
		runs.add(new Runnable() {
689

690
			@Override
691
			public void run() {
692
				// TODO send notify
693
			}
694
		});
695 720
	}
696 721

697 722
	public QetKeyWord[] build(String id, List<String> ss) {