Skip to content

Commit

Permalink
Feat: Post 기능 구현
Browse files Browse the repository at this point in the history
* Feat: Post 기본 코드 구현
- 깃허브가 꼬여서 이전에 작성한거 다시 가지고 왔습니다..

* Fix: Post - Member Id 외래키 매핑

* Fix: Post - @NotNull 적용
  • Loading branch information
Shsin9797 authored Sep 23, 2024
1 parent eeac46a commit ba4c28b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/notai/post/application/PostQueryService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package notai.post.application;

public class PostQueryService {
}
4 changes: 4 additions & 0 deletions src/main/java/notai/post/application/PostService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package notai.post.application;

public class PostService {
}
46 changes: 46 additions & 0 deletions src/main/java/notai/post/domain/Post.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package notai.post.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import notai.member.domain.Member;

import static jakarta.persistence.GenerationType.IDENTITY;
import static lombok.AccessLevel.PROTECTED;

@Getter
@NoArgsConstructor(access = PROTECTED)
@AllArgsConstructor
@Entity
public class Post {
@Id
@GeneratedValue(strategy = IDENTITY)
private Long id;
@ManyToOne
@NotNull
@JoinColumn(name="member_id")
private Member member;
@NotNull
@Column(length = 255)
private String title;
@NotNull
@Column(length = 255)
private String contents;

public Post(
Member member,
String title,
String contents
) {
this.member = member;
this.title = title;
this.contents = contents;
}
}
9 changes: 9 additions & 0 deletions src/main/java/notai/post/domain/PostRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package notai.post.domain;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface PostRepository extends JpaRepository<Post, Long> {

}
4 changes: 4 additions & 0 deletions src/main/java/notai/post/presentation/PostController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package notai.post.presentation;

public class PostController {
}

0 comments on commit ba4c28b

Please sign in to comment.