|
@@ -1,5 +1,6 @@
|
|
|
package com.uas.ps.message.service.impl;
|
|
package com.uas.ps.message.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.druid.stat.TableStat.Mode;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.account.entity.User;
|
|
import com.uas.account.entity.User;
|
|
|
import com.uas.account.entity.UserView;
|
|
import com.uas.account.entity.UserView;
|
|
@@ -44,6 +45,7 @@ import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
@@ -198,7 +200,9 @@ public class MessageServiceImpl implements MessageService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public List<Message> readMessage(String consumer) {
|
|
|
|
|
|
|
+ public ModelMap readMessage(String consumer) {
|
|
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
|
|
+ map.put("success", "false");
|
|
|
if (StringUtils.isEmpty(consumer)) {
|
|
if (StringUtils.isEmpty(consumer)) {
|
|
|
throw new ParameterMissingException("接收人信息为空,无法阅读消息");
|
|
throw new ParameterMissingException("接收人信息为空,无法阅读消息");
|
|
|
}
|
|
}
|
|
@@ -211,41 +215,51 @@ public class MessageServiceImpl implements MessageService {
|
|
|
Object receiverEnuu = jsonObject.get("receiverEnuu");
|
|
Object receiverEnuu = jsonObject.get("receiverEnuu");
|
|
|
Object consumerApp = jsonObject.get("consumerApp");
|
|
Object consumerApp = jsonObject.get("consumerApp");
|
|
|
if (StringUtils.isEmpty(messageId)) {
|
|
if (StringUtils.isEmpty(messageId)) {
|
|
|
- throw new ParameterMissingException("消息id为空,请重新确认消息信息");
|
|
|
|
|
|
|
+ map.put("data", "消息id为空,请重新确认消息信息");
|
|
|
|
|
+ return map;
|
|
|
} else {
|
|
} else {
|
|
|
String[] messageIds = String.valueOf(messageId).split(SplitChar.COMMA);
|
|
String[] messageIds = String.valueOf(messageId).split(SplitChar.COMMA);
|
|
|
List<Message> messages = new ArrayList<>();
|
|
List<Message> messages = new ArrayList<>();
|
|
|
|
|
|
|
|
for (String id : messageIds) {
|
|
for (String id : messageIds) {
|
|
|
- Message message = messageDao.findOne(Long.valueOf(String.valueOf(messageId)));
|
|
|
|
|
|
|
+ Message message = messageDao.findOne(Long.valueOf(String.valueOf(id)));
|
|
|
if (message == null) {
|
|
if (message == null) {
|
|
|
- throw new IllegalOperatorException("消息不存在,请重新确认消息信息");
|
|
|
|
|
|
|
+ map.put("data", "消息不存在,请重新确认消息信息");
|
|
|
|
|
+ return map;
|
|
|
}
|
|
}
|
|
|
if (receiverUu == null || StringUtils.isEmpty(String.valueOf(receiverEnuu)) || receiverEnuu == null
|
|
if (receiverUu == null || StringUtils.isEmpty(String.valueOf(receiverEnuu)) || receiverEnuu == null
|
|
|
|| StringUtils.isEmpty(String.valueOf(receiverUu))
|
|
|| StringUtils.isEmpty(String.valueOf(receiverUu))
|
|
|
|| StringUtils.isEmpty(String.valueOf(consumerApp))) {
|
|
|| StringUtils.isEmpty(String.valueOf(consumerApp))) {
|
|
|
- throw new ParameterMissingException("用户信息为空,无法读取消息");
|
|
|
|
|
|
|
+ map.put("data", "用户信息为空,无法读取消息");
|
|
|
|
|
+ return map;
|
|
|
}
|
|
}
|
|
|
if (!Long.valueOf(String.valueOf(receiverEnuu)).equals(message.getReceiverEnuu())
|
|
if (!Long.valueOf(String.valueOf(receiverEnuu)).equals(message.getReceiverEnuu())
|
|
|
|| !Long.valueOf(String.valueOf(receiverUu)).equals(message.getReceiverUu())) {
|
|
|| !Long.valueOf(String.valueOf(receiverUu)).equals(message.getReceiverUu())) {
|
|
|
- throw new IllegalOperatorException("此消息不属于当前用户,请重新确认后读取");
|
|
|
|
|
|
|
+ map.put("data", "此消息不属于当前用户,请重新确认后读取");
|
|
|
|
|
+ return map;
|
|
|
}
|
|
}
|
|
|
if (Constant.YES.equals(message.getIsRead())) {
|
|
if (Constant.YES.equals(message.getIsRead())) {
|
|
|
- throw new IllegalOperatorException("消息已阅读");
|
|
|
|
|
|
|
+ map.put("data", "消息已阅读");
|
|
|
|
|
+ return map;
|
|
|
}
|
|
}
|
|
|
App app = appDao.findByName(String.valueOf(consumerApp));
|
|
App app = appDao.findByName(String.valueOf(consumerApp));
|
|
|
if (app == null) {
|
|
if (app == null) {
|
|
|
- throw new IllegalOperatorException("消费应用不存在,请重新确认用户信息");
|
|
|
|
|
|
|
+ map.put("data", "消费应用不存在,请重新确认用户信息");
|
|
|
|
|
+ return map;
|
|
|
}
|
|
}
|
|
|
if (!message.getConsumerApp().contains(app)) {
|
|
if (!message.getConsumerApp().contains(app)) {
|
|
|
- throw new IllegalOperatorException("消息不属于当前应用");
|
|
|
|
|
|
|
+ map.put("data", "消息不属于当前应用");
|
|
|
|
|
+ return map;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
message.setIsRead(Constant.YES);
|
|
message.setIsRead(Constant.YES);
|
|
|
messages.add(message);
|
|
messages.add(message);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return messageDao.save(messages);
|
|
|
|
|
|
|
+ messages = messageDao.save(messages);
|
|
|
|
|
+ map.put("success", "success");
|
|
|
|
|
+ map.put("data", FastjsonUtils.toJson(messages));
|
|
|
|
|
+ return map;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|