|
|
@@ -1,5 +1,7 @@
|
|
|
package com.uas.ps.message.service.impl;
|
|
|
|
|
|
+import static com.sun.org.apache.xml.internal.serializer.utils.Utils.messages;
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.account.entity.User;
|
|
|
import com.uas.account.entity.UserView;
|
|
|
@@ -171,6 +173,38 @@ public class MessageServiceImpl implements MessageService {
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getMessageCount(String receiverUu, String receiverEnuu, String consumerApp,
|
|
|
+ String isRead) {
|
|
|
+ if (StringUtils.isEmpty(receiverUu) || StringUtils.isEmpty(receiverEnuu)) {
|
|
|
+ throw new ParameterMissingException("接收人信息为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(consumerApp)) {
|
|
|
+ throw new ParameterMissingException("接收应用信息为空");
|
|
|
+ }
|
|
|
+ App consumerAppExists = appDao.findByName(consumerApp);
|
|
|
+ if (consumerApp == null) {
|
|
|
+ throw new IllegalOperatorException("接收应用不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Message> messages = new ArrayList<>();
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(isRead) || (!isRead.equals(Constant.NO.toString()) && !isRead.equals(Constant.YES.toString()))) {
|
|
|
+ messages = messageDao.findByReceiverUuAndReceiverEnuuAndConsumerAppId(Long.valueOf(receiverUu),
|
|
|
+ Long.valueOf(receiverEnuu), consumerAppExists.getId());
|
|
|
+
|
|
|
+ } else {
|
|
|
+ messages = messageDao.findByReceiverUuAndReceiverEnuuAndIsReadAndConsumerAppId(Long.valueOf(receiverUu),
|
|
|
+ Long.valueOf(receiverEnuu), Short.valueOf(isRead), consumerAppExists.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("success", "success");
|
|
|
+ resultMap.put("count", CollectionUtils.isEmpty(messages) ? 0 : messages.size());
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<Message> saveMessages(String messages) {
|
|
|
List<JSONObject> jsonObjects = FastjsonUtils.fromJsonArray(messages, JSONObject.class);
|