Image error solve update

This commit is contained in:
2025-10-10 19:15:18 +05:30
parent 5a88ba6993
commit 0ad84e030a

View File

@ -14,7 +14,6 @@ import net.shyshkin.study.fullstack.supportportal.backend.exception.domain.Profe
import net.shyshkin.study.fullstack.supportportal.backend.mapper.ProfessorMapper;
import net.shyshkin.study.fullstack.supportportal.backend.repository.ProfessorRepository;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@ -23,6 +22,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import org.springframework.boot.web.client.RestTemplateBuilder;
import javax.annotation.PostConstruct;
@ -55,9 +55,6 @@ public class ProfessorServiceImpl implements ProfessorService {
private final ProfileImageService profileImageService;
private final RestTemplateBuilder restTemplateBuilder;
@Value("${app.base-url}")
private String baseUrl;
private RestTemplate restTemplate;
@PostConstruct
@ -82,11 +79,16 @@ public class ProfessorServiceImpl implements ProfessorService {
}
private String generateDefaultProfileImageUrl(UUID professorId) {
return baseUrl + String.format(DEFAULT_USER_IMAGE_URI_PATTERN, professorId);
return ServletUriComponentsBuilder.fromCurrentContextPath()
.path(String.format(DEFAULT_USER_IMAGE_URI_PATTERN, professorId))
.toUriString();
}
private String generateProfileImageUrl(UUID professorId) {
return baseUrl + String.format(DEFAULT_USER_IMAGE_URI_PATTERN, professorId) + "/" + USER_IMAGE_FILENAME;
return ServletUriComponentsBuilder.fromCurrentContextPath()
.path(String.format(DEFAULT_USER_IMAGE_URI_PATTERN, professorId))
.pathSegment(USER_IMAGE_FILENAME)
.toUriString();
}
@Override