瀏覽代碼

--add LeaveWord.class

zzy.zhiyuan.foxmail 8 年之前
父節點
當前提交
848062bbc0

+ 23 - 0
src/main/java/com/ekexiu/portal/dao/LeaveWordDao.java

@ -0,0 +1,23 @@
1
package com.ekexiu.portal.dao;
2

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

7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
9
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
10
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
11
import org.jfw.apt.orm.annotation.dao.param.LessThan;
12

13
import com.ekexiu.portal.po.LeaveWord;
14

15
@DAO
16
public abstract class LeaveWordDao {
17
	@Insert
18
	public abstract int insert(Connection con,LeaveWord word) throws SQLException;
19

20
	@LimitSelect
21
	@OrderBy("ORDER BY CREATE_TIME DESC,ORDER_KEY DESC")
22
	public abstract List<LeaveWord> query(Connection con,String articleId,@LessThan String createTime,@LessThan long orderKey,int rows) throws SQLException; 
23
}

+ 62 - 0
src/main/java/com/ekexiu/portal/po/LeaveWord.java

@ -0,0 +1,62 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

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

10
@PrimaryKey("id")
11
@Table
12
public class LeaveWord implements CreateTimeSupported {
13
	private String id;
14
	private String Content;
15
	private String sender;
16
	private String articleId;
17
	private String createTime;
18
	private long orderKey;
19
	
20
	@Column(DE.id_32)
21
	public String getId() {
22
		return id;
23
	}
24
	public void setId(String id) {
25
		this.id = id;
26
	}
27
	@Column(DE.text_de)
28
	public String getContent() {
29
		return Content;
30
	}
31
	public void setContent(String content) {
32
		Content = content;
33
	}
34
	@Column(DE.id_32)
35
	public String getSender() {
36
		return sender;
37
	}
38
	public void setSender(String sender) {
39
		this.sender = sender;
40
	}
41
	@Column(DE.id_32)
42
	public String getArticleId() {
43
		return articleId;
44
	}
45
	public void setArticleId(String articleId) {
46
		this.articleId = articleId;
47
	}
48
	public String getCreateTime() {
49
		return createTime;
50
	}
51
	public void setCreateTime(String createTime) {
52
		this.createTime = createTime;
53
	}
54
	@Column(DE.long_de)
55
	public long getOrderKey() {
56
		return orderKey;
57
	}
58
	public void setOrderKey(long orderKey) {
59
		this.orderKey = orderKey;
60
	}
61
	
62
}

+ 48 - 0
src/main/java/com/ekexiu/portal/service/LeaveWordService.java

@ -0,0 +1,48 @@
1
package com.ekexiu.portal.service;
2

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

7
import org.jfw.apt.annotation.Autowrie;
8
import org.jfw.apt.annotation.DefaultValue;
9
import org.jfw.apt.web.annotation.Path;
10
import org.jfw.apt.web.annotation.operate.Get;
11
import org.jfw.apt.web.annotation.operate.Post;
12
import org.jfw.apt.web.annotation.param.JdbcConn;
13
import org.jfw.util.StringUtil;
14

15
import com.ekexiu.portal.dao.LeaveWordDao;
16
import com.ekexiu.portal.po.LeaveWord;
17

18
@Path("/leaveWord")
19
public class LeaveWordService {
20
	public static final String MAX_CREATETIME="9";
21

22
	@Autowrie
23
	private LeaveWordDao leaveWordDao;
24

25
	public LeaveWordDao getLeaveWordDao() {
26
		return leaveWordDao;
27
	}
28

29
	public void setLeaveWordDao(LeaveWordDao leaveWordDao) {
30
		this.leaveWordDao = leaveWordDao;
31
	}
32
	
33
	@Post
34
	@Path
35
	public String insert(@JdbcConn(true) Connection con,LeaveWord word) throws SQLException{
36
		String id = StringUtil.buildUUID();
37
		word.setId(id);
38
		word.setOrderKey(System.currentTimeMillis());
39
		this.leaveWordDao.insert(con, word);
40
		return id;
41
	}
42
	
43
	@Get
44
	@Path("/ql")
45
	public List<LeaveWord> query(@JdbcConn Connection con,String articleId,@DefaultValue("com.ekexiu.portal.service.LeaveWordService.MAX_CREATETIME")  String createTime,@DefaultValue("0") long orderKey,@DefaultValue("10") int rows) throws SQLException{
46
		return this.leaveWordDao.query(con, articleId, createTime, orderKey, rows);
47
	}
48
}