added security and fix edit profile
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user