|
@ -20,6 +20,7 @@ import org.jfw.apt.web.annotation.operate.Post;
|
20
|
20
|
import org.jfw.apt.web.annotation.param.JdbcConn;
|
21
|
21
|
import org.jfw.util.DateUtil;
|
22
|
22
|
import org.jfw.util.PageQueryResult;
|
|
23
|
import org.jfw.util.exception.JfwBaseException;
|
23
|
24
|
import org.jfw.util.jdbc.JdbcUtil;
|
24
|
25
|
import org.jfw.util.jdbc.PreparedStatementConfig;
|
25
|
26
|
import org.jfw.util.jdbc.ResultSetExtractor;
|
|
@ -32,6 +33,8 @@ public class Service {
|
32
|
33
|
|
33
|
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
|
38
|
@Autowrie
|
36
|
39
|
private WebMsgDao webMsgDao;
|
37
|
40
|
|
|
@ -71,6 +74,11 @@ public class Service {
|
71
|
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
|
82
|
@Get
|
75
|
83
|
@Path("/idx/qm")
|
76
|
84
|
public List<ActorItem> query(@JdbcConn Connection con, String id) throws SQLException {
|
|
@ -80,19 +88,19 @@ public class Service {
|
80
|
88
|
|
81
|
89
|
@Get
|
82
|
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
|
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
|
96
|
} else {
|
88
|
|
wmi = webMsgDao.query(con, oid, id);
|
|
97
|
wmi = webMsgDao.query(con, actor, owner);
|
89
|
98
|
}
|
90
|
99
|
SimpleDateFormat sf = new SimpleDateFormat(DateUtil.TIMESTAMP_FORMAT);
|
91
|
100
|
if (wmi != null) {
|
92
|
|
return build(wmi, id, sf);
|
|
101
|
return build(wmi, owner, sf);
|
93
|
102
|
}
|
94
|
103
|
return null;
|
95
|
|
|
96
|
104
|
}
|
97
|
105
|
|
98
|
106
|
@Get
|
|
@ -133,12 +141,13 @@ public class Service {
|
133
|
141
|
|
134
|
142
|
@Post
|
135
|
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
|
146
|
boolean ownerSend = true;
|
138
|
147
|
String owner = sender;
|
139
|
148
|
String actor = reciver;
|
140
|
149
|
boolean next = true;
|
141
|
|
if (sender.compareTo(reciver) < 0) {
|
|
150
|
if (sender.compareTo(reciver) > 0) {
|
142
|
151
|
ownerSend = false;
|
143
|
152
|
owner = reciver;
|
144
|
153
|
actor = sender;
|
|
@ -201,7 +210,8 @@ public class Service {
|
201
|
210
|
|
202
|
211
|
@Post
|
203
|
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
|
215
|
int num = webMsgDao.readed(con, sender, reciver, time);
|
206
|
216
|
if (num > 0) {
|
207
|
217
|
String owner = sender;
|
|
@ -220,4 +230,14 @@ public class Service {
|
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
|
}
|