jiapeng 7 years ago
parent
commit
9e0db34dd2

+ 12 - 0
src/main/java/com/ekexiu/portal/question/QuestionDao.java

22
	@DeleteWith
22
	@DeleteWith
23
	@From(QetKeyWord.class)
23
	@From(QetKeyWord.class)
24
	int deleteKeys(Connection con, String id) throws SQLException;
24
	int deleteKeys(Connection con, String id) throws SQLException;
25
	
26
	
27
	@UpdateWith
28
	@From(Question.class)
29
	@SetSentence("REPLY_COUNT=REPLY_COUNT+1")
30
	int incQuestionReply(Connection con,String id)throws SQLException;
25

31

26
	@Insert
32
	@Insert
27
	@Batch
33
	@Batch
43
	@Nullable
49
	@Nullable
44
	Question query(Connection con, String id) throws SQLException;
50
	Question query(Connection con, String id) throws SQLException;
45
	
51
	
52

53
	
46
	@SelectOne
54
	@SelectOne
47
	@Nullable
55
	@Nullable
48
	Answer queryAnswer(Connection con,String id)throws SQLException;
56
	Answer queryAnswer(Connection con,String id)throws SQLException;
59
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
67
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
60
	@Where("QID IN(SELECT ID FROM QUESTION WHERE STATE='1') AND STATE='1'")
68
	@Where("QID IN(SELECT ID FROM QUESTION WHERE STATE='1') AND STATE='1'")
61
	List<Answer> answerSelf(Connection con, String uid, @LtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
69
	List<Answer> answerSelf(Connection con, String uid, @LtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
70
	
71
	@SelectOne
72
	@Nullable
73
	Answer answer(Connection con,String uid,String qid)throws SQLException;
62

74

63
	@LimitSelect
75
	@LimitSelect
64
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
76
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")

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

274
			}
274
			}
275
			throw e;
275
			throw e;
276
		}
276
		}
277
		questionDao.incQuestionReply(con, qid);
277
		notifyService.notify(con, q.getUid(), uid, uname, qid, q.getTitle(), NotifyType.ANSWER_QUESTION, runs);
278
		notifyService.notify(con, q.getUid(), uid, uname, qid, q.getTitle(), NotifyType.ANSWER_QUESTION, runs);
278
		return id;
279
		return id;
279
	}
280
	}
281
	@Get
282
	@Path("/answer")
283
	public Answer answer(@JdbcConn Connection con,String id)throws SQLException{
284
		return questionDao.queryAnswer(con, id);
285
	}
286
	
287
	@Get
288
	@Path("/answer/exists")
289
	public boolean existsAnswer(@JdbcConn Connection con,String uid,String qid)throws SQLException{
290
		return null!=questionDao.answer(con, uid, qid);
291
	}
280

292

281
	/**
293
	/**
282
	 * 修改一个回答
294
	 * 修改一个回答

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

8
public class SortedAnswwer extends Answer {
8
public class SortedAnswwer extends Answer {
9
	private long score ;
9
	private long score ;
10

10

11
	@CalcColumn(nullable=false,handlerClass=LongHandler.class,column="10000 * agree / ballot SCORE")
11
	@CalcColumn(nullable=false,handlerClass=LongHandler.class,column="(10000 * agree+1) / (ballot+1) SCORE")
12
	public long getScore() {
12
	public long getScore() {
13
		return score;
13
		return score;
14
	}
14
	}