jiapeng 7 years ago
parent
commit
9e0db34dd2

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

@ -22,6 +22,12 @@ public interface QuestionDao {
22 22
	@DeleteWith
23 23
	@From(QetKeyWord.class)
24 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 32
	@Insert
27 33
	@Batch
@ -43,6 +49,8 @@ public interface QuestionDao {
43 49
	@Nullable
44 50
	Question query(Connection con, String id) throws SQLException;
45 51
	
52

53
	
46 54
	@SelectOne
47 55
	@Nullable
48 56
	Answer queryAnswer(Connection con,String id)throws SQLException;
@ -59,6 +67,10 @@ public interface QuestionDao {
59 67
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
60 68
	@Where("QID IN(SELECT ID FROM QUESTION WHERE STATE='1') AND STATE='1'")
61 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 75
	@LimitSelect
64 76
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")

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

@ -274,9 +274,21 @@ public class Service {
274 274
			}
275 275
			throw e;
276 276
		}
277
		questionDao.incQuestionReply(con, qid);
277 278
		notifyService.notify(con, q.getUid(), uid, uname, qid, q.getTitle(), NotifyType.ANSWER_QUESTION, runs);
278 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,7 +8,7 @@ import org.jfw.apt.orm.core.defaultImpl.LongHandler;
8 8
public class SortedAnswwer extends Answer {
9 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 12
	public long getScore() {
13 13
		return score;
14 14
	}