|
@@ -2,21 +2,29 @@ package cn.org.bjca.trust.java.imserver.request;
|
|
|
|
|
|
import cn.org.bjca.trust.java.imserver.HttpResult;
|
|
import cn.org.bjca.trust.java.imserver.HttpResult;
|
|
import cn.org.bjca.trust.java.imserver.bean.group.GroupCreateData;
|
|
import cn.org.bjca.trust.java.imserver.bean.group.GroupCreateData;
|
|
|
|
+import cn.org.bjca.trust.java.imserver.bean.group.MsgHistoryForCountData;
|
|
import cn.org.bjca.trust.java.imserver.common.SpringUtilsAuTo;
|
|
import cn.org.bjca.trust.java.imserver.common.SpringUtilsAuTo;
|
|
import cn.org.bjca.trust.java.imserver.common.TimeHelper;
|
|
import cn.org.bjca.trust.java.imserver.common.TimeHelper;
|
|
import cn.org.bjca.trust.java.imserver.common.json.GsonImplHelp;
|
|
import cn.org.bjca.trust.java.imserver.common.json.GsonImplHelp;
|
|
import cn.org.bjca.trust.java.imserver.entitys.GroupEntity;
|
|
import cn.org.bjca.trust.java.imserver.entitys.GroupEntity;
|
|
import cn.org.bjca.trust.java.imserver.im.msg.RequestMessage;
|
|
import cn.org.bjca.trust.java.imserver.im.msg.RequestMessage;
|
|
import cn.org.bjca.trust.java.imserver.im.msg.ResultMessage;
|
|
import cn.org.bjca.trust.java.imserver.im.msg.ResultMessage;
|
|
|
|
+import cn.org.bjca.trust.java.imserver.im.msg.msg.SZYXMessage;
|
|
import cn.org.bjca.trust.java.imserver.repository.GroupRepository;
|
|
import cn.org.bjca.trust.java.imserver.repository.GroupRepository;
|
|
import cn.org.bjca.trust.java.imserver.repository.MessageRepository;
|
|
import cn.org.bjca.trust.java.imserver.repository.MessageRepository;
|
|
import cn.org.bjca.trust.java.imserver.repository.UserRepository;
|
|
import cn.org.bjca.trust.java.imserver.repository.UserRepository;
|
|
import cn.org.bjca.trust.java.imserver.repository.tenant.ApplicationRepository;
|
|
import cn.org.bjca.trust.java.imserver.repository.tenant.ApplicationRepository;
|
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
|
+import org.springframework.data.domain.Sort;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
|
|
|
+import java.util.Comparator;
|
|
|
|
+import java.util.List;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
|
|
import static cn.org.bjca.trust.java.imserver.request.RequestConstant.Group_create_v1;
|
|
import static cn.org.bjca.trust.java.imserver.request.RequestConstant.Group_create_v1;
|
|
|
|
+import static cn.org.bjca.trust.java.imserver.request.RequestConstant.MsgHistoryForCount;
|
|
|
|
|
|
public class RequestManager {
|
|
public class RequestManager {
|
|
|
|
|
|
@@ -70,8 +78,12 @@ public class RequestManager {
|
|
return (HttpResult<T>) this.groupCreate(data instanceof String ?
|
|
return (HttpResult<T>) this.groupCreate(data instanceof String ?
|
|
GsonImplHelp.get().toObject((String) data, GroupCreateData.class)
|
|
GsonImplHelp.get().toObject((String) data, GroupCreateData.class)
|
|
: (GroupCreateData) data, appId, userId);
|
|
: (GroupCreateData) data, appId, userId);
|
|
|
|
+ case MsgHistoryForCount:
|
|
|
|
+ return (HttpResult<T>) this.getHistoryForCount(data instanceof String ?
|
|
|
|
+ GsonImplHelp.get().toObject((String) data, MsgHistoryForCountData.class)
|
|
|
|
+ : (MsgHistoryForCountData) data, appId, userId);
|
|
default:
|
|
default:
|
|
- return new HttpResult<>(201, "路径错误", null);
|
|
|
|
|
|
+ return new HttpResult<>(201, "路径错误" + path, null);
|
|
}
|
|
}
|
|
|
|
|
|
} else return new HttpResult<>(201, "参数错误", null);
|
|
} else return new HttpResult<>(201, "参数错误", null);
|
|
@@ -79,6 +91,17 @@ public class RequestManager {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ private HttpResult<List<SZYXMessage>> getHistoryForCount(MsgHistoryForCountData data, String appid, String userid) {
|
|
|
|
+
|
|
|
|
+ Pageable pageable = PageRequest.of(0, 10, Sort.by("_id").descending());
|
|
|
|
+
|
|
|
|
+ List<SZYXMessage> l = messageRepository.getHistoryForCount(appid, userid, data.getUserId(), data.getTimestamp(), pageable);
|
|
|
|
+ l.sort((o1, o2) -> (int) (o1.get_id() - o2.get_id()));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return new HttpResult<>(200, "查询成功", l);
|
|
|
|
+ }
|
|
|
|
+
|
|
private HttpResult<String> groupCreate(GroupCreateData data, String appid, String userid) {
|
|
private HttpResult<String> groupCreate(GroupCreateData data, String appid, String userid) {
|
|
if (null == data.getUserIdList() || data.getUserIdList().isEmpty() || data.getUserIdList().size() < 2) {
|
|
if (null == data.getUserIdList() || data.getUserIdList().isEmpty() || data.getUserIdList().size() < 2) {
|
|
return new HttpResult<>(201, "群组成员需要大于一", "");
|
|
return new HttpResult<>(201, "群组成员需要大于一", "");
|