Browse Source

new db update 2 fix

master
gsd 1 year ago
parent
commit
06bb85f58d
  1. 4
      src/main/java/app/controllers/user/MessagesController.java
  2. 6
      src/main/java/app/services/db/MessageService.java

4
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);
}
}

6
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];

Loading…
Cancel
Save