jiapeng 7 years ago
parent
commit
54f29973d4

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

@ -1,6 +1,8 @@
1 1
package com.ekexiu.portal.msg;
2 2

3 3
import java.sql.Connection;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
4 6
import java.sql.SQLException;
5 7
import java.text.SimpleDateFormat;
6 8
import java.util.ArrayList;
@ -18,7 +20,9 @@ import org.jfw.apt.web.annotation.operate.Post;
18 20
import org.jfw.apt.web.annotation.param.JdbcConn;
19 21
import org.jfw.util.DateUtil;
20 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 26
import org.jfw.util.json.JsonService;
23 27

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

76 81
	@Get
77 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 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 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 94
		return null;
90
		
95

91 96
	}
92
	
93
	
94 97

95 98
	@Get
96 99
	@Path("/idx/pq")
@ -105,6 +108,29 @@ public class Service {
105 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 134
	@Post
109 135
	@Path
110 136
	public void send(@JdbcConn Connection con, String sender, String reciver, String cnt) throws SQLException {
@ -117,9 +143,7 @@ public class Service {
117 143
			owner = reciver;
118 144
			actor = sender;
119 145
		}
120
		String id = StringUtil.buildUUID();
121 146
		WebMsgCnt wmc = new WebMsgCnt();
122
		wmc.setId(id);
123 147
		wmc.setCnt(cnt);
124 148
		wmc.setReaded(false);
125 149
		wmc.setReciver(reciver);

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

@ -3,29 +3,19 @@ package com.ekexiu.portal.msg;
3 3
import org.jfw.apt.orm.annotation.entry.Column;
4 4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5 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 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 9
@Table
13 10
public class WebMsgCnt {
14 11

15
	private String id;
16 12
	private String cnt;
17 13
	private String sendTime;
18 14
	private String sender;
19 15
	private String reciver;
20 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 21
	 * @return

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

@ -2067,8 +2067,12 @@ COMMENT ON COLUMN  DEMAND.MODIFY_TIME IS '最后修改时间,=完成时间 =
2067 2067
ALTER TABLE organization ADD COLUMN res_mgr char(1) NOT NULL DEFAULT '0';
2068 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