jiapeng 7 anos atrás
pai
commit
54f29973d4

+ 37 - 13
src/main/java/com/ekexiu/portal/msg/Service.java

1
package com.ekexiu.portal.msg;
1
package com.ekexiu.portal.msg;
2

2

3
import java.sql.Connection;
3
import java.sql.Connection;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
4
import java.sql.SQLException;
6
import java.sql.SQLException;
5
import java.text.SimpleDateFormat;
7
import java.text.SimpleDateFormat;
6
import java.util.ArrayList;
8
import java.util.ArrayList;
18
import org.jfw.apt.web.annotation.param.JdbcConn;
20
import org.jfw.apt.web.annotation.param.JdbcConn;
19
import org.jfw.util.DateUtil;
21
import org.jfw.util.DateUtil;
20
import org.jfw.util.PageQueryResult;
22
import org.jfw.util.PageQueryResult;
21
import org.jfw.util.StringUtil;
23
import org.jfw.util.jdbc.JdbcUtil;
24
import org.jfw.util.jdbc.PreparedStatementConfig;
25
import org.jfw.util.jdbc.ResultSetExtractor;
22
import org.jfw.util.json.JsonService;
26
import org.jfw.util.json.JsonService;
23

27

24
import com.ekexiu.portal.util.WebMsgSocketServlet;
28
import com.ekexiu.portal.util.WebMsgSocketServlet;
73
		List<WebMsgIdx> list = webMsgDao.query(con, id);
77
		List<WebMsgIdx> list = webMsgDao.query(con, id);
74
		return build(list, id);
78
		return build(list, id);
75
	}
79
	}
80

76
	@Get
81
	@Get
77
	@Path("/idx/qo")
82
	@Path("/idx/qo")
78
	public ActorItem query(@JdbcConn Connection con,String id,String oid)throws SQLException{
83
	public ActorItem query(@JdbcConn Connection con, String id, String oid) throws SQLException {
79
		WebMsgIdx wmi = null;
84
		WebMsgIdx wmi = null;
80
		if(id.compareTo(oid)<0){
81
			wmi = webMsgDao.query(con,id, oid);
82
		}else{
83
			wmi = webMsgDao.query(con,oid, id);
85
		if (id.compareTo(oid) < 0) {
86
			wmi = webMsgDao.query(con, id, oid);
87
		} else {
88
			wmi = webMsgDao.query(con, oid, id);
84
		}
89
		}
85
		SimpleDateFormat sf = new SimpleDateFormat(DateUtil.TIMESTAMP_FORMAT);
90
		SimpleDateFormat sf = new SimpleDateFormat(DateUtil.TIMESTAMP_FORMAT);
86
		if(wmi!=null){
87
			return build(wmi,id, sf);
91
		if (wmi != null) {
92
			return build(wmi, id, sf);
88
		}
93
		}
89
		return null;
94
		return null;
90
		
95

91
	}
96
	}
92
	
93
	
94

97

95
	@Get
98
	@Get
96
	@Path("/idx/pq")
99
	@Path("/idx/pq")
105
		return ret;
108
		return ret;
106
	}
109
	}
107

110

111
	@Get
112
	@Path("/unReadedCount")
113
	public Integer queryUnReadedCount(@JdbcConn Connection con, final String id) throws SQLException {
114
		return JdbcUtil.query(con,
115
				"SELECT NUM_OF_OWNER FROM WEB_MSG_IDX WHERE OWNER ='' AND SHOW_OF_OWNER='1' UNION ALL SELECT NUM_OF_ACTOR FROM WEB_MSG_IDX WHERE ACTOR ='' AND SHOW_OF_ACTOR='1' ",
116
				new ResultSetExtractor<Integer>() {
117
					@Override
118
					public Integer extractData(ResultSet rs) throws SQLException {
119
						int ret = 0;
120
						while (rs.next()) {
121
							ret += rs.getInt(1);
122
						}
123
						return ret;
124
					}
125
				}, new PreparedStatementConfig() {
126
					@Override
127
					public void config(PreparedStatement ps) throws SQLException {
128
						ps.setString(1, id);
129
						ps.setString(2, id);
130
					}
131
				});
132
	}
