This commit is contained in:
jack ning
2025-03-15 14:22:33 +08:00
parent 0ae8b23fab
commit 18e77bb213
7 changed files with 36 additions and 41 deletions

View File

@@ -36,5 +36,6 @@ public class TypeConsts {
public static final String COMPONENT_TYPE_TEAM = "team";
public static final String COMPONENT_TYPE_SERVICE = "service";
public static final String COMPONENT_TYPE_ROBOT = "robot";
public static final String COMPONENT_TYPE_VISITOR = "visitor";
}

View File

@@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-01-29 16:21:24
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-03-05 16:36:20
* @LastEditTime: 2025-03-15 14:20:07
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
* Please be aware of the BSL license restrictions before installing Bytedesk IM
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
@@ -72,7 +72,7 @@ public class MessageRestController extends BaseRestController<MessageRequest> {
@GetMapping("/query/topic")
public ResponseEntity<?> queryByTopic(MessageRequest request) {
Page<MessageResponse> response = messageService.queryByTopic(request);
Page<MessageResponse> response = messageService.queryByOrg(request);
//
return ResponseEntity.ok(JsonResult.success(response));
}

View File

@@ -19,9 +19,7 @@ import org.springframework.cache.annotation.Caching;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.lang.NonNull;
import org.springframework.orm.ObjectOptimisticLockingFailureException;
@@ -61,18 +59,13 @@ public class MessageRestService extends BaseRestService<MessageEntity, MessageRe
return queryByOrg(request);
}
@Cacheable(value = "message", key = "#request.topic", unless = "#result == null")
public Page<MessageResponse> queryByTopic(MessageRequest request) {
Pageable pageable = PageRequest.of(request.getPageNumber(), request.getPageSize(), Sort.Direction.DESC,
"createdAt");
Specification<MessageEntity> specs = MessageSpecification.search(request);
Page<MessageEntity> messagePage = messageRepository.findAll(specs, pageable);
return messagePage.map(ConvertUtils::convertToMessageResponse);
}
// @Cacheable(value = "message", key = "#request.topic", unless = "#result == null")
// public Page<MessageResponse> queryByTopic(MessageRequest request) {
// Pageable pageable = request.getPageable();
// Specification<MessageEntity> specs = MessageSpecification.search(request);
// Page<MessageEntity> messagePage = messageRepository.findAll(specs, pageable);
// return messagePage.map(ConvertUtils::convertToMessageResponse);
// }
@Cacheable(value = "message", key = "#uid", unless = "#result == null")
public Optional<MessageEntity> findByUid(String uid) {

View File

@@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-06-05 22:53:57
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-03-13 11:01:27
* @LastEditTime: 2025-03-15 14:14:41
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
* Please be aware of the BSL license restrictions before installing Bytedesk IM
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
@@ -49,6 +49,15 @@ public class MessageSpecification extends BaseSpecification {
} else if (TypeConsts.COMPONENT_TYPE_ROBOT.equals(request.getComponentType())) {
// topic like '%robot%'
predicates.add(criteriaBuilder.like(root.get("topic"), "%robot%"));
} else if (TypeConsts.COMPONENT_TYPE_VISITOR.equals(request.getComponentType())) {
// 访客端查询消息过滤掉一些消息类型比如TRANSFER, TRANSFER_ACCEPT, TRANSFER_REJECT
predicates.add(criteriaBuilder.notEqual(root.get("type"), MessageTypeEnum.TRANSFER.name()));
predicates.add(criteriaBuilder.notEqual(root.get("type"), MessageTypeEnum.TRANSFER_ACCEPT.name()));
predicates.add(criteriaBuilder.notEqual(root.get("type"), MessageTypeEnum.TRANSFER_REJECT.name()));
// 过滤掉 INVITE, INVITE_ACCEPT, INVITE_REJECT
predicates.add(criteriaBuilder.notEqual(root.get("type"), MessageTypeEnum.INVITE.name()));
predicates.add(criteriaBuilder.notEqual(root.get("type"), MessageTypeEnum.INVITE_ACCEPT.name()));
predicates.add(criteriaBuilder.notEqual(root.get("type"), MessageTypeEnum.INVITE_REJECT.name()));
}
}
predicates.add(criteriaBuilder.equal(root.get("deleted"), false));