-
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
8 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
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
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
16 changes: 16 additions & 0 deletions
16
...in/src/main/java/allchive/server/domain/domains/quitReason/adaptor/QuitReasonAdaptor.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 allchive.server.domain.domains.quitReason.adaptor; | ||
|
||
import allchive.server.core.annotation.Adaptor; | ||
import allchive.server.domain.domains.quitReason.domain.QuitReason; | ||
import allchive.server.domain.domains.quitReason.repository.QuitReasonRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Adaptor | ||
@RequiredArgsConstructor | ||
public class QuitReasonAdaptor { | ||
private final QuitReasonRepository quitReasonRepository; | ||
|
||
public void save(QuitReason quitReason) { | ||
quitReasonRepository.save(quitReason); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Domain/src/main/java/allchive/server/domain/domains/quitReason/domain/QuitReason.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 allchive.server.domain.domains.quitReason.domain; | ||
|
||
import allchive.server.domain.common.model.BaseTimeEntity; | ||
import allchive.server.domain.domains.quitReason.domain.enums.Reason; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
import javax.validation.constraints.NotNull; | ||
|
||
@Getter | ||
@Table(name = "tbl_quit_reason") | ||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class QuitReason extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
private Long userId; | ||
|
||
private Reason reason; | ||
|
||
@Builder | ||
private QuitReason(Long userId, Reason reason) { | ||
this.userId = userId; | ||
this.reason = reason; | ||
} | ||
|
||
public static QuitReason of(Long userId, Reason reason) { | ||
return QuitReason.builder() | ||
.userId(userId) | ||
.reason(reason) | ||
.build(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Domain/src/main/java/allchive/server/domain/domains/quitReason/domain/enums/Reason.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,31 @@ | ||
package allchive.server.domain.domains.quitReason.domain.enums; | ||
|
||
import allchive.server.domain.domains.user.domain.enums.OauthProvider; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.stream.Stream; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum Reason { | ||
NOT_USED("NOT_USED"), // 자주 사용하지 않아서 | ||
UNCONFORTABLE("UNCONFORTABLE"), // 이용이 불편하고 장애가 많아서 | ||
USE_OTHER_SERVICE("USE_OTHER_SERVICE"), //다른 대체 서비스를 이용해서 | ||
EXPENSIVE("EXPENSIVE"), // 서비스 이용료가 비싸서 | ||
NEW_ACCOUNT("NEW_ACCOUNT"), //새 계정을 만들고싶어서 | ||
ETC("ETC"); | ||
|
||
@JsonValue | ||
private String value; | ||
|
||
@JsonCreator | ||
public static Reason parsing(String inputValue) { | ||
return Stream.of(Reason.values()) | ||
.filter(type -> type.getValue().equals(inputValue)) | ||
.findFirst() | ||
.orElse(null); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
.../main/java/allchive/server/domain/domains/quitReason/repository/QuitReasonRepository.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,7 @@ | ||
package allchive.server.domain.domains.quitReason.repository; | ||
|
||
import allchive.server.domain.domains.quitReason.domain.QuitReason; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface QuitReasonRepository extends JpaRepository<QuitReason, Long> { | ||
} |
16 changes: 16 additions & 0 deletions
16
.../main/java/allchive/server/domain/domains/quitReason/service/QuitReasonDomainService.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 allchive.server.domain.domains.quitReason.service; | ||
|
||
import allchive.server.core.annotation.DomainService; | ||
import allchive.server.domain.domains.quitReason.adaptor.QuitReasonAdaptor; | ||
import allchive.server.domain.domains.quitReason.domain.QuitReason; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@DomainService | ||
@RequiredArgsConstructor | ||
public class QuitReasonDomainService { | ||
private final QuitReasonAdaptor quitReasonAdaptor; | ||
|
||
public void save(QuitReason quitReason) { | ||
quitReasonAdaptor.save(quitReason); | ||
} | ||
} |
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