added security and fix edit profile

This commit is contained in:
SlimusMinus
2026-06-18 00:22:50 +03:00
parent 81e3e007e1
commit bafb636cbe
24 changed files with 418 additions and 56 deletions

View File

@@ -36,7 +36,6 @@ public class PostService {
private final ImageRepository imageRepository;
private final NominatimService nominatimService;
@CacheEvict(value = "posts", allEntries = true)
public PostRequest create(PostRequest request, MultipartFile image) {
Post post = mapper.toEntity(request);
@@ -74,15 +73,10 @@ public class PostService {
}
@Cacheable(value = "post", key = "#id")
public PostResponse getById(Long id) {
Post post = repository.findById(id)
.orElseThrow(() -> new ApiException(ErrorCode.NOT_FOUND, "Post not found", HttpStatus.NOT_FOUND));
return mapper.toResponse(post);
public List <PostResponse> getById(Long id) {
return repository.findByUserId(id).stream().map(mapper::toResponse).toList();
}
@CacheEvict(value = {"posts", "post"}, allEntries = true)
public PostResponse update(Long id, PostRequest request, MultipartFile image) {
Post post = repository.findById(id)