jiapeng 7 years ago
parent
commit
e375a7b364

+ 4 - 3
src/main/java/com/ekexiu/portal/found/Service.java

@ -39,14 +39,15 @@ public class Service {
39 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 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 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() {
42
        "WHERE T.tm<? OR (T.tm = ? AND T.id > ?) ORDER BY tm DESC LIMIT ?", new PreparedStatementConfig() {
43 43
			@Override
44 44
			public void config(PreparedStatement ps) throws SQLException {
45 45
				ps.setString(1,ex);
46 46
				ps.setString(2, ex);
47 47
				ps.setString(3, time);
48
				ps.setString(4, id);
49
				ps.setInt(5,rows);
48
				ps.setString(4, time);
49
				ps.setString(5, id);
50
				ps.setInt(6,rows);
50 51
			}
51 52
		});
52 53
	}

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

@ -5,12 +5,11 @@ import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5 5
import org.jfw.apt.orm.annotation.entry.Table;
6 6
import org.jfw.apt.orm.core.enums.DE;
7 7

8
import com.ekexiu.portal.basepo.CreateTimeSupported;
9 8
import com.ekexiu.portal.basepo.ModifyTimeSupported;
10 9

11 10
@PrimaryKey("id")
12 11
@Table
13
public class LeaveMsg implements CreateTimeSupported,ModifyTimeSupported {
12
public class LeaveMsg implements ModifyTimeSupported {
14 13

15 14
	private String id;
16 15
	private String cnt;
@ -25,6 +24,15 @@ public class LeaveMsg implements CreateTimeSupported,ModifyTimeSupported {
25 24
	private String state;
26 25
	private long  agreeCount;
27 26
	
27
	private transient String timeDesc;
28
	
29
	@Column(DE.text_de)
30
	public String getTimeDesc() {
31
		return timeDesc;
32
	}
33
	public void setTimeDesc(String timeDesc) {
34
		this.timeDesc = timeDesc;
35
	}
28 36
	/**
29 37
	 * id
30 38
	 * @return
@ -113,6 +121,7 @@ public class LeaveMsg implements CreateTimeSupported,ModifyTimeSupported {
113 121
	public void setReciver(String reciver) {
114 122
		this.reciver = reciver;
115 123
	}
124
	@Column(DE.text_de)
116 125
	public String getCreateTime() {
117 126
		return createTime;
118 127
	}

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

@ -1,21 +1,28 @@
1 1
package com.ekexiu.portal.leavemsg;
2 2

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

3 7
import org.jfw.apt.annotation.DefaultValue;
4 8
import org.jfw.apt.annotation.Nullable;
5 9
import org.jfw.apt.orm.annotation.dao.Column;
6 10
import org.jfw.apt.orm.annotation.dao.DAO;
7
import org.jfw.apt.orm.annotation.dao.method.*;
8
import org.jfw.apt.orm.annotation.dao.method.operator.*;
11
import org.jfw.apt.orm.annotation.dao.method.From;
12
import org.jfw.apt.orm.annotation.dao.method.IncludeFixSet;
13
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
14
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
15
import org.jfw.apt.orm.annotation.dao.method.Where;
16
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
17
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
18
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
19
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
20
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
9 21
import org.jfw.apt.orm.annotation.dao.param.GreaterThan;
10 22
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
11
import org.jfw.apt.orm.annotation.dao.param.GtEq;
12 23
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
13 24
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
14 25

15
import java.sql.Connection;
16
import java.sql.SQLException;
17
import java.util.List;
18

19 26
@DAO
20 27
public interface LeaveMsgDao {
21 28

@ -37,8 +44,8 @@ public interface LeaveMsgDao {
37 44

38 45
	@LimitSelect
39 46
	@Where("STATE='1'")
40
	@OrderBy("ORDER BY CREATE_TIME ASC,ID ASC")
41
	List<LeaveMsg> query(Connection con, String refId, String refType, @GtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
47
	@OrderBy("ORDER BY TIME_DESC ASC")
48
	List<LeaveMsg> query(Connection con, String refId, String refType, @GreaterThan String timeDesc, int rows) throws SQLException;
42 49

43 50
	@Nullable
44 51
	@SelectOne
@ -52,15 +59,15 @@ public interface LeaveMsgDao {
52 59
	LeaveMsgAgreeRec queryAgreeRec(Connection con, String id, String uid) throws SQLException;
53 60

54 61
	@LimitSelect
55
	@OrderBy("ORDER BY CREATE_TIME ASC,ID ASC")
56
	List<LeaveMsg> queryWithParent(Connection con, String parent, @GtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
62
	@OrderBy("ORDER BY TIME_DESC ASC")
63
	List<LeaveMsg> queryWithParent(Connection con, String parent, @GreaterThan String timeDesc, int rows) throws SQLException;
57 64

58 65
	@LimitSelect
59
	@OrderBy("ORDER BY CREATE_TIME ASC,ID ASC")
66
	@OrderBy("ORDER BY TIME_DESC ASC")
60 67
	List<LeaveMsg> queryWithTop(Connection con, String top,
61 68
			@GroupSqlColumn(handlerClass = StringHandler.class, isAnd = false, value = { "SENDER=?", "RECIVER=?" }, force = true) String sid,
62 69
			@GroupSqlColumn(handlerClass = StringHandler.class, isAnd = false, value = { "SENDER=?", "RECIVER=?" }, force = true) String rid,
63
			@GtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
70
			 @GreaterThan String timeDesc,int rows) throws SQLException;
64 71

65 72
	@QueryVal
66 73
	@From(LeaveMsg.class)

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

@ -8,7 +8,6 @@ import java.util.Map;
8 8

9 9
import org.jfw.apt.annotation.Autowrie;
10 10
import org.jfw.apt.annotation.DefaultValue;
11
import org.jfw.apt.annotation.Nullable;
12 11
import org.jfw.apt.web.annotation.Path;
13 12
import org.jfw.apt.web.annotation.operate.Get;
14 13
import org.jfw.apt.web.annotation.operate.Post;
@ -16,6 +15,7 @@ import org.jfw.apt.web.annotation.param.AfterCommit;
16 15
import org.jfw.apt.web.annotation.param.FieldParam;
17 16
import org.jfw.apt.web.annotation.param.JdbcConn;
18 17
import org.jfw.apt.web.annotation.param.RequestParam;
18
import org.jfw.util.DateUtil;
19 19
import org.jfw.util.StringUtil;
20 20
import org.jfw.util.exception.JfwBaseException;
21 21
import org.jfw.util.jdbc.JdbcUtil;
@ -209,11 +209,14 @@ public class Service {
209 209
					@FieldParam(value = "refType", valueClass = String.class), @FieldParam(value = "sender", valueClass = String.class) }) LeaveMsg msg,
210 210
			 String uname, @AfterCommit List<Runnable> runs) throws SQLException, JfwBaseException {
211 211
		String id = StringUtil.buildUUID();
212
		String time = DateUtil.formatDate(System.currentTimeMillis());
212 213
		msg.setId(id);
213 214
		msg.setTop(id);
214 215
		msg.setState("1");
215 216
		msg.setParent(null);
216 217
		msg.setAgreeCount(0);
218
		msg.setCreateTime(time);
219
		msg.setTimeDesc(time+id);
217 220
		leaveMsgDao.insert(con, msg);
218 221
		this.notify(con, msg.getRefType(), msg.getRefId(), null, msg.getSender(), uname, id,false, runs);
219 222
		return id;
@ -255,6 +258,9 @@ public class Service {
255 258
		msg.setState("1");
256 259
		msg.setCnt(cnt);
257 260
		msg.setId(nid);
261
		String time = DateUtil.formatDate(System.currentTimeMillis());
262
		msg.setCreateTime(time);
263
		msg.setTimeDesc(time+nid);
258 264
		leaveMsgDao.insert(con, msg);
259 265
		this.notify(con, msg.getRefType(), msg.getRefId(), msg.getReciver(), uid, uname, id,false, runs);
260 266
		return nid;
@ -281,7 +287,7 @@ public class Service {
281 287
	@Path("/subject")
282 288
	public List<LeaveMsg> query(@JdbcConn Connection con, String stype, String sid, @DefaultValue("\"0\"") String time, @DefaultValue("\"0\"") String id,
283 289
			int rows) throws SQLException {
284
		return leaveMsgDao.query(con, sid, stype, time, id, rows);
290
		return leaveMsgDao.query(con, sid, stype, time+id, rows);
285 291
	}
286 292

287 293
	@Get
@ -431,10 +437,10 @@ public class Service {
431 437
		if (msg == null)
432 438
			throw new JfwBaseException(50000, "leave message[id:" + id + "] not found");
433 439
		if (msg.getId().equals(msg.getTop())) {
434
			ret = leaveMsgDao.queryWithParent(con, msg.getId(), "0", "0", Integer.MAX_VALUE);
440
			ret = leaveMsgDao.queryWithParent(con, msg.getId(), "0", Integer.MAX_VALUE);
435 441
			ret.add(0, msg);
436 442
		} else {
437
			ret = leaveMsgDao.queryWithTop(con, msg.getId(), msg.getSender(), msg.getReciver(), "0", "0", Integer.MAX_VALUE);
443
			ret = leaveMsgDao.queryWithTop(con, msg.getId(), msg.getSender(), msg.getReciver(), "0", Integer.MAX_VALUE);
438 444
		}
439 445
		return ret;
440 446
	}

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

@ -17,6 +17,15 @@ public class NotifyMsgCnt{
17 17
	private String uid;
18 18
	private String createTime;
19 19
	private int opType;
20
	
21
	private transient String timeDesc;
22
	@Column(DE.text_de)
23
	public String getTimeDesc() {
24
		return timeDesc;
25
	}
26
	public void setTimeDesc(String timeDesc) {
27
		this.timeDesc = timeDesc;
28
	}
20 29
	@Column(DE.id_32)
21 30
	public String getId() {
22 31
		return id;

+ 4 - 5
src/main/java/com/ekexiu/portal/notify/NotifyMsgDao.java

@ -14,8 +14,7 @@ import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
14 14
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
15 15
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
16 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;
17
import org.jfw.apt.orm.annotation.dao.param.LessThan;
19 18
import org.jfw.apt.orm.annotation.dao.param.LtEq;
20 19
import org.jfw.apt.orm.annotation.dao.param.Set;
21 20

@ -41,12 +40,12 @@ public interface NotifyMsgDao {
41 40
	
42 41
	
43 42
	@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;
43
	@OrderBy("ORDER BY TIME_DESC DESC")
44
	List<NotifyMsgCnt> queryCnt(Connection con,String reciver,@LessThan String timeDesc,int rows)throws SQLException;
46 45
	
47 46
	@UpdateWith
48 47
	@From(NotifyMsgCnt.class)
49 48
	@SetSentence("READED='1'")
50 49
	@Where("READED<>'1'")
51
	int readed(Connection con,String reciver ,@LtEq String createTime,@GtEq String id)throws SQLException; 
50
	int readed(Connection con,String reciver ,@LtEq String timeDesc)throws SQLException; 
52 51
}

+ 3 - 2
src/main/java/com/ekexiu/portal/notify/NotifyService.java

@ -54,6 +54,7 @@ public class NotifyService {
54 54
		cnt.setReaded(false);
55 55
		cnt.setReciver(rid);
56 56
		cnt.setUid(uid);
57
		cnt.setTimeDesc(time+id);
57 58
		notifyMsgDao.insert(con, cnt);
58 59
		final NotifyMsgIdx idx = new NotifyMsgIdx();
59 60
		idx.setLastCnt(tCnt);
@ -86,12 +87,12 @@ public class NotifyService {
86 87
	@Get
87 88
	public List<NotifyMsgCnt> query(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String mid,
88 89
			@DefaultValue("20") int rows) throws SQLException {
89
		return notifyMsgDao.queryCnt(con, uid, time, mid, rows);
90
		return notifyMsgDao.queryCnt(con, uid, time+mid, rows);
90 91
	}
91 92
	@Post
92 93
	@Path("/readed")
93 94
	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
		int num = this.notifyMsgDao.readed(con, uid,time+mid);
95 96
		if(num>0){
96 97
			this.notifyMsgDao.decUnRead(con, uid,num);
97 98
		}

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

@ -7,12 +7,11 @@ import org.jfw.apt.orm.annotation.entry.Unique;
7 7
import org.jfw.apt.orm.annotation.entry.Uniques;
8 8
import org.jfw.apt.orm.core.enums.DE;
9 9

10
import com.ekexiu.portal.basepo.CreateTimeSupported;
11 10
import com.ekexiu.portal.basepo.ModifyTimeSupported;
12 11
@PrimaryKey("id")
13 12
@Uniques({@Unique(clolumns={"qid","uid"},name="UNI_ANSWER_QID_UID")})
14 13
@Table
15
public class Answer  implements CreateTimeSupported,ModifyTimeSupported{
14
public class Answer  implements ModifyTimeSupported{
16 15
	private String id;
17 16
	private String qid;
18 17
	private String uid;
@ -23,6 +22,15 @@ public class Answer  implements CreateTimeSupported,ModifyTimeSupported{
23 22
	private long  ballot;
24 23
	private String createTime;
25 24
	private String modifyTime;
25
	private transient String timeDesc;
26
	
27
	@Column(DE.text_de)
28
	public String getTimeDesc() {
29
		return timeDesc;
30
	}
31
	public void setTimeDesc(String timeDesc) {
32
		this.timeDesc = timeDesc;
33
	}
26 34
	/**
27 35
	 * ID
28 36
	 * @return
@ -99,6 +107,7 @@ public class Answer  implements CreateTimeSupported,ModifyTimeSupported{
99 107
	public void setBallot(long ballot) {
100 108
		this.ballot = ballot;
101 109
	}
110
	@Column(DE.text_de)
102 111
	public String getCreateTime() {
103 112
		return createTime;
104 113
	}

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

@ -11,7 +11,7 @@ import com.ekexiu.portal.basepo.ModifyTimeSupported;
11 11

12 12
@PrimaryKey("id")
13 13
@Table
14
public class Question implements CreateTimeSupported,ModifyTimeSupported{
14
public class Question implements ModifyTimeSupported{
15 15
	
16 16
	private String id;
17 17
	private String title;
@ -24,7 +24,16 @@ public class Question implements CreateTimeSupported,ModifyTimeSupported{
24 24
	private String lastReplyTime;
25 25
	private long replyCount;
26 26
	private String state;
27
	private transient String timeDesc;
27 28
	
29
	
30
	@Column(DE.text_de)
31
	public String getTimeDesc() {
32
		return timeDesc;
33
	}
34
	public void setTimeDesc(String timeDesc) {
35
		this.timeDesc = timeDesc;
36
	}
28 37
	/**
29 38
	 * ID
30 39
	 * @return
@ -65,6 +74,7 @@ public class Question implements CreateTimeSupported,ModifyTimeSupported{
65 74
	public void setImg(String img) {
66 75
		this.img = img;
67 76
	}
77
	@Column(DE.text_de)
68 78
	public String getCreateTime() {
69 79
		return createTime;
70 80
	}

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

@ -34,16 +34,16 @@ public interface QuestionDao {
34 34
	int[] insert(Connection con, QetKeyWord[] kws) throws SQLException;
35 35

36 36
	@LimitSelect
37
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
38
	List<Question> query(Connection con, @Nullable String state, @Nullable String uid, @LtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
37
	@OrderBy("ORDER BY TIME_DESC DESC")
38
	List<Question> query(Connection con, @Nullable String state, @Nullable String uid, @LessThan String timeDesc, int rows) throws SQLException;
39 39

40 40
	@LimitSelect
41
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
41
	@OrderBy("ORDER BY TIME_DESC DESC")
42 42
	@Where(" STATE='1'")
43 43
	List<Question> watch(Connection con,
44 44
			@SqlColumn(handlerClass = StringHandler.class, value = {
45 45
					" ID IN (SELECT WATCH_OBJECT FROM WATCH WHERE WATCH_TYPE='8' AND PROFESSOR_ID=?)" }) String uid,
46
			@LtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
46
			@LessThan String timeDesc, int rows) throws SQLException;
47 47

48 48
	@SelectOne
49 49
	@Nullable
@ -64,33 +64,33 @@ public interface QuestionDao {
64 64
	List<Question> query(Connection con, @In String[] id) throws SQLException;
65 65
	
66 66
	@LimitSelect
67
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
67
	@OrderBy("ORDER BY TIME_DESC DESC")
68 68
	@Where("QID IN(SELECT ID FROM QUESTION WHERE STATE='1') AND STATE='1'")
69
	List<Answer> answer(Connection con,@LtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
69
	List<Answer> answer(Connection con,@LessThan String timeDesc, int rows) throws SQLException;
70 70

71 71
	@LimitSelect
72
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
72
	@OrderBy("ORDER BY TIME_DESC DESC")
73 73
	@Where("QID IN(SELECT ID FROM QUESTION WHERE STATE='1') AND STATE='1'")
74
	List<Answer> answerSelf(Connection con, String uid, @LtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
74
	List<Answer> answerSelf(Connection con, String uid, @LessThan String timeDesc, int rows) throws SQLException;
75 75
	
76 76
	@SelectOne
77 77
	@Nullable
78 78
	Answer answer(Connection con,String uid,String qid)throws SQLException;
79 79

80 80
	@LimitSelect
81
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
81
	@OrderBy("ORDER BY TIME_DESC DESC")
82 82
	@Where("QID IN(SELECT ID FROM QUESTION WHERE STATE='1') AND STATE='1'")
83 83
	List<Answer> watchAnswer(Connection con,
84 84
			@SqlColumn(handlerClass = StringHandler.class, value = {
85 85
					" ID IN (SELECT WATCH_OBJECT FROM WATCH WHERE WATCH_TYPE='9' AND PROFESSOR_ID=?)" }) String uid,
86
			@LtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
86
			@LessThan String timeDesc, int rows) throws SQLException;
87 87

88 88
	@LimitSelect
89
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
90
	List<Answer> byQes(Connection con, String qid, @LtEq String createTime, @GreaterThan String id, int rows) throws SQLException;
89
	@OrderBy("ORDER BY TIME_DESC DESC")
90
	List<Answer> byQes(Connection con, String qid, @LessThan String timeDesc, int rows) throws SQLException;
91 91
	@LimitQuery
92 92
	@OrderBy("ORDER BY SCORE DESC,ID ASC")
93
	List<SortedAnswwer> byQes(Connection con, String qid, @SqlColumn(handlerClass = IntHandler.class, value = { "(10000 * AGREE+1) / (BALLOT+1) <= ?  " }) int score, @GreaterThan String id, int rows) throws SQLException;
93
	List<SortedAnswwer> byQesScore(Connection con, String qid, @SqlColumn(handlerClass = StringHandler.class, value = { "(TO_CHAR((10000 * (AGREE+1)) / (BALLOT+1),'00009')+ID) < ?  " })  String score, int rows) throws SQLException;
94 94

95 95
	@Insert
96 96
	int insert(Connection con,AnswerAgreeRec aar)throws SQLException;

+ 10 - 8
src/main/java/com/ekexiu/portal/question/Service.java

@ -340,7 +340,7 @@ public class Service {
340 340
	@Path()
341 341
	public List<Question> query(@JdbcConn Connection con, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
342 342
			@DefaultValue("10000000") int rows) throws SQLException {
343
		return questionDao.query(con, "1", null, time, id, rows);
343
		return questionDao.query(con, "1", null, time+id, rows);
344 344
	}
345 345

346 346
	/**
@ -362,7 +362,7 @@ public class Service {
362 362
	@Path("/my")
363 363
	public List<Question> querySelf(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
364 364
			@DefaultValue("10000000") int rows) throws SQLException {
365
		return questionDao.query(con, "1", uid, time, id, rows);
365
		return questionDao.query(con, "1", uid, time+id, rows);
366 366
	}
367 367

368 368
	/**
@ -384,7 +384,7 @@ public class Service {
384 384
	@Path("/watch")
385 385
	public List<Question> watch(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
386 386
			@DefaultValue("10000000") int rows) throws SQLException {
387
		return questionDao.watch(con, uid, time, id, rows);
387
		return questionDao.watch(con, uid, time+ id, rows);
388 388
	}
389 389

390 390
	/**
@ -406,7 +406,7 @@ public class Service {
406 406
	@Path("/answer/bySelf")
407 407
	public List<Answer> answerSelf(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
408 408
			@DefaultValue("10000000") int rows) throws SQLException {
409
		return questionDao.answerSelf(con, uid, time, id, rows);
409
		return questionDao.answerSelf(con, uid, time+id, rows);
410 410
	}
411 411

412 412
	/**
@ -428,7 +428,7 @@ public class Service {
428 428
	@Path("/answer/byWatch")
429 429
	public List<Answer> answerWatch(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
430 430
			@DefaultValue("10000000") int rows) throws SQLException {
431
		return questionDao.watchAnswer(con, uid, time, id, rows);
431
		return questionDao.watchAnswer(con, uid, time+id, rows);
432 432
	}
433 433
	
434 434
	/**
@ -446,7 +446,7 @@ public class Service {
446 446
	@Path("/answer/byTime")
447 447
	public List<Answer> answerByTime(@JdbcConn Connection con,@DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
448 448
			@DefaultValue("10000000") int rows) throws SQLException {
449
		return questionDao.answer(con,  time, id, rows);
449
		return questionDao.answer(con,  time+ id, rows);
450 450
	}
451 451
	/**
452 452
	 * 指定提问的回答(按最新回答时间,由新到旧排序)
@ -467,7 +467,7 @@ public class Service {
467 467
	@Path("/answer/qes/byTime")
468 468
	public List<Answer> byQes(@JdbcConn Connection con, String qid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
469 469
			@DefaultValue("10000000") int rows) throws SQLException {
470
		return questionDao.byQes(con, qid, time, id, rows);
470
		return questionDao.byQes(con, qid, time+id, rows);
471 471
	}
472 472

473 473
	/**
@ -489,7 +489,9 @@ public class Service {
489 489
	@Path("/answer/qes/byScore")
490 490
	public List<SortedAnswwer> byQes(@JdbcConn Connection con, String qid, @DefaultValue("100000") int score, @DefaultValue("\"0\"") String id,
491 491
			@DefaultValue("10000000") int rows) throws SQLException {
492
		return questionDao.byQes(con, qid, score, id, rows);
492
		String p = "000000"+score;
493
		p = p.substring(p.length()-5)+id;
494
		return questionDao.byQesScore(con, qid, p, rows);
493 495
	}
494 496
	
495 497
	

+ 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+1) / (ballot+1) 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
	}

+ 7 - 4
src/main/resources/database.sql

@ -2100,7 +2100,8 @@ COMMENT ON COLUMN WEB_MSG_CNT.READED is '消息是否已读';
2100 2100

2101 2101
--modify begin at version2.20
2102 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);
2103
TOP TEXT NOT NULL,PARENT TEXT,SENDER TEXT NOT NULL,RECIVER TEXT,STATE CHAR(1) NOT NULL,AGREE_COUNT BIGINT NOT NULL,
2104
CREATE_TIME CHAR(14) NOT NULL,MODIFY_TIME CHAR(14) NOT NULL,TIME_DESC TEXT NOT NULL);
2104 2105
ALTER TABLE LEAVE_MSG ADD PRIMARY KEY (ID);
2105 2106
COMMENT ON TABLE LEAVE_MSG is '留言表(新)';
2106 2107
COMMENT ON COLUMN LEAVE_MSG.ID is '留言ID';
@ -2124,7 +2125,8 @@ COMMENT ON COLUMN LEAVE_MSG_AGREE_REC.UID is '点赞人ID';
2124 2125
CREATE TABLE QUESTION (ID CHAR(32) NOT NULL,TITLE TEXT NOT NULL,
2125 2126
CNT TEXT,IMG TEXT,KEYS TEXT NOT NULL,
2126 2127
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
REPLY_COUNT BIGINT NOT NULL,STATE CHAR(1) NOT NULL,CREATE_TIME CHAR(14) NOT NULL,
2129
TIME_DESC TEXT NOT NULL,MODIFY_TIME CHAR(14) NOT NULL);
2128 2130
ALTER TABLE QUESTION ADD PRIMARY KEY (ID);
2129 2131
COMMENT ON TABLE QUESTION is '提问表';
2130 2132
COMMENT ON COLUMN QUESTION.ID is '提问ID';
@ -2140,7 +2142,8 @@ COMMENT ON COLUMN QUESTION.STATE is '状态 1:发布中';
2140 2142

2141 2143

2142 2144
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);
2145
CNT TEXT NOT NULL,AGREE BIGINT NOT NULL,BALLOT BIGINT NOT NULL,CREATE_TIME CHAR(14) NOT NULL,
2146
TIME_DESC TEXT NOT NULL,MODIFY_TIME CHAR(14) NOT NULL);
2144 2147
ALTER TABLE ANSWER ADD PRIMARY KEY (ID);
2145 2148
ALTER TABLE ANSWER ADD UNIQUE (QID,UID);
2146 2149
COMMENT ON TABLE ANSWER is '回答表';
@ -2173,7 +2176,7 @@ COMMENT ON COLUMN NOTIFY_MSG_IDX.LAST_TIME is '最后通知时间';
2173 2176
COMMENT ON COLUMN NOTIFY_MSG_IDX.UN_READ is '未读通知数';
2174 2177

2175 2178
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);
2179
PID TEXT NOT NULL,UID TEXT NOT NULL,CREATE_TIME TEXT NOT NULL,OP_TYPE INTEGER NOT NULL,TIME_DESC TEXT NOT NULL);
2177 2180
ALTER TABLE NOTIFY_MSG_CNT ADD PRIMARY KEY (ID);
2178 2181
COMMENT ON TABLE NOTIFY_MSG_CNT is '通知内容表';
2179 2182
COMMENT ON COLUMN NOTIFY_MSG_CNT.ID is '通知ID';