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);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: 003-add-phone-posts
|
||||
author: you
|
||||
changes:
|
||||
- addColumn:
|
||||
tableName: posts
|
||||
columns:
|
||||
- column: { name: phone, type: VARCHAR(255) }
|
||||
@@ -11,3 +11,4 @@ databaseChangeLog:
|
||||
- include: { file: db/changelog/alter/010-alter-user.yaml }
|
||||
- include: { file: db/changelog/add/011-add-name-user.yaml }
|
||||
- include: { file: db/changelog/add/012-add-email-role.yaml }
|
||||
- include: { file: db/changelog/add/003-add-phone-posts.yaml }
|
||||
Reference in New Issue
Block a user