From 06bb85f58d438188e44c975a38a0b908978c1689 Mon Sep 17 00:00:00 2001 From: gsd Date: Sat, 4 Nov 2023 22:08:09 +0300 Subject: [PATCH] new db update 2 fix --- src/main/java/app/controllers/user/MessagesController.java | 4 ++-- src/main/java/app/services/db/MessageService.java | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/app/controllers/user/MessagesController.java b/src/main/java/app/controllers/user/MessagesController.java index 4953b9a..81e7165 100644 --- a/src/main/java/app/controllers/user/MessagesController.java +++ b/src/main/java/app/controllers/user/MessagesController.java @@ -31,7 +31,7 @@ public class MessagesController { @RequestParam(required = false, defaultValue = "0") Integer offset, @RequestParam(required = false, defaultValue = "20") Integer limit) { if (limit > 20) return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE); - return new ResponseEntity(messageService.getAllMessages(srv, filter, offset, limit), HttpStatus.OK); + return new ResponseEntity(messageService.getAllMessages(srv, filter==null||filter.isEmpty()?null:filter, offset, limit), HttpStatus.OK); } @PostMapping("/account") @@ -47,6 +47,6 @@ public class MessagesController { SteamID steamID = steam64 == null || steam64.isEmpty() ? SteamIDConverter.getSteamID(mysteam64) : SteamIDConverter.getSteamID(steam64); if (steamID == null) return new ResponseEntity(HttpStatus.NOT_FOUND); if (limit > 20) return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE); - return new ResponseEntity(messageService.getAccountMessages(steamID, srv, filter, offset, limit), HttpStatus.OK); + return new ResponseEntity(messageService.getAccountMessages(steamID, srv, filter==null||filter.isEmpty()?null:filter, offset, limit), HttpStatus.OK); } } diff --git a/src/main/java/app/services/db/MessageService.java b/src/main/java/app/services/db/MessageService.java index d9a3ff9..86ce558 100644 --- a/src/main/java/app/services/db/MessageService.java +++ b/src/main/java/app/services/db/MessageService.java @@ -3,6 +3,7 @@ package app.services.db; import app.entities.Stats; import app.entities.other.SteamID; import jakarta.persistence.EntityManager; +import lombok.Data; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -52,7 +53,7 @@ public class MessageService { .setParameter(2, server_id==null||server_id.isEmpty()?"%":server_id) .setParameter(3, filter==null||filter.isEmpty()?"%":"%" + filter + "%") .getSingleResult(); - return Map.of("result", result.stream().peek(message -> message.setAccount_name(nicknameService)).toList(), "count", count); + return Map.of("result", result, "count", count); } public Long getMessageCount(SteamID steamID, String server_id) { @@ -62,11 +63,12 @@ public class MessageService { .getSingleResult(); } + @Data class Message { int account_id; long utime; String message; - private String server_id; + String server_id; String account_name; Message(Object obj) { this.account_id = (int) ((Object[]) obj)[0];