jiapeng 7 gadi atpakaļ
vecāks
revīzija
e375a7b364

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

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 "+
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
		"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 "+
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
		"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 "+
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
			@Override
43
			@Override
44
			public void config(PreparedStatement ps) throws SQLException {
44
			public void config(PreparedStatement ps) throws SQLException {
45
				ps.setString(1,ex);
45
				ps.setString(1,ex);
46
				ps.setString(2, ex);
46
				ps.setString(2, ex);
47
				ps.setString(3, time);
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
import org.jfw.apt.orm.annotation.entry.Table;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
6
import org.jfw.apt.orm.core.enums.DE;
7

7

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

9

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

13

15
	private String id;
14
	private String id;
16
	private String cnt;
15
	private String cnt;
25
	private String state;
24
	private String state;
26
	private long  agreeCount;
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
	 * id
37
	 * id
30
	 * @return
38
	 * @return
113
	public void setReciver(String reciver) {
121
	public void setReciver(String reciver) {
114
		this.reciver = reciver;
122
		this.reciver = reciver;
115
	}
123
	}
124
	@Column(DE.text_de)
116
	public String getCreateTime() {
125
	public String getCreateTime() {
117
		return createTime;
126
		return createTime;
118
	}
127
	}

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

1
package com.ekexiu.portal.leavemsg;
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
import org.jfw.apt.annotation.DefaultValue;
7
import org.jfw.apt.annotation.DefaultValue;
4
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.annotation.Nullable;
5
import org.jfw.apt.orm.annotation.dao.Column;
9
import org.jfw.apt.orm.annotation.dao.Column;
6
import org.jfw.apt.orm.annotation.dao.DAO;
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
import org.jfw.apt.orm.annotation.dao.param.GreaterThan;
21
import org.jfw.apt.orm.annotation.dao.param.GreaterThan;
10
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
22
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
11
import org.jfw.apt.orm.annotation.dao.param.GtEq;
12
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
23
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
13
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
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
@DAO
26
@DAO
20
public interface LeaveMsgDao {
27
public interface LeaveMsgDao {
21

28

37

44

38
	@LimitSelect
45
	@LimitSelect
39
	@Where("STATE='1'")
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
	@Nullable
50
	@Nullable
44
	@SelectOne
51
	@SelectOne
52
	LeaveMsgAgreeRec queryAgreeRec(Connection con, String id, String uid) throws SQLException;
59
	LeaveMsgAgreeRec queryAgreeRec(Connection con, String id, String uid) throws SQLException;
53

60

54
	@LimitSelect
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
	@LimitSelect
65
	@LimitSelect
59
	@OrderBy("ORDER BY CREATE_TIME ASC,ID ASC")
66
	@OrderBy("ORDER BY TIME_DESC ASC")
60
	List<LeaveMsg> queryWithTop(Connection con, String top,
67
	List<LeaveMsg> queryWithTop(Connection con, String top,
61
			@GroupSqlColumn(handlerClass = StringHandler.class, isAnd = false, value = { "SENDER=?", "RECIVER=?" }, force = true) String sid,
68
			@GroupSqlColumn(handlerClass = StringHandler.class, isAnd = false, value = { "SENDER=?", "RECIVER=?" }, force = true) String sid,
62
			@GroupSqlColumn(handlerClass = StringHandler.class, isAnd = false, value = { "SENDER=?", "RECIVER=?" }, force = true) String rid,
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
	@QueryVal
72
	@QueryVal
66
	@From(LeaveMsg.class)
73
	@From(LeaveMsg.class)

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

8

8

9
import org.jfw.apt.annotation.Autowrie;
9
import org.jfw.apt.annotation.Autowrie;
10
import org.jfw.apt.annotation.DefaultValue;
10
import org.jfw.apt.annotation.DefaultValue;
11
import org.jfw.apt.annotation.Nullable;
12
import org.jfw.apt.web.annotation.Path;
11
import org.jfw.apt.web.annotation.Path;
13
import org.jfw.apt.web.annotation.operate.Get;
12
import org.jfw.apt.web.annotation.operate.Get;
14
import org.jfw.apt.web.annotation.operate.Post;
13
import org.jfw.apt.web.annotation.operate.Post;
16
import org.jfw.apt.web.annotation.param.FieldParam;
15
import org.jfw.apt.web.annotation.param.FieldParam;
17
import org.jfw.apt.web.annotation.param.JdbcConn;
16
import org.jfw.apt.web.annotation.param.JdbcConn;
18
import org.jfw.apt.web.annotation.param.RequestParam;
17
import org.jfw.apt.web.annotation.param.RequestParam;
18
import org.jfw.util.DateUtil;
19
import org.jfw.util.StringUtil;
19
import org.jfw.util.StringUtil;
20
import org.jfw.util.exception.JfwBaseException;
20
import org.jfw.util.exception.JfwBaseException;
21
import org.jfw.util.jdbc.JdbcUtil;
21
import org.jfw.util.jdbc.JdbcUtil;
209
					@FieldParam(value = "refType", valueClass = String.class), @FieldParam(value = "sender", valueClass = String.class) }) LeaveMsg msg,
209
					@FieldParam(value = "refType", valueClass = String.class), @FieldParam(value = "sender", valueClass = String.class) }) LeaveMsg msg,
210
			 String uname, @AfterCommit List<Runnable> runs) throws SQLException, JfwBaseException {
210
			 String uname, @AfterCommit List<Runnable> runs) throws SQLException, JfwBaseException {
211
		String id = StringUtil.buildUUID();
211
		String id = StringUtil.buildUUID();
212
		String time = DateUtil.formatDate(System.currentTimeMillis());
212
		msg.setId(id);
213
		msg.setId(id);
213
		msg.setTop(id);
214
		msg.setTop(id);
214
		msg.setState("1");
215
		msg.setState("1");
215
		msg.setParent(null);
216
		msg.setParent(null);
216
		msg.setAgreeCount(0);
217
		msg.setAgreeCount(0);
218
		msg.setCreateTime(time);
219
		msg.setTimeDesc(time+id);
217
		leaveMsgDao.insert(con, msg);
220
		leaveMsgDao.insert(con, msg);
218
		this.notify(con, msg.getRefType(), msg.getRefId(), null, msg.getSender(), uname, id,false, runs);
221
		this.notify(con, msg.getRefType(), msg.getRefId(), null, msg.getSender(), uname, id,false, runs);
219
		return id;
222
		return id;
255
		msg.setState("1");
258
		msg.setState("1");
256
		msg.setCnt(cnt);
259
		msg.setCnt(cnt);
257
		msg.setId(nid);
260
		msg.setId(nid);
261
		String time = DateUtil.formatDate(System.currentTimeMillis());
262
		msg.setCreateTime(time);
263
		msg.setTimeDesc(time+nid);
258
		leaveMsgDao.insert(con, msg);
264
		leaveMsgDao.insert(con, msg);
259
		this.notify(con, msg.getRefType(), msg.getRefId(), msg.getReciver(), uid, uname, id,false, runs);
265
		this.notify(con, msg.getRefType(), msg.getRefId(), msg.getReciver(), uid, uname, id,false, runs);
260
		return nid;
266
		return nid;
281
	@Path("/subject")
287
	@Path("/subject")
282
	public List<LeaveMsg> query(@JdbcConn Connection con, String stype, String sid, @DefaultValue("\"0\"") String time, @DefaultValue("\"0\"") String id,
288
	public List<LeaveMsg> query(@JdbcConn Connection con, String stype, String sid, @DefaultValue("\"0\"") String time, @DefaultValue("\"0\"") String id,
283
			int rows) throws SQLException {
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
	@Get
293
	@Get
431
		if (msg == null)
437
		if (msg == null)
432
			throw new JfwBaseException(50000, "leave message[id:" + id + "] not found");
438
			throw new JfwBaseException(50000, "leave message[id:" + id + "] not found");
433
		if (msg.getId().equals(msg.getTop())) {
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
			ret.add(0, msg);
441
			ret.add(0, msg);
436
		} else {
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
		return ret;
445
		return ret;
440
	}
446
	}

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

17
	private String uid;
17
	private String uid;
18
	private String createTime;
18
	private String createTime;
19
	private int opType;
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
	@Column(DE.id_32)
29
	@Column(DE.id_32)
21
	public String getId() {
30
	public String getId() {
22
		return id;
31
		return id;

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

14
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
14
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
15
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
15
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
16
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
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
import org.jfw.apt.orm.annotation.dao.param.LtEq;
18
import org.jfw.apt.orm.annotation.dao.param.LtEq;
20
import org.jfw.apt.orm.annotation.dao.param.Set;
19
import org.jfw.apt.orm.annotation.dao.param.Set;
21

20

41
	
40
	
42
	
41
	
43
	@LimitSelect
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
	@UpdateWith
46
	@UpdateWith
48
	@From(NotifyMsgCnt.class)
47
	@From(NotifyMsgCnt.class)
49
	@SetSentence("READED='1'")
48
	@SetSentence("READED='1'")
50
	@Where("READED<>'1'")
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
		cnt.setReaded(false);
54
		cnt.setReaded(false);
55
		cnt.setReciver(rid);
55
		cnt.setReciver(rid);
56
		cnt.setUid(uid);
56
		cnt.setUid(uid);
57
		cnt.setTimeDesc(time+id);
57
		notifyMsgDao.insert(con, cnt);
58
		notifyMsgDao.insert(con, cnt);
58
		final NotifyMsgIdx idx = new NotifyMsgIdx();
59
		final NotifyMsgIdx idx = new NotifyMsgIdx();
59
		idx.setLastCnt(tCnt);
60
		idx.setLastCnt(tCnt);
86
	@Get
87
	@Get
87
	public List<NotifyMsgCnt> query(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String mid,
88
	public List<NotifyMsgCnt> query(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String mid,
88
			@DefaultValue("20") int rows) throws SQLException {
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
	@Post
92
	@Post
92
	@Path("/readed")
93
	@Path("/readed")
93
	public int read(@JdbcConn(true) Connection con,String uid,String time,String mid)throws SQLException{
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
		if(num>0){
96
		if(num>0){
96
			this.notifyMsgDao.decUnRead(con, uid,num);
97
			this.notifyMsgDao.decUnRead(con, uid,num);
97
		}
98
		}

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

7
import org.jfw.apt.orm.annotation.entry.Uniques;
7
import org.jfw.apt.orm.annotation.entry.Uniques;
8
import org.jfw.apt.orm.core.enums.DE;
8
import org.jfw.apt.orm.core.enums.DE;
9

9

10
import com.ekexiu.portal.basepo.CreateTimeSupported;
11
import com.ekexiu.portal.basepo.ModifyTimeSupported;
10
import com.ekexiu.portal.basepo.ModifyTimeSupported;
12
@PrimaryKey("id")
11
@PrimaryKey("id")
13
@Uniques({@Unique(clolumns={"qid","uid"},name="UNI_ANSWER_QID_UID")})
12
@Uniques({@Unique(clolumns={"qid","uid"},name="UNI_ANSWER_QID_UID")})
14
@Table
13
@Table
15
public class Answer  implements CreateTimeSupported,ModifyTimeSupported{
14
public class Answer  implements ModifyTimeSupported{
16
	private String id;
15
	private String id;
17
	private String qid;
16
	private String qid;
18
	private String uid;
17
	private String uid;
23
	private long  ballot;
22
	private long  ballot;
24
	private String createTime;
23
	private String createTime;
25
	private String modifyTime;
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
	 * ID
35
	 * ID
28
	 * @return
36
	 * @return
99
	public void setBallot(long ballot) {
107
	public void setBallot(long ballot) {
100
		this.ballot = ballot;
108
		this.ballot = ballot;
101
	}
109
	}
110
	@Column(DE.text_de)
102
	public String getCreateTime() {
111
	public String getCreateTime() {
103
		return createTime;
112
		return createTime;
104
	}
113
	}

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

11

11

12
@PrimaryKey("id")
12
@PrimaryKey("id")
13
@Table
13
@Table
14
public class Question implements CreateTimeSupported,ModifyTimeSupported{
14
public class Question implements ModifyTimeSupported{
15
	
15
	
16
	private String id;
16
	private String id;
17
	private String title;
17
	private String title;
24
	private String lastReplyTime;
24
	private String lastReplyTime;
25
	private long replyCount;
25
	private long replyCount;
26
	private String state;
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
	 * ID
38
	 * ID
30
	 * @return
39
	 * @return
65
	public void setImg(String img) {
74
	public void setImg(String img) {
66
		this.img = img;
75
		this.img = img;
67
	}
76
	}
77
	@Column(DE.text_de)
68
	public String getCreateTime() {
78
	public String getCreateTime() {
69
		return createTime;
79
		return createTime;
70
	}
80
	}

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

34
	int[] insert(Connection con, QetKeyWord[] kws) throws SQLException;
34
	int[] insert(Connection con, QetKeyWord[] kws) throws SQLException;
35

35

36
	@LimitSelect
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
	@LimitSelect
40
	@LimitSelect
41
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
41
	@OrderBy("ORDER BY TIME_DESC DESC")
42
	@Where(" STATE='1'")
42
	@Where(" STATE='1'")
43
	List<Question> watch(Connection con,
43
	List<Question> watch(Connection con,
44
			@SqlColumn(handlerClass = StringHandler.class, value = {
44
			@SqlColumn(handlerClass = StringHandler.class, value = {
45
					" ID IN (SELECT WATCH_OBJECT FROM WATCH WHERE WATCH_TYPE='8' AND PROFESSOR_ID=?)" }) String uid,
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
	@SelectOne
48
	@SelectOne
49
	@Nullable
49
	@Nullable
64
	List<Question> query(Connection con, @In String[] id) throws SQLException;
64
	List<Question> query(Connection con, @In String[] id) throws SQLException;
65
	
65
	
66
	@LimitSelect
66
	@LimitSelect
67
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
67
	@OrderBy("ORDER BY TIME_DESC DESC")
68
	@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'")
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
	@LimitSelect
71
	@LimitSelect
72
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
72
	@OrderBy("ORDER BY TIME_DESC DESC")
73
	@Where("QID IN(SELECT ID FROM QUESTION WHERE STATE='1') AND STATE='1'")
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
	@SelectOne
76
	@SelectOne
77
	@Nullable
77
	@Nullable
78
	Answer answer(Connection con,String uid,String qid)throws SQLException;
78
	Answer answer(Connection con,String uid,String qid)throws SQLException;
79

79

80
	@LimitSelect
80
	@LimitSelect
81
	@OrderBy("ORDER BY CREATE_TIME DESC,ID ASC")
81
	@OrderBy("ORDER BY TIME_DESC DESC")
82
	@Where("QID IN(SELECT ID FROM QUESTION WHERE STATE='1') AND STATE='1'")
82
	@Where("QID IN(SELECT ID FROM QUESTION WHERE STATE='1') AND STATE='1'")
83
	List<Answer> watchAnswer(Connection con,
83
	List<Answer> watchAnswer(Connection con,
84
			@SqlColumn(handlerClass = StringHandler.class, value = {
84
			@SqlColumn(handlerClass = StringHandler.class, value = {
85
					" ID IN (SELECT WATCH_OBJECT FROM WATCH WHERE WATCH_TYPE='9' AND PROFESSOR_ID=?)" }) String uid,
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
	@LimitSelect
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
	@LimitQuery
91
	@LimitQuery
92
	@OrderBy("ORDER BY SCORE DESC,ID ASC")
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
	@Insert
95
	@Insert
96
	int insert(Connection con,AnswerAgreeRec aar)throws SQLException;
96
	int insert(Connection con,AnswerAgreeRec aar)throws SQLException;

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

340
	@Path()
340
	@Path()
341
	public List<Question> query(@JdbcConn Connection con, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
341
	public List<Question> query(@JdbcConn Connection con, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
342
			@DefaultValue("10000000") int rows) throws SQLException {
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
	@Path("/my")
362
	@Path("/my")
363
	public List<Question> querySelf(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
363
	public List<Question> querySelf(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
364
			@DefaultValue("10000000") int rows) throws SQLException {
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
	@Path("/watch")
384
	@Path("/watch")
385
	public List<Question> watch(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
385
	public List<Question> watch(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
386
			@DefaultValue("10000000") int rows) throws SQLException {
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
	@Path("/answer/bySelf")
406
	@Path("/answer/bySelf")
407
	public List<Answer> answerSelf(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
407
	public List<Answer> answerSelf(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
408
			@DefaultValue("10000000") int rows) throws SQLException {
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
	@Path("/answer/byWatch")
428
	@Path("/answer/byWatch")
429
	public List<Answer> answerWatch(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
429
	public List<Answer> answerWatch(@JdbcConn Connection con, String uid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
430
			@DefaultValue("10000000") int rows) throws SQLException {
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
	@Path("/answer/byTime")
446
	@Path("/answer/byTime")
447
	public List<Answer> answerByTime(@JdbcConn Connection con,@DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
447
	public List<Answer> answerByTime(@JdbcConn Connection con,@DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
448
			@DefaultValue("10000000") int rows) throws SQLException {
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
	@Path("/answer/qes/byTime")
467
	@Path("/answer/qes/byTime")
468
	public List<Answer> byQes(@JdbcConn Connection con, String qid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
468
	public List<Answer> byQes(@JdbcConn Connection con, String qid, @DefaultValue("\"99999999999999\"") String time, @DefaultValue("\"0\"") String id,
469
			@DefaultValue("10000000") int rows) throws SQLException {
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
	@Path("/answer/qes/byScore")
489
	@Path("/answer/qes/byScore")
490
	public List<SortedAnswwer> byQes(@JdbcConn Connection con, String qid, @DefaultValue("100000") int score, @DefaultValue("\"0\"") String id,
490
	public List<SortedAnswwer> byQes(@JdbcConn Connection con, String qid, @DefaultValue("100000") int score, @DefaultValue("\"0\"") String id,
491
			@DefaultValue("10000000") int rows) throws SQLException {
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
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+1) / (ballot+1) 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
	}

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

2100

2100

2101
--modify begin at version2.20
2101
--modify begin at version2.20
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,
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
ALTER TABLE LEAVE_MSG ADD PRIMARY KEY (ID);
2105
ALTER TABLE LEAVE_MSG ADD PRIMARY KEY (ID);
2105
COMMENT ON TABLE LEAVE_MSG is '留言表(新)';
2106
COMMENT ON TABLE LEAVE_MSG is '留言表(新)';
2106
COMMENT ON COLUMN LEAVE_MSG.ID is '留言ID';
2107
COMMENT ON COLUMN LEAVE_MSG.ID is '留言ID';
2124
CREATE TABLE QUESTION (ID CHAR(32) NOT NULL,TITLE TEXT NOT NULL,
2125
CREATE TABLE QUESTION (ID CHAR(32) NOT NULL,TITLE TEXT NOT NULL,
2125
CNT TEXT,IMG TEXT,KEYS TEXT NOT NULL,
2126
CNT TEXT,IMG TEXT,KEYS TEXT NOT NULL,
2126
UID TEXT NOT NULL,LAST_REPLY_TIME CHAR(14),
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
ALTER TABLE QUESTION ADD PRIMARY KEY (ID);
2130
ALTER TABLE QUESTION ADD PRIMARY KEY (ID);
2129
COMMENT ON TABLE QUESTION is '提问表';
2131
COMMENT ON TABLE QUESTION is '提问表';
2130
COMMENT ON COLUMN QUESTION.ID is '提问ID';
2132
COMMENT ON COLUMN QUESTION.ID is '提问ID';
2140

2142

2141

2143

2142
CREATE TABLE ANSWER (ID CHAR(32) NOT NULL,QID TEXT NOT NULL,UID TEXT NOT NULL,STATE CHAR(1) NOT NULL,
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
ALTER TABLE ANSWER ADD PRIMARY KEY (ID);
2147
ALTER TABLE ANSWER ADD PRIMARY KEY (ID);
2145
ALTER TABLE ANSWER ADD UNIQUE (QID,UID);
2148
ALTER TABLE ANSWER ADD UNIQUE (QID,UID);
2146
COMMENT ON TABLE ANSWER is '回答表';
2149
COMMENT ON TABLE ANSWER is '回答表';
2173
COMMENT ON COLUMN NOTIFY_MSG_IDX.UN_READ is '未读通知数';
2176
COMMENT ON COLUMN NOTIFY_MSG_IDX.UN_READ is '未读通知数';
2174

2177

2175
CREATE TABLE NOTIFY_MSG_CNT (ID CHAR(32) NOT NULL,CNT TEXT NOT NULL,RECIVER TEXT NOT NULL,READED CHAR(1) NOT NULL,
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
ALTER TABLE NOTIFY_MSG_CNT ADD PRIMARY KEY (ID);
2180
ALTER TABLE NOTIFY_MSG_CNT ADD PRIMARY KEY (ID);
2178
COMMENT ON TABLE NOTIFY_MSG_CNT is '通知内容表';
2181
COMMENT ON TABLE NOTIFY_MSG_CNT is '通知内容表';
2179
COMMENT ON COLUMN NOTIFY_MSG_CNT.ID is '通知ID';
2182
COMMENT ON COLUMN NOTIFY_MSG_CNT.ID is '通知ID';