Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 13 additions & 0 deletions src/main/java/com/example/umc9th/Umc9thApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.umc9th;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@SpringBootApplication
@EnableJpaAuditing // 👈 이 어노테이션을 꼭 추가해주세요!
public class Umc9thApplication {
public static void main(String[] args) {
SpringApplication.run(Umc9thApplication.class, args);
}
}
20 changes: 20 additions & 0 deletions src/main/java/com/example/umc9th/domain/common/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.umc9th.domain.common;

import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.time.LocalDateTime;

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
@Getter
public abstract class BaseEntity {
@CreatedDate
private LocalDateTime createdAt;

@LastModifiedDate
private LocalDateTime updatedAt;
}
21 changes: 21 additions & 0 deletions src/main/java/com/example/umc9th/domain/food/entity/Food.java

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1:N 연관관계 매핑이 안되어 있어요

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.umc9th.domain.food.entity;

import com.example.umc9th.domain.common.BaseEntity;
import com.example.umc9th.domain.food.enums.FoodName;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Food extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Enumerated(EnumType.STRING)
@Column(columnDefinition = "VARCHAR(20)")
private FoodName name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.umc9th.domain.food.enums;

public enum FoodName {
KOREAN_FOOD, CHINESE_FOOD, JAPANESE_FOOD, WESTERN_FOOD, BUNSIK, CAFE_DESSERT
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1:N 연관관계 매핑이 안되어 있어요

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.umc9th.domain.location.entity;

import com.example.umc9th.domain.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Location extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false, length = 50)
private String name;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1:N 연관관계 매핑이 안되어 있어요

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.umc9th.domain.mission.entity;

import com.example.umc9th.domain.common.BaseEntity;
import com.example.umc9th.domain.store.entity.Store;
import jakarta.persistence.*;
import lombok.*;

import java.time.LocalDate;

@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Mission extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private LocalDate deadline;

@Column(length = 200)
private String conditional;

private Integer point;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "store_id")
private Store store;
}
32 changes: 32 additions & 0 deletions src/main/java/com/example/umc9th/domain/review/entity/Review.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.example.umc9th.domain.review.entity;

import com.example.umc9th.domain.common.BaseEntity;
import com.example.umc9th.domain.store.entity.Store;
import com.example.umc9th.domain.user.entity.User;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Review extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(columnDefinition = "TEXT")
private String content;

private Float star;

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

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "store_id")
private Store store;
}
31 changes: 31 additions & 0 deletions src/main/java/com/example/umc9th/domain/store/entity/Store.java

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1:N 연관관계 매핑이 안되어 있어요

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.umc9th.domain.store.entity;

import com.example.umc9th.domain.common.BaseEntity;
import com.example.umc9th.domain.location.entity.Location;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Store extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false, length = 50)
private String name;

@Column(name = "zip_code", length = 10)
private String zipCode;

@Column(name = "detail_address", length = 100)
private String detailAddress;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "location_id")
private Location location;
}
20 changes: 20 additions & 0 deletions src/main/java/com/example/umc9th/domain/term/entity/Term.java

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1:N 연관관계 매핑이 안되어 있어요
@onetomany

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.umc9th.domain.term.entity;

import com.example.umc9th.domain.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Term extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false, length = 100)
private String name;
}
38 changes: 38 additions & 0 deletions src/main/java/com/example/umc9th/domain/user/entity/User.java

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1:N 연관관계 매핑이 안되어 있어요
https://github.com/onetomany

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.example.umc9th.domain.user.entity;

import com.example.umc9th.domain.common.BaseEntity;
import com.example.umc9th.domain.user.enums.Gender;
import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDate;

@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class User extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false, length = 20)
private String name;

@Enumerated(EnumType.STRING)
@Column(columnDefinition = "VARCHAR(10)")
private Gender gender;

@Column(length = 40)
private String address;

private LocalDate birth;

@Column(length = 50)
private String email;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이메일 주소의 length 는 255로 하는것이 좋을거같아요. 50자를 넘는 이메일도 존재할 수 있어요.
https://stackoverflow.com/questions/386294/what-is-the-maximum-length-of-a-valid-email-address

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그러네요 감사합니다


@Column(name = "phone_number", length = 20)
private String phoneNumber;

private LocalDate deletedAt;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.umc9th.domain.user.enums;

public enum Gender {
MALE, FEMALE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.example.umc9th.domain.user_food.entity;

import com.example.umc9th.domain.common.BaseEntity;
import com.example.umc9th.domain.food.entity.Food;
import com.example.umc9th.domain.user.entity.User;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class UserFood extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

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

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "food_id")
private Food food;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example.umc9th.domain.user_mission.entity;

import com.example.umc9th.domain.common.BaseEntity;
import com.example.umc9th.domain.mission.entity.Mission;
import com.example.umc9th.domain.user.entity.User;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class UserMission extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private Boolean complete;

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

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "mission_id")
private Mission mission;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.example.umc9th.domain.user_term.entity;

import com.example.umc9th.domain.common.BaseEntity;
import com.example.umc9th.domain.term.entity.Term;
import com.example.umc9th.domain.user.entity.User;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class UserTerm extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

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

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "term_id")
private Term term;
}
19 changes: 19 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
spring:
# === ?????? ?? ?? ===
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
# 'umc9th2' ??????? ?????. MySQL Workbench?? ?? ??????!
url: jdbc:mysql://localhost:3306/umc9th2?serverTimezone=Asia/Seoul&useSSL=false
username: root
password: ssms101504@ # ? ??? ?? ????? ?????!

# === JPA(?????? ??? ??) ?? ===
jpa:
hibernate:
# ? ?? ??? ?? ??? ?? DB ???? ???? ??????.
ddl-auto: create
properties:
hibernate:
# ???? SQL ??? ??? ? ? ?? ??? ?????.
show_sql: true
format_sql: true
13 changes: 13 additions & 0 deletions src/test/java/com/example/umc9th/Umc9thApplicationTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.umc9th;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class Umc9thApplicationTests {

@Test
void contextLoads() {
}

}