Browse Source

пельмень апдейт 3.5.5

master
gsd 2 days ago
parent
commit
806c110b2c
  1. 10
      src/main/java/app/controllers/user/MessagesController.java
  2. 22
      src/main/java/app/entities/SearchFilter.java
  3. 14
      src/main/java/app/entities/messages/MessageSearchFilter.java

10
src/main/java/app/controllers/user/MessagesController.java

@ -5,7 +5,7 @@ import app.annotations.interfaces.CheckWebAccess;
import app.annotations.interfaces.CollectStatistic;
import app.annotations.interfaces.WaitAfterNext;
import app.entities.messages.Message;
import app.entities.messages.MessageSearch;
import app.entities.messages.MessageSearchFilter;
import app.entities.other.SteamID;
import app.repositories.GametimeRepository;
import app.repositories.MessageRepository;
@ -15,16 +15,12 @@ import app.utils.SteamIDConverter;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* котроллер для пользователя, чтоб смотреть сообщения
*/
@ -67,8 +63,8 @@ public class MessagesController {
@WaitAfterNext(order = "messages")
@CollectStatistic
public Page<Message> getMessagesWithFilters(Pageable pageable,
@RequestBody(required = false) MessageSearch filter) {
if (filter == null) filter = new MessageSearch();
@RequestBody(required = false) MessageSearchFilter filter) {
if (filter == null) filter = new MessageSearchFilter();
Page<Message> messages = messageRepository.getMessages(
pageable,
filter.getAccounts(profileService),

22
src/main/java/app/entities/messages/MessageSearch.java → src/main/java/app/entities/SearchFilter.java

@ -1,23 +1,17 @@
package app.entities.messages;
package app.entities;
import app.services.ProfileService;
import lombok.Getter;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class MessageSearch {
private List<String> accounts;
private LocalDateTime begin;
private LocalDateTime end;
private String message;
private String serverId;
public MessageSearch() {
}
public abstract class SearchFilter {
private List<String> accounts = null;
private LocalDateTime begin = null;
private LocalDateTime end = null;
private String serverId = null;
public List<Long> getAccounts(ProfileService profileService) {
if (accounts == null || accounts.isEmpty()) return null;
@ -39,10 +33,6 @@ public class MessageSearch {
return end == null ? null : end.atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
}
public String getMessage() {
return message == null || message.isEmpty() ? null : "%"+message+"%";
}
public String getServerId() {
return serverId == null || serverId.isEmpty() ? null : serverId;
}

14
src/main/java/app/entities/messages/MessageSearchFilter.java

@ -0,0 +1,14 @@
package app.entities.messages;
import app.entities.SearchFilter;
public class MessageSearchFilter extends SearchFilter {
private String message;
public MessageSearchFilter() {
}
public String getMessage() {
return message == null || message.isEmpty() ? null : "%"+message+"%";
}
}
Loading…
Cancel
Save