Skip to content

Commit

Permalink
Merge pull request #38 from GDSC-Ewha-5th/LeeSeohyun
Browse files Browse the repository at this point in the history
[이서현] 4주차 과제 - complete
  • Loading branch information
seohyun-lee authored Nov 18, 2023
2 parents 1e85c68 + 48b6237 commit f5278a7
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions 4주차 Server S-Day 과제/domain_leeseohyun/Blogpost.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.serverstudy4.domain_leeseohyun;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

@Entity
@Getter @Setter
public class Blogpost {
@Id
@GeneratedValue
@Column(name="blogpost_id")
private Long id; //id
private String title; //제목
private String content; //내용
private LocalDateTime timestamp; //포스팅된 당시의 시각

//Many 쪽에 외래키를 둔다. User, Category둘 다 대해 Many쪽임
@ManyToOne
@JoinColumn(name="user_id")
private User user;

@ManyToOne
@JoinColumn(name = "category_id")
private Category category;
}
21 changes: 21 additions & 0 deletions 4주차 Server S-Day 과제/domain_leeseohyun/Category.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.serverstudy4.domain_leeseohyun;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

@Entity
@Getter @Setter
public class Category {
@Id
@GeneratedValue
@Column(name="category_id")
private Long id; //id
private String category_name; //카테고리명

@OneToMany(mappedBy="category") //one 쪽이다
private List<Blogpost> blogposts = new ArrayList<>();
}
20 changes: 20 additions & 0 deletions 4주차 Server S-Day 과제/domain_leeseohyun/Resume.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.serverstudy4.domain_leeseohyun;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter @Setter
public class Resume {
@Id
@GeneratedValue
@JoinColumn(name="resume_id")
private Long id;
private String title; //제목
private String content; //내용

@ManyToOne //Many 쪽임
@JoinColumn(name="user_id")
private User user;
}
27 changes: 27 additions & 0 deletions 4주차 Server S-Day 과제/domain_leeseohyun/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.example.serverstudy4.domain_leeseohyun;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

@Entity
@Getter
@Setter
public class User {

@Id
@GeneratedValue
@Column(name="user_id")
private Long id; //id
private String name; //이름
private int age; //나이
private String country; //국가
private String city; //도시
private String postal_code; //우편번호

@OneToMany(mappedBy="user") //one 쪽이다
private List<Blogpost> blogposts = new ArrayList<>();
}

0 comments on commit f5278a7

Please sign in to comment.