jiapeng 7 年之前
父节点
当前提交
8905111460
共有 2 个文件被更改,包括 43 次插入9 次删除
  1. 29 9
      src/main/java/com/ekexiu/portal/msg/Service.java
  2. 14 0
      src/main/java/com/ekexiu/portal/msg/WebMsgDao.java

+ 29 - 9
src/main/java/com/ekexiu/portal/msg/Service.java

20
import org.jfw.apt.web.annotation.param.JdbcConn;
20
import org.jfw.apt.web.annotation.param.JdbcConn;
21
import org.jfw.util.DateUtil;
21
import org.jfw.util.DateUtil;
22
import org.jfw.util.PageQueryResult;
22
import org.jfw.util.PageQueryResult;
23
import org.jfw.util.exception.JfwBaseException;
23
import org.jfw.util.jdbc.JdbcUtil;
24
import org.jfw.util.jdbc.JdbcUtil;
24
import org.jfw.util.jdbc.PreparedStatementConfig;
25
import org.jfw.util.jdbc.PreparedStatementConfig;
25
import org.jfw.util.jdbc.ResultSetExtractor;
26
import org.jfw.util.jdbc.ResultSetExtractor;
32

33

33
	public static final List<ActorItem> EMPTY_ACTORS = Collections.<ActorItem> emptyList();
34
	public static final List<ActorItem> EMPTY_ACTORS = Collections.<ActorItem> emptyList();
34

35

36
	public static final int ERROR_OWNER_OR_ACTOR = JfwBaseException.MIN_LOGIC_ERROR_CODE + 1;
37

35
	@Autowrie
38
	@Autowrie
36
	private WebMsgDao webMsgDao;
39
	private WebMsgDao webMsgDao;
37

40

71
		return ret;
74
		return ret;
72
	}
75
	}
73

76

77
	public static void checkActors(String id, String id2) throws JfwBaseException {
78
		if (id.compareTo(id2) == 0)
79
			throw new JfwBaseException(ERROR_OWNER_OR_ACTOR, "消息的参与人不合法");
80
	}
81

74
	@Get
82
	@Get
75
	@Path("/idx/qm")
83
	@Path("/idx/qm")
76
	public List<ActorItem> query(@JdbcConn Connection con, String id) throws SQLException {
84
	public List<ActorItem> query(@JdbcConn Connection con, String id) throws SQLException {
80

88

81
	@Get
89
	@Get
82
	@Path("/idx/qo")
90
	@Path("/idx/qo")
83
	public ActorItem query(@JdbcConn Connection con, String id, String oid) throws SQLException {
91
	public ActorItem query(@JdbcConn Connection con, String owner, String actor) throws SQLException, JfwBaseException {
92
		checkActors(owner, owner);
84
		WebMsgIdx wmi = null;
93
		WebMsgIdx wmi = null;
85
		if (id.compareTo(oid) < 0) {
86
			wmi = webMsgDao.query(con, id, oid);
94
		if (owner.compareTo(actor) < 0) {
95
			wmi = webMsgDao.query(con, owner, actor);
87
		} else {
96
		} else {
88
			wmi = webMsgDao.query(con, oid, id);
97
			wmi = webMsgDao.query(con, actor, owner);
89
		}
98
		}
90
		SimpleDateFormat sf = new SimpleDateFormat(DateUtil.TIMESTAMP_FORMAT);
99
		SimpleDateFormat sf = new SimpleDateFormat(DateUtil.TIMESTAMP_FORMAT);
91
		if (wmi != null) {
100
		if (wmi != null) {
92
			return build(wmi, id, sf);
101
			return build(wmi, owner, sf);
93
		}
102
		}
94
		return null;
103
		return null;
95

96
	}
104
	}
97

105

98
	@Get
106
	@Get
133

141

134
	@Post
142
	@Post
135
	@Path
143
	@Path
136
	public void send(@JdbcConn Connection con, String sender, String reciver, String cnt) throws SQLException {
144
	public void send(@JdbcConn Connection con, String sender, String reciver, String cnt) throws SQLException, JfwBaseException {
145
		checkActors(sender, reciver);
137
		boolean ownerSend = true;
146
		boolean ownerSend = true;
138
		String owner = sender;
147
		String owner = sender;
139
		String actor = reciver;
148
		String actor = reciver;
140
		boolean next = true;
149
		boolean next = true;
141
		if (sender.compareTo(reciver) < 0) {
150
		if (sender.compareTo(reciver) > 0) {
142
			ownerSend = false;
151
			ownerSend = false;
143
			owner = reciver;
152
			owner = reciver;
144
			actor = sender;
153
			actor = sender;
201

210

202
	@Post
211
	@Post
203
	@Path("/readed")
212
	@Path("/readed")
204
	public void readed(@JdbcConn(true) Connection con, String sender, String reciver, String time) throws SQLException {
213
	public void readed(@JdbcConn(true) Connection con, String sender, String reciver, String time) throws SQLException, JfwBaseException {
214
		checkActors(sender, reciver);
205
		int num = webMsgDao.readed(con, sender, reciver, time);
215
		int num = webMsgDao.readed(con, sender, reciver, time);
206
		if (num > 0) {
216
		if (num > 0) {
207
			String owner = sender;
217
			String owner = sender;
220
		}
230
		}
221
	}
231
	}
222

232

233
	@Post
234
	@Path("/disable/show")
235
	public void disableShow(@JdbcConn(true) Connection con, String owner, String actor) throws SQLException, JfwBaseException {
236
		checkActors(owner, actor);
237
		if (owner.compareTo(actor) < 0) {
238
			webMsgDao.disableOwnerShow(con, owner, actor);
239
		} else {
240
			webMsgDao.disableActorShow(con, actor, owner);
241
		}
242
	}
223
}
243
}

+ 14 - 0
src/main/java/com/ekexiu/portal/msg/WebMsgDao.java

10
import org.jfw.apt.orm.annotation.dao.method.From;
10
import org.jfw.apt.orm.annotation.dao.method.From;
11
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
11
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
12
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
12
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
13
import org.jfw.apt.orm.annotation.dao.method.Where;
13
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
14
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
14
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
15
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
15
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
16
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
89
	@From(WebMsgCnt.class)
90
	@From(WebMsgCnt.class)
90
	@SetSentence("READED='1'")
91
	@SetSentence("READED='1'")
91
	int readed(Connection con,String sender,String reciver,@LtEq String sendTime)throws SQLException;
92
	int readed(Connection con,String sender,String reciver,@LtEq String sendTime)throws SQLException;
93
	
94
	@UpdateWith
95
	@From(WebMsgIdx.class)
96
	@SetSentence("SHOW_OF_OWNER='0'")
97
	@Where("SHOW_OF_OWNER='1'")
98
	int disableOwnerShow(Connection con,String owner,String actor) throws SQLException;
99
	
100
	@UpdateWith
101
	@From(WebMsgIdx.class)
102
	@SetSentence("SHOW_OF_ACTOR='0'")
103
	@Where("SHOW_OF_ACTOR='1'")
104
	int disableActorShow(Connection con,String owner,String actor) throws SQLException;
105
	
92
}
106
}