diff --git a/src/main/java/com/goldbalance/dive/domain/member/api/MemberController.java b/src/main/java/com/goldbalance/dive/domain/member/api/MemberController.java new file mode 100644 index 0000000..ebe0410 --- /dev/null +++ b/src/main/java/com/goldbalance/dive/domain/member/api/MemberController.java @@ -0,0 +1,3 @@ +package com.goldbalance.dive.domain.member.api; + +public class MemberController {} diff --git a/src/main/java/com/goldbalance/dive/domain/member/domain/Member.java b/src/main/java/com/goldbalance/dive/domain/member/domain/Member.java new file mode 100644 index 0000000..19b17bd --- /dev/null +++ b/src/main/java/com/goldbalance/dive/domain/member/domain/Member.java @@ -0,0 +1,51 @@ +package com.goldbalance.dive.domain.member.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Member { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "member_id") + private Long id; + + @Column(unique = true) + private String nickname; + + @Enumerated(EnumType.STRING) + private Tier tier; + + private long totalMileage; + + private long monthlyMileage; + + @Builder(access = AccessLevel.PRIVATE) + private Member(String nickname, Tier tier, long totalMileage, long monthlyMileage) { + this.nickname = nickname; + this.tier = tier; + this.totalMileage = totalMileage; + this.monthlyMileage = monthlyMileage; + } + + public static Member create(String nickname) { + return Member.builder() + .nickname(nickname) + .tier(Tier.BRONZE) + .totalMileage(0) + .monthlyMileage(0) + .build(); + } +} diff --git a/src/main/java/com/goldbalance/dive/domain/member/domain/Mileage.java b/src/main/java/com/goldbalance/dive/domain/member/domain/Mileage.java new file mode 100644 index 0000000..8e45030 --- /dev/null +++ b/src/main/java/com/goldbalance/dive/domain/member/domain/Mileage.java @@ -0,0 +1,51 @@ +package com.goldbalance.dive.domain.member.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +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 java.time.LocalDateTime; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Mileage { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "mileage_id") + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "member_id") + private Member member; + + private long amount; + + @Enumerated(EnumType.STRING) + private MileageType type; + + private LocalDateTime createdAt; + + @Builder(access = AccessLevel.PRIVATE) + private Mileage(Member member, long amount, MileageType type) { + this.member = member; + this.amount = amount; + this.type = type; + this.createdAt = LocalDateTime.now(); + } + + public static Mileage create(Member member, long amount, MileageType type) { + return Mileage.builder().member(member).amount(amount).type(type).build(); + } +} diff --git a/src/main/java/com/goldbalance/dive/domain/member/domain/MileageType.java b/src/main/java/com/goldbalance/dive/domain/member/domain/MileageType.java new file mode 100644 index 0000000..dbf92ee --- /dev/null +++ b/src/main/java/com/goldbalance/dive/domain/member/domain/MileageType.java @@ -0,0 +1,14 @@ +package com.goldbalance.dive.domain.member.domain; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum MileageType { + ATTENDANCE("출석"), + READ_ARTICLE("글 읽기"), + QUIZ_CORRECT("퀴즈 정답"); + + private final String mileageTypeName; +} diff --git a/src/main/java/com/goldbalance/dive/domain/member/domain/Tier.java b/src/main/java/com/goldbalance/dive/domain/member/domain/Tier.java new file mode 100644 index 0000000..e52f027 --- /dev/null +++ b/src/main/java/com/goldbalance/dive/domain/member/domain/Tier.java @@ -0,0 +1,16 @@ +package com.goldbalance.dive.domain.member.domain; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum Tier { + BRONZE("브론즈"), + SILVER("실버"), + GOLD("골드"), + DIAMOND("다이아"), + MASTER("마스터"); + + private final String tierName; +} diff --git a/src/main/java/com/goldbalance/dive/domain/member/repository/MemberRepository.java b/src/main/java/com/goldbalance/dive/domain/member/repository/MemberRepository.java new file mode 100644 index 0000000..f5bbc16 --- /dev/null +++ b/src/main/java/com/goldbalance/dive/domain/member/repository/MemberRepository.java @@ -0,0 +1,6 @@ +package com.goldbalance.dive.domain.member.repository; + +import com.goldbalance.dive.domain.member.domain.Member; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface MemberRepository extends JpaRepository {} diff --git a/src/main/java/com/goldbalance/dive/domain/member/repository/MileageRepository.java b/src/main/java/com/goldbalance/dive/domain/member/repository/MileageRepository.java new file mode 100644 index 0000000..d197631 --- /dev/null +++ b/src/main/java/com/goldbalance/dive/domain/member/repository/MileageRepository.java @@ -0,0 +1,6 @@ +package com.goldbalance.dive.domain.member.repository; + +import com.goldbalance.dive.domain.member.domain.Mileage; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface MileageRepository extends JpaRepository {} diff --git a/src/main/java/com/goldbalance/dive/domain/member/service/MemberService.java b/src/main/java/com/goldbalance/dive/domain/member/service/MemberService.java new file mode 100644 index 0000000..47a677b --- /dev/null +++ b/src/main/java/com/goldbalance/dive/domain/member/service/MemberService.java @@ -0,0 +1,3 @@ +package com.goldbalance.dive.domain.member.service; + +public class MemberService {}