-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/main/java/com/project1hour/api/core/domain/credit/entity/Credit.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,39 @@ | ||
package com.project1hour.api.core.domain.credit.entity; | ||
|
||
import com.project1hour.api.core.domain.credit.value.EarnType; | ||
import com.project1hour.api.core.domain.credit.value.Quantity; | ||
import com.project1hour.api.global.entity.AbstractEntity; | ||
import io.hypersistence.utils.hibernate.id.Tsid; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embedded; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.Id; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.SQLDelete; | ||
import org.hibernate.annotations.SQLRestriction; | ||
|
||
@Entity | ||
@Getter | ||
@SQLDelete(sql = "UPDATE credit SET deleted_at = now() WHERE credit_id = ?") | ||
@SQLRestriction("deleted_at IS NULL") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Credit extends AbstractEntity<Long> { | ||
|
||
@Id | ||
@Tsid | ||
@Column(name = "credit_id") | ||
private Long id; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private EarnType earnType; | ||
|
||
@Embedded | ||
private Quantity quantity; | ||
|
||
@Column(nullable = false) | ||
private Long userId; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/project1hour/api/core/domain/credit/entity/Credits.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,8 @@ | ||
package com.project1hour.api.core.domain.credit.entity; | ||
|
||
import java.util.List; | ||
|
||
public class Credits { | ||
|
||
private List<Credit> creditList; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/project1hour/api/core/domain/credit/value/EarnType.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.project1hour.api.core.domain.credit.value; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum EarnType { | ||
WELCOME_REWARD(6); | ||
|
||
private final int creditVolume; | ||
|
||
EarnType(final int creditVolume) { | ||
this.creditVolume = creditVolume; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/project1hour/api/core/domain/credit/value/Quantity.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,12 @@ | ||
package com.project1hour.api.core.domain.credit.value; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
|
||
@Embeddable | ||
public record Quantity(@Column(name = "quantity") int value) { | ||
|
||
public static Quantity fromEarnType(final EarnType earnType) { | ||
return new Quantity(earnType.getCreditVolume()); | ||
} | ||
} |