|
|
@@ -1,8 +1,6 @@
|
|
|
package com.uas.ps.message.service.impl;
|
|
|
|
|
|
|
|
|
-import static antlr.build.ANTLR.root;
|
|
|
-
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.account.entity.User;
|
|
|
import com.uas.account.entity.UserView;
|
|
|
@@ -96,15 +94,19 @@ public class MessageServiceImpl implements MessageService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<Message> getMessages(String receiverUu, final String receiverEnuu, String consumerApp, String isRead,
|
|
|
+ public Page<Message> getMessages(String receiverUu, String receiverEnuu, String consumerApp, String isRead,
|
|
|
String keyword, PageParams pageParams) {
|
|
|
if (StringUtils.isEmpty(receiverUu) || StringUtils.isEmpty(receiverEnuu)) {
|
|
|
throw new ParameterMissingException("接收人信息为空");
|
|
|
}
|
|
|
- final App consumerAppExists = appDao.findByName(consumerApp);
|
|
|
+ if (StringUtils.isEmpty(consumerApp)) {
|
|
|
+ throw new ParameterMissingException("接收应用信息为空");
|
|
|
+ }
|
|
|
+ App consumerAppExists = appDao.findByName(consumerApp);
|
|
|
if (consumerApp == null) {
|
|
|
throw new IllegalOperatorException("接收应用不存在");
|
|
|
}
|
|
|
+ final Long consumerAppId = consumerAppExists.getId();
|
|
|
|
|
|
// 消息接收人过滤
|
|
|
SimpleExpression receiverUuExp = PredicateUtils.eq("receiverUu", Long.valueOf(receiverUu), true);
|
|
|
@@ -136,7 +138,7 @@ public class MessageServiceImpl implements MessageService {
|
|
|
criteriaBuilder));
|
|
|
// 消费应用过滤
|
|
|
Predicate consumerAppPredicate = criteriaBuilder.equal(root.join("consumerApp").get("id"),
|
|
|
- consumerAppExists.getId());
|
|
|
+ consumerAppId);
|
|
|
Predicate all = criteriaBuilder.and(messagePredicate, consumerAppPredicate);
|
|
|
criteriaQuery.where(all);
|
|
|
return null;
|
|
|
@@ -144,6 +146,28 @@ public class MessageServiceImpl implements MessageService {
|
|
|
}, pageInfo);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getUnReadMessageCount(String receiverUu, String receiverEnuu, String consumerApp) {
|
|
|
+ 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 = messageDao.findByReceiverUuAndReceiverEnuuAndConsumerAppId(Long.valueOf(receiverUu), Long.valueOf(receiverEnuu),
|
|
|
+ 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);
|