Skip to content

Commit

Permalink
Feature/set-Entity (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
YeaChan05 authored Feb 8, 2024
2 parents 7831c09 + cdcefc1 commit 33839c5
Show file tree
Hide file tree
Showing 38 changed files with 917 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.kakaoshare.backend.domain.base.entity;

import jakarta.persistence.Column;
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;

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

@CreatedDate
@Column(updatable = false)
protected LocalDateTime createdAt;

@LastModifiedDate
protected LocalDateTime updatedAt;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.kakaoshare.backend.domain.brand.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
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.OneToMany;
import java.util.List;
import lombok.Getter;
import org.kakaoshare.backend.domain.base.entity.BaseTimeEntity;
import org.kakaoshare.backend.domain.category.entity.Category;
import org.kakaoshare.backend.domain.product.entity.Product;


@Entity
@Getter
public class Brand extends BaseTimeEntity {

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

@Column(nullable = false)
private String name;

@Column
private String iconPhoto;

@Column(nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "category_id")
private Category category;

@OneToMany(mappedBy = "brand")
private List<Product> products;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.kakaoshare.backend.domain.brand.repository;

import org.kakaoshare.backend.domain.brand.entity.Brand;
import org.springframework.data.jpa.repository.JpaRepository;


public interface BrandRepository extends JpaRepository<Brand, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.kakaoshare.backend.domain.category.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
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.OneToMany;
import java.util.List;
import lombok.Getter;
import org.kakaoshare.backend.domain.base.entity.BaseTimeEntity;


@Entity
@Getter
public class Category extends BaseTimeEntity {

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

@Column(nullable = false)
private String name;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_id")
private Category parent;

@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
private List<Category> Categories;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.kakaoshare.backend.domain.category.repository;

import org.kakaoshare.backend.domain.category.entity.Category;
import org.springframework.data.jpa.repository.JpaRepository;


public interface CategoryRepository extends JpaRepository<Category, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.kakaoshare.backend.domain.funding.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
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.OneToMany;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.List;
import lombok.Getter;
import org.kakaoshare.backend.domain.base.entity.BaseTimeEntity;
import org.kakaoshare.backend.domain.member.entity.Member;
import org.kakaoshare.backend.domain.product.entity.Product;


@Entity
@Getter
public class Funding extends BaseTimeEntity {

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

@Column
private String status;

@Column(nullable = false)
private LocalDate expiredAt;

@Column(nullable = false, precision = 12, scale = 2)
private BigDecimal goalAmount;

@Column(nullable = false, precision = 12, scale = 2)
private BigDecimal accumulateAmount;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id", nullable = false)
private Member member;

@OneToMany(mappedBy = "funding")
private List<FundingDetail> fundingDetails;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "product_id", nullable = false)
private Product product;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.kakaoshare.backend.domain.funding.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
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.OneToMany;
import java.math.BigDecimal;
import java.util.List;
import lombok.Getter;
import org.kakaoshare.backend.domain.base.entity.BaseTimeEntity;
import org.kakaoshare.backend.domain.order.entity.Order;


@Entity
@Getter
public class FundingDetail extends BaseTimeEntity {

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

@Column(nullable = false, precision = 12, scale = 2)
private BigDecimal amount;

@Column(nullable = false, precision = 7, scale = 2)
private BigDecimal rate;

@OneToMany(mappedBy = "fundingDetail")
private List<Order> orders;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "funding_id", nullable = false)
private Funding funding;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.kakaoshare.backend.domain.funding.repository;

import org.kakaoshare.backend.domain.funding.entity.FundingDetail;
import org.springframework.data.jpa.repository.JpaRepository;


public interface FundingDetailRepository extends JpaRepository<FundingDetail, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.kakaoshare.backend.domain.funding.repository;

import org.kakaoshare.backend.domain.funding.entity.Funding;
import org.springframework.data.jpa.repository.JpaRepository;


public interface FundingRepository extends JpaRepository<Funding, Long> {
}
40 changes: 40 additions & 0 deletions src/main/java/org/kakaoshare/backend/domain/gift/entity/Gift.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.kakaoshare.backend.domain.gift.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
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 lombok.Getter;
import org.kakaoshare.backend.domain.base.entity.BaseTimeEntity;
import org.kakaoshare.backend.domain.order.entity.Order;
import org.kakaoshare.backend.domain.product.entity.Product;


@Entity
@Getter
public class Gift extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long giftId;
@Column(nullable = false, length = 50)
private String status;

@Column
private String message;

@Column
private String messagePhoto;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "orders_id", nullable = false)
private Order order;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "product_id", nullable = false)
private Product product;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.kakaoshare.backend.domain.gift.repository;

import org.kakaoshare.backend.domain.gift.entity.Gift;
import org.springframework.data.jpa.repository.JpaRepository;


public interface GiftRepository extends JpaRepository<Gift, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.kakaoshare.backend.domain.hashtag.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import java.util.List;
import lombok.Getter;
import org.kakaoshare.backend.domain.base.entity.BaseTimeEntity;


@Entity
@Getter
public class Hashtag extends BaseTimeEntity {

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

@Column(nullable = false)
private String name;

@OneToMany(mappedBy = "hashtag")
private List<ProductHashtag> ProductHashtags;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.kakaoshare.backend.domain.hashtag.entity;

import jakarta.persistence.Entity;
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 lombok.Getter;
import org.kakaoshare.backend.domain.base.entity.BaseTimeEntity;
import org.kakaoshare.backend.domain.hashtag.entity.Hashtag;
import org.kakaoshare.backend.domain.product.entity.Product;


@Entity
@Getter
public class ProductHashtag extends BaseTimeEntity {

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

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "hashtag_id", nullable = false)
private Hashtag hashtag;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "product_id", nullable = false)
private Product product;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.kakaoshare.backend.domain.hashtag.repository;

import org.kakaoshare.backend.domain.hashtag.entity.Hashtag;
import org.springframework.data.jpa.repository.JpaRepository;


public interface HashtagRepository extends JpaRepository<Hashtag, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.kakaoshare.backend.domain.member.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import java.util.List;
import lombok.Getter;
import org.kakaoshare.backend.domain.base.entity.BaseTimeEntity;
import org.kakaoshare.backend.domain.order.entity.Order;
import org.kakaoshare.backend.domain.funding.entity.Funding;


@Entity
@Getter
public class Member extends BaseTimeEntity {

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

@Column(nullable = false)
private String email;

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

@Column
private String kakaoId;

@Column
private String kakaoUuid;

@OneToMany(mappedBy = "member")
private List<Order> orders;

@OneToMany(mappedBy = "member")
private List<Funding> funding;

}
Loading

0 comments on commit 33839c5

Please sign in to comment.