-
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.
feat(notification): add PushToken entity (#164)
* feat(notification): add PushToken entity * refactor(notification): inherited Persistent Interface
- Loading branch information
1 parent
4c59677
commit de72cff
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/main/java/com/e2i/wemeet/domain/notification/PushToken.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,49 @@ | ||
package com.e2i.wemeet.domain.notification; | ||
|
||
import com.e2i.wemeet.domain.base.BaseTimeEntity; | ||
import com.e2i.wemeet.domain.member.Member; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.domain.Persistable; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Table(name = "PUSH_TOKEN") | ||
@Entity | ||
public class PushToken extends BaseTimeEntity implements Persistable<String> { | ||
|
||
@Id | ||
private String token; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
@Builder | ||
public PushToken(String token, Member member) { | ||
this.token = token; | ||
this.member = member; | ||
} | ||
|
||
private void setMember(final Member member) { | ||
this.member = member; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return this.token; | ||
} | ||
|
||
@Override | ||
public boolean isNew() { | ||
return createdAt == null; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/e2i/wemeet/domain/notification/PushTokenRepository.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 com.e2i.wemeet.domain.notification; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface PushTokenRepository extends JpaRepository<PushToken, String> { | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/resources/db/migration/V2311081752__create_push_token.sql
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,9 @@ | ||
CREATE TABLE IF NOT EXISTS `push_token` | ||
( | ||
`token` varchar(100) NOT NULL, | ||
`member_id` bigint, | ||
PRIMARY KEY (`token`), | ||
FOREIGN KEY (`member_id`) REFERENCES member (`member_id`) ON DELETE CASCADE | ||
) | ||
ENGINE = InnoDB | ||
DEFAULT CHARACTER SET = utf8mb4; |