Skip to content

Commit

Permalink
Merge pull request #22 from OurMenu/KAN-17-feat/domain
Browse files Browse the repository at this point in the history
[Feat] BaseEntity 추가, 지연로딩 추가
  • Loading branch information
david-parkk authored Jan 5, 2025
2 parents d4bfc90 + 74332c8 commit fd5fabe
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.ourmenu.backend.domain.menu.domain;

import com.ourmenu.backend.domain.store.domain.Store;
import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
Expand All @@ -18,7 +20,7 @@
@AllArgsConstructor
@Builder
@Getter
public class Menu {
public class Menu extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -39,6 +41,6 @@ public class Menu {
@NotNull
private Long userId;

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
private Store store;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ourmenu.backend.domain.menu.domain;

import com.ourmenu.backend.domain.menu.dto.MenuFolderDto;
import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand All @@ -20,7 +21,7 @@
@AllArgsConstructor
@Builder
@Getter
public class MenuFolder {
public class MenuFolder extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ourmenu.backend.domain.menu.domain;

import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand All @@ -15,7 +16,7 @@
@AllArgsConstructor
@Builder
@Getter
public class MenuImg {
public class MenuImg extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.ourmenu.backend.domain.menu.domain;

import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
Expand All @@ -18,13 +20,13 @@
@AllArgsConstructor
@Builder
@Getter
public class MenuMenuFolder {
public class MenuMenuFolder extends BaseEntity {

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

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
private Menu menu;

private Long folderId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.ourmenu.backend.domain.search.domain;

import com.ourmenu.backend.domain.store.domain.Store;
import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
Expand All @@ -18,7 +20,7 @@
@AllArgsConstructor
@Builder
@Getter
public class NotFoundStore {
public class NotFoundStore extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -36,6 +38,6 @@ public class NotFoundStore {
@NotNull
private Double mapY;

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
private Store store;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ourmenu.backend.domain.search.domain;

import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand All @@ -19,7 +20,7 @@
@AllArgsConstructor
@Builder
@Getter
public class NotOwnedMenuSearch {
public class NotOwnedMenuSearch extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ourmenu.backend.domain.search.domain;

import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand All @@ -19,7 +20,7 @@
@AllArgsConstructor
@Builder
@Getter
public class OwnedMenuSearch {
public class OwnedMenuSearch extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.ourmenu.backend.domain.store.domain;

import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
Expand All @@ -17,7 +19,7 @@
@AllArgsConstructor
@Builder
@Getter
public class Map {
public class Map extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -29,6 +31,6 @@ public class Map {
@NotNull
private Double mapY;

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
private Store store;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ourmenu.backend.domain.store.domain;

import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand All @@ -16,7 +17,7 @@
@AllArgsConstructor
@Builder
@Getter
public class Store {
public class Store extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.ourmenu.backend.domain.tag.domain;

import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
Expand All @@ -17,7 +19,7 @@
@AllArgsConstructor
@Builder
@Getter
public class MenuTag {
public class MenuTag extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -26,6 +28,6 @@ public class MenuTag {
@NotNull
private Long menuId;

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
private Tag tag;
}
3 changes: 2 additions & 1 deletion src/main/java/com/ourmenu/backend/domain/tag/domain/Tag.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ourmenu.backend.domain.tag.domain;

import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand All @@ -16,7 +17,7 @@
@AllArgsConstructor
@Builder
@Getter
public class Tag {
public class Tag extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ourmenu.backend.domain.user.domain;

import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand All @@ -14,7 +15,7 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MealTime {
public class MealTime extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/ourmenu/backend/domain/user/domain/User.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.ourmenu.backend.domain.user.domain;

import jakarta.persistence.*;
import com.ourmenu.backend.global.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -11,7 +15,7 @@
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class User{
public class User extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -23,7 +27,7 @@ public class User{

private SignInType signInType;

public void changePassword(String newPassword){
public void changePassword(String newPassword) {
this.password = newPassword;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.ourmenu.backend.global.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@Configuration
@EnableJpaAuditing
public class BaseEntityConfig {
}
21 changes: 21 additions & 0 deletions src/main/java/com/ourmenu/backend/global/domain/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.ourmenu.backend.global.domain;

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

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
@Getter
public abstract class BaseEntity {

@CreatedDate
private LocalDateTime createdAt;

@LastModifiedDate
private LocalDateTime modifiedAt;
}

0 comments on commit fd5fabe

Please sign in to comment.