added advertising

This commit is contained in:
SlimusMinus
2026-09-23 23:34:05 +03:00
parent 05d93d6b0a
commit 942cd09585
83 changed files with 2546 additions and 46 deletions

View File

@@ -1,8 +1,10 @@
package com.krylov.refound.controller;
import com.krylov.refound.dto.*;
import com.krylov.refound.dto.ChatDto;
import com.krylov.refound.dto.MessageDto;
import com.krylov.refound.service.ChatService;
import com.krylov.refound.service.UserService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
@@ -10,9 +12,13 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@@ -61,10 +67,13 @@ public class ChatController {
chatService.markAsRead(chatId, currentUserId);
}
private Long extractUserId(Authentication auth) {
// Подставь свою логику получения userId из JWT/Authentication
String login = auth.getName();
log.debug("extractUserId by login {}", login);
private Long extractUserId(Authentication authentication) {
if (authentication == null || !authentication.isAuthenticated() || "anonymousUser".equals(authentication.getPrincipal())) {
return null;
}
String login = authentication.getName();
log.info("extractUserId by login {}", login);
return userService.getUserIdByLogin(login);
}