Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 초기 엔티티 생성 #6

Merged
merged 20 commits into from
Jan 1, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.sweet.domain.gift.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/api/gift")
@RestController
public class GiftController {
}
42 changes: 42 additions & 0 deletions src/main/java/org/sopt/sweet/domain/gift/entity/Gift.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.sopt.sweet.domain.gift.entity;

import jakarta.persistence.*;
import lombok.*;
import org.sopt.sweet.domain.gifter.entity.Gifter;
import org.sopt.sweet.domain.member.entity.Member;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder(access = AccessLevel.PRIVATE)
@Table(name = "gift")
@Entity
public class Gift {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "gift_id")
private Long id;

@Column(nullable = false)
private String url;

@Column(nullable = false)
private String name;

@Column(nullable = false)
private int cost;

private String img;

@Builder.Default
private int score = 0;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gifter_id")
private Gifter gifter;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id", nullable = false)
private Member member;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.sopt.sweet.domain.gift.repository;

import org.sopt.sweet.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,9 @@
package org.sopt.sweet.domain.gift.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class GiftService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.sopt.sweet.domain.gifter.constant;

public enum TournamentDuration {
SIX_HOURS(6),
TWELVE_HOURS(12),
EIGHTEEN_HOURS(18),
TWENTY_FOUR_HOURS(24);

private final int hours;

TournamentDuration(int hours) {
this.hours = hours;
}

public int getHours() {
return hours;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.sweet.domain.gifter.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/api/gifter")
@RestController
public class GifterController {
}
46 changes: 46 additions & 0 deletions src/main/java/org/sopt/sweet/domain/gifter/entity/Gifter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.sopt.sweet.domain.gifter.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import lombok.*;
import org.sopt.sweet.domain.gifter.constant.TournamentDuration;
import org.sopt.sweet.domain.member.entity.Member;

import java.time.LocalDateTime;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder(access = AccessLevel.PRIVATE)
@Table(name = "gifter")
@Entity
public class Gifter {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "gifter_id")
private Long id;

@Column(nullable = false)
private String gifteeName;

private String img;

@Builder.Default
private int gifterNum = 0;

@Column(nullable = false)
private LocalDateTime deliveryDate;

@Column(nullable = false)
private LocalDateTime tournamentStartDate;

@Column(nullable = false)
private TournamentDuration tournamentDuration;

private String invitationCode;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "host_id", nullable = false)
private Member host;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.sopt.sweet.domain.gifter.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import lombok.*;
import org.sopt.sweet.domain.member.entity.Member;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder(access = AccessLevel.PRIVATE)
@Entity
public class GifterMember {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "gifter_member_id")
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gifter_id")
private Gifter gifter;

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

@Column(columnDefinition = "TINYINT(1) default 0")
private boolean tournamentParticipation;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.sopt.sweet.domain.gifter.repository;

import org.sopt.sweet.domain.gifter.entity.GifterMember;
import org.springframework.data.jpa.repository.JpaRepository;

public interface GifterMemberRepository extends JpaRepository<GifterMember, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.sopt.sweet.domain.gifter.repository;

import org.sopt.sweet.domain.gifter.entity.Gifter;
import org.springframework.data.jpa.repository.JpaRepository;

public interface GifterRepository extends JpaRepository<Gifter, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.sweet.domain.gifter.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class GifterService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.sopt.sweet.domain.member.constant;

public enum SocialType {
KAKAO, GOOGLE, NAVER
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.sweet.domain.member.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/api/member")
@RestController
public class MemberController {

}
33 changes: 33 additions & 0 deletions src/main/java/org/sopt/sweet/domain/member/entity/Member.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.sopt.sweet.domain.member.entity;

import jakarta.persistence.*;
import lombok.*;
import org.sopt.sweet.domain.member.constant.SocialType;
import org.sopt.sweet.global.common.BaseTimeEntity;


@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder(access = AccessLevel.PRIVATE)
@Table(name = "member")
@Entity
public class Member extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "member_id")
private Long id;

@Column(nullable = false)
private String socialId;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private SocialType socialType;

private String profileImg;

private String nickName;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.sopt.sweet.domain.member.repository;

import org.sopt.sweet.domain.member.entity.Member;
import org.springframework.data.jpa.repository.JpaRepository;

public interface MemberRepository extends JpaRepository<Member, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.sweet.domain.member.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class MemberService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.sweet.domain.product.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/api/product")
@RestController
public class ProductController {
}
30 changes: 30 additions & 0 deletions src/main/java/org/sopt/sweet/domain/product/entity/Product.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.sopt.sweet.domain.product.entity;

import jakarta.persistence.*;
import lombok.*;
import org.sopt.sweet.global.common.BaseTimeEntity;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder(access = AccessLevel.PRIVATE)
@Table(name = "product")
@Entity
public class Product extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "product_id")
private Long id;

@Column(nullable = false)
private String url;

@Column(nullable = false)
private String name;

@Column(nullable = false)
private int cost;

private String img;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.sopt.sweet.domain.product.repository;

import org.sopt.sweet.domain.product.entity.Product;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ProductRepository extends JpaRepository<Product, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.sweet.domain.product.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ProductService {
}