added phone for post
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.krylov.refound.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.krylov.refound.enums.PostType;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.krylov.refound.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.krylov.refound.enums.PostStatus;
|
||||
import com.krylov.refound.enums.PostType;
|
||||
import jakarta.persistence.Column;
|
||||
@@ -47,5 +48,8 @@ public class Post {
|
||||
private PostStatus status;
|
||||
|
||||
@ManyToOne
|
||||
@JsonIgnore
|
||||
private User user;
|
||||
|
||||
private String phone;
|
||||
}
|
||||
|
||||
@@ -41,19 +41,18 @@ public class PostService {
|
||||
@CacheEvict(value = "posts", allEntries = true)
|
||||
public PostRequest create(PostRequest request) {
|
||||
|
||||
// User user = userService.getCurrentUser();
|
||||
//
|
||||
Post post = mapper.toEntity(request);
|
||||
post.setCreatedAt(LocalDateTime.now());
|
||||
post.setStatus(PostStatus.ACTIVE);
|
||||
|
||||
Post savedPost = repository.save(post);
|
||||
repository.save(post);
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
public List<Post> getFeed() {
|
||||
return repository.findAll();
|
||||
List<Post> postList = repository.findAll();
|
||||
return postList;
|
||||
}
|
||||
|
||||
@Cacheable(value = "post", key = "#id")
|
||||
@@ -77,7 +76,7 @@ public class PostService {
|
||||
post.setTitle(request.getTitle());
|
||||
post.setDescription(request.getDescription());
|
||||
post.setCategory(request.getCategory());
|
||||
|
||||
post.setPhone(request.getPhone());
|
||||
post.setType(request.getType());
|
||||
|
||||
Post updated = repository.save(post);
|
||||
|
||||
Reference in New Issue
Block a user