Skip to content

Commit

Permalink
feat(notification): add PushToken entity (#164)
Browse files Browse the repository at this point in the history
* feat(notification): add PushToken entity

* refactor(notification): inherited Persistent Interface
  • Loading branch information
Chaerim1001 authored Nov 8, 2023
1 parent 4c59677 commit de72cff
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/main/java/com/e2i/wemeet/domain/notification/PushToken.java
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;
}
}
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> {

}
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;

0 comments on commit de72cff

Please sign in to comment.