Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor] Content -> Post 엔티티 변경 #19

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/contents")
public class ContentController {
@RequestMapping("/posts")
public class PostController {
}
57 changes: 0 additions & 57 deletions src/main/java/wanted/media/content/domain/Content.java

This file was deleted.

67 changes: 67 additions & 0 deletions src/main/java/wanted/media/content/domain/Post.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package wanted.media.content.domain;

import java.time.LocalDateTime;

import org.hibernate.annotations.ColumnDefault;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Size;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import wanted.media.user.domain.User;

@Entity
@Getter
@Table(name = "post")
rhaehf marked this conversation as resolved.
Show resolved Hide resolved
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EntityListeners(AuditingEntityListener.class)
public class Post {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
rhaehf marked this conversation as resolved.
Show resolved Hide resolved
@Column(name = "post_id", nullable = false)
private String id;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private Type type;

@Size(max = 150)
@Column(nullable = false)
private String title;
private String content;
private String hashtags;

@ColumnDefault("0")
private Long likeCount;

@ColumnDefault("0")
private Long viewCount;

@ColumnDefault("0")
private Long shareCount;

@CreatedDate
private LocalDateTime createdAt;

@LastModifiedDate
private LocalDateTime updatedAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
private User user;
}