133

108
	@Post
134
	@Post
109
	@Path
135
	@Path
110
	public void send(@JdbcConn Connection con, String sender, String reciver, String cnt) throws SQLException {
136
	public void send(@JdbcConn Connection con, String sender, String reciver, String cnt) throws SQLException {
117
			owner = reciver;
143
			owner = reciver;
118
			actor = sender;
144
			actor = sender;
119
		}
145
		}
120
		String id = StringUtil.buildUUID();
121
		WebMsgCnt wmc = new WebMsgCnt();
146
		WebMsgCnt wmc = new WebMsgCnt();
122
		wmc.setId(id);
123
		wmc.setCnt(cnt);
147
		wmc.setCnt(cnt);
124
		wmc.setReaded(false);
148
		wmc.setReaded(false);
125
		wmc.setReciver(reciver);
149
		wmc.setReciver(reciver);

+ 2 - 12
src/main/java/com/ekexiu/portal/msg/WebMsgCnt.java

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

7

10
@Uniques(@Unique(clolumns = { "sender","reciver","sendTime" }, name = "WEB_MSG_CNT_S_R_TIME"))
11
@PrimaryKey("id")
8
@PrimaryKey( { "sender","reciver","sendTime" })
12
@Table
9
@Table
13
public class WebMsgCnt {
10
public class WebMsgCnt {
14

11

15
	private String id;
16
	private String cnt;
12
	private String cnt;
17
	private String sendTime;
13
	private String sendTime;
18
	private String sender;
14
	private String sender;
19
	private String reciver;
15
	private String reciver;
20
	private boolean readed;
16
	private boolean readed;
21
	
17
	
22
	@Column(DE.id_32)
23
	public String getId() {
24
		return id;
25
	}
26
	public void setId(String id) {
27
		this.id = id;
28
	}
18
	
29
	/**
19
	/**
30
	 * 消息内容
20
	 * 消息内容
31
	 * @return
21
	 * @return

+ 5 - 1
src/main/resources/database.sql

2067
ALTER TABLE organization ADD COLUMN res_mgr char(1) NOT NULL DEFAULT '0';
2067
ALTER TABLE organization ADD COLUMN res_mgr char(1) NOT NULL DEFAULT '0';
2068
COMMENT ON COLUMN organization.res_mgr IS '是否是资源管理者 0:不是  1:是';
2068
COMMENT ON COLUMN organization.res_mgr IS '是否是资源管理者 0:不是  1:是';
2069

2069

2070
--- modify begin at version 2.1
2070

2071

2071

2072
CREATE TABLE WEB_MSG_IDX (OWNER CHAR(32) NOT NULL,ACTOR CHAR(32) NOT NULL,LAST_TIME BIGINT NOT NULL,NUM_OF_OWNER INTEGER NOT NULL,NUM_OF_ACTOR INTEGER NOT NULL,LAST_CNT TEXT NOT NULL,SHOW_OF_OWNER CHAR(1) NOT NULL,SHOW_OF_ACTOR CHAR(1) NOT NULL);
2073
ALTER TABLE WEB_MSG_IDX ADD PRIMARY KEY (OWNER,ACTOR);
2074
CREATE TABLE WEB_MSG_CNT (CNT TEXT NOT NULL,SEND_TIME TEXT NOT NULL,SENDER CHAR(32) NOT NULL,RECIVER CHAR(32) NOT NULL,READED CHAR(1) NOT NULL);
2075
ALTER TABLE WEB_MSG_CNT ADD PRIMARY KEY (SENDER,RECIVER,SEND_TIME);
2072

2076

2073

2077

2074

2078