-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feature: 멤버 도메인 구현 * refactor: getter 추가 * feature: 마일리지 도메인 추가 * style: spotless apply * feature: 마일리지 레포지토리 추가
- Loading branch information
1 parent
93038da
commit 3cea371
Showing
8 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/main/java/com/goldbalance/dive/domain/member/api/MemberController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.goldbalance.dive.domain.member.api; | ||
|
||
public class MemberController {} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/goldbalance/dive/domain/member/domain/Member.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/goldbalance/dive/domain/member/domain/Mileage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/goldbalance/dive/domain/member/domain/MileageType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/goldbalance/dive/domain/member/domain/Tier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/goldbalance/dive/domain/member/repository/MemberRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Member, Long> {} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/goldbalance/dive/domain/member/repository/MileageRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Mileage, Long> {} |
3 changes: 3 additions & 0 deletions
3
src/main/java/com/goldbalance/dive/domain/member/service/MemberService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.goldbalance.dive.domain.member.service; | ||
|
||
public class MemberService {} |