added filter on title and description on post
This commit is contained in:
@@ -5,6 +5,7 @@ import com.krylov.refound.service.ChatService;
|
||||
import com.krylov.refound.service.UserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
@@ -42,4 +43,17 @@ public class ChatController {
|
||||
return userService.getUserIdByLogin(login);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{chatId}")
|
||||
public void deleteChat(@PathVariable Long chatId, Authentication auth) {
|
||||
Long currentUserId = extractUserId(auth);
|
||||
chatService.deleteChat(chatId);
|
||||
}
|
||||
|
||||
@PostMapping("/api/v1/chats/{chatId}/read")
|
||||
public void markAsRead(@PathVariable Long chatId) {
|
||||
Long userId = (Long) SecurityContextHolder.getContext()
|
||||
.getAuthentication().getPrincipal(); // или твой способ
|
||||
chatService.markAsRead(chatId, userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,10 @@ import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
@@ -44,8 +48,10 @@ public class PostController {
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<PostResponse> getFeed() {
|
||||
return service.getFeed();
|
||||
public Page<PostResponse> getFeed(
|
||||
@RequestParam(required = false) String search,
|
||||
@PageableDefault(size = 20, sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable) {
|
||||
return service.getFeed(search, pageable);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
|
||||
Reference in New Issue
Block a user