Merge pull request #5 from SlimusMinus/add-phone

added phone for post
This commit is contained in:
SlimusMinus
2026-05-29 01:19:52 +03:00
committed by GitHub
5 changed files with 19 additions and 7 deletions

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -0,0 +1,9 @@
databaseChangeLog:
- changeSet:
id: 003-add-phone-posts
author: you
changes:
- addColumn:
tableName: posts
columns:
- column: { name: phone, type: VARCHAR(255) }

View File

@@ -10,4 +10,5 @@ databaseChangeLog:
- include: { file: db/changelog/constraint/009-fk-favorite-user.yaml }
- 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/012-add-email-role.yaml }
- include: { file: db/changelog/add/003-add-phone-posts.yaml }