From 6dd264601727f2e7ae70e5caa99f137fdad6546c Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期二, 30 十一月 2021 19:45:31 +0800 Subject: [PATCH] [add] 【todo 131189】新增嚴選配對年資篩選功能 --- pamapi/src/main/java/com/pollex/pam/domain/Customer.java | 47 +++++++++++++++++++++++++++++++---------------- 1 files changed, 31 insertions(+), 16 deletions(-) diff --git a/pamapi/src/main/java/com/pollex/pam/domain/Customer.java b/pamapi/src/main/java/com/pollex/pam/domain/Customer.java index 225fba6..9a94a8c 100644 --- a/pamapi/src/main/java/com/pollex/pam/domain/Customer.java +++ b/pamapi/src/main/java/com/pollex/pam/domain/Customer.java @@ -2,42 +2,45 @@ import java.io.Serializable; import java.time.Instant; +import java.util.Optional; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; +import javax.persistence.*; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import org.springframework.util.StringUtils; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.pollex.pam.enums.OtpLoginTypeEnum; +@EntityListeners(AuditingEntityListener.class) @Entity @Table(name = "customer") public class Customer implements Serializable { - - + /** - * + * */ private static final long serialVersionUID = 1L; - + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - + @Column(name = "name") private String name; - + @Column(name = "phone") private String phone; - + @Column(name = "email") private String email; - + + @Enumerated(value = EnumType.STRING) + @Column(name = "contact_type") + private OtpLoginTypeEnum contactType; + @CreatedDate @Column(name = "created_date", updatable = false) @JsonIgnore @@ -95,7 +98,19 @@ public void setLastModifiedDate(Instant lastModifiedDate) { this.lastModifiedDate = lastModifiedDate; } - - + + public OtpLoginTypeEnum getContactType() { + return contactType; + } + + public void setContactType(OtpLoginTypeEnum contactType) { + this.contactType = contactType; + } + + public String toAccountString() { + return Optional.ofNullable(getPhone()) + .filter(StringUtils::hasText) + .orElseGet(this::getEmail); + } } -- Gitblit v1.8.0