Skip to content

Commit

Permalink
firebase notification
Browse files Browse the repository at this point in the history
  • Loading branch information
문준호 authored and 문준호 committed Mar 19, 2024
1 parent c4d49fa commit 79d271c
Show file tree
Hide file tree
Showing 26 changed files with 193 additions and 307 deletions.
Binary file modified .gradle/7.2/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.2/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/7.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.2/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/7.2/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/checksums/checksums.lock
Binary file not shown.
Binary file modified .gradle/checksums/md5-checksums.bin
Binary file not shown.
Binary file modified .gradle/checksums/sha1-checksums.bin
Binary file not shown.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ dependencies {

//firebase
implementation 'com.google.firebase:firebase-admin:9.2.0'
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.2.2'

}
tasks.named('test') {
Expand Down
4 changes: 2 additions & 2 deletions src/main/generated/com/example/just/Dao/QMember.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class QMember extends EntityPathBase<Member> {

public final StringPath email = createString("email");

public final StringPath fcmToken = createString("fcmToken");

public final NumberPath<Long> id = createNumber("id", Long.class);

public final ListPath<Comment, QComment> likedComments = this.<Comment, QComment>createList("likedComments", Comment.class, QComment.class, PathInits.DIRECT2);
Expand All @@ -40,8 +42,6 @@ public class QMember extends EntityPathBase<Member> {

public final StringPath nickname = createString("nickname");

public final ListPath<Notification, QNotification> notifications = this.<Notification, QNotification>createList("notifications", Notification.class, QNotification.class, PathInits.DIRECT2);

public final ListPath<Post, QPost> posts = this.<Post, QPost>createList("posts", Post.class, QPost.class, PathInits.DIRECT2);

public final StringPath provider = createString("provider");
Expand Down
61 changes: 0 additions & 61 deletions src/main/generated/com/example/just/Dao/QNotification.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-03-14T18:31:05+0900",
date = "2024-03-19T14:53:30+0900",
comments = "version: 1.5.3.Final, compiler: IncrementalProcessingEnvironment from gradle-language-java-7.2.jar, environment: Java 11.0.11 (AdoptOpenJDK)"
)
@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-03-14T18:31:05+0900",
date = "2024-03-19T14:53:30+0900",
comments = "version: 1.5.3.Final, compiler: IncrementalProcessingEnvironment from gradle-language-java-7.2.jar, environment: Java 11.0.11 (AdoptOpenJDK)"
)
@Component
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/example/just/Config/FirebaseConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FirebaseConfig {

@Value("${fcm.key-file}")
private String serviceAccountFilePath;

@Value("${fcm.project-id}")
private String projectId;
@PostConstruct
public void init(){
try {
FileInputStream serviceAccount =
new FileInputStream("src/main/resources/key/just-firebase-key.json");
new FileInputStream(serviceAccountFilePath);
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setProjectId(projectId)
.build();
FirebaseApp.initializeApp(options);
} catch (Exception e) {
Expand Down

This file was deleted.

9 changes: 3 additions & 6 deletions src/main/java/com/example/just/Dao/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class Member {
@Column(name = "refresh_token")
private String refreshToken;

@Column(name = "fcm_token")
private String fcmToken;

@Builder.Default //안 써도 되는데 경고떠서 그냥 부침
@OneToMany(mappedBy = "member", cascade = CascadeType.REMOVE,fetch = FetchType.EAGER, orphanRemoval=true)
@JsonIgnore
Expand All @@ -70,11 +73,6 @@ public void addBlame(){
blameCount++;
}

@OneToMany(mappedBy = "receiver") //알림
private List<Notification> notifications;
public void updateMember(final Post post) {
posts.add(post);
}


public Member(Member member) {
Expand All @@ -89,7 +87,6 @@ public Member(Member member) {
this.blameCount = member.getBlameCount();
this.posts = member.getPosts();
this.likedPosts = member.getLikedPosts();
this.notifications = member.getNotifications();
}
}

Expand Down
98 changes: 49 additions & 49 deletions src/main/java/com/example/just/Dao/Notification.java
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
package com.example.just.Dao;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "notification")
@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class Notification implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long notId;

@Column(name = "not_type") //알림 타입
private String notType;

@Column(name = "not_post_id") //알림 내용
private Long notPostId;

@Column(name = "not_datetime") //알림 발생 시일
private Date notDatetime;
//
// @Column(name = "not_read_datetime") //알림 읽은 시간
// private Date not_read_dateTime;

@Column(nullable = false)
private Boolean notIsRead; //알림 읽음 여부
@ManyToOne
@JoinColumn(name = "id")
@OnDelete(action = OnDeleteAction.CASCADE) //알림을 받을 member
private Member receiver;

@Column(name = "not_sender_id") //송신자 id
private Long senderId;


}
//package com.example.just.Dao;
//
//import lombok.AllArgsConstructor;
//import lombok.Builder;
//import lombok.Getter;
//import lombok.NoArgsConstructor;
//import org.hibernate.annotations.OnDelete;
//import org.hibernate.annotations.OnDeleteAction;
//
//import javax.persistence.*;
//import java.io.Serializable;
//import java.util.Date;
//import java.util.List;
//
//@Entity
//@Table(name = "notification")
//@Builder
//@Getter
//@NoArgsConstructor
//@AllArgsConstructor
//public class Notification implements Serializable {
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private Long notId;
//
// @Column(name = "not_type") //알림 타입
// private String notType;
//
// @Column(name = "not_post_id") //알림 내용
// private Long notPostId;
//
// @Column(name = "not_datetime") //알림 발생 시일
// private Date notDatetime;
////
//// @Column(name = "not_read_datetime") //알림 읽은 시간
//// private Date not_read_dateTime;
//
// @Column(nullable = false)
// private Boolean notIsRead; //알림 읽음 여부
// @ManyToOne
// @JoinColumn(name = "id")
// @OnDelete(action = OnDeleteAction.CASCADE) //알림을 받을 member
// private Member receiver;
//
// @Column(name = "not_sender_id") //송신자 id
// private Long senderId;
//
//
//}
1 change: 0 additions & 1 deletion src/main/java/com/example/just/Dao/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public void updatePost(String post_tag, Long post_like, Date post_create_time,
this.secret = secret;
this.emoticon = emoticon;
this.member = member;
this.member.updateMember(this);
}

public void addLike(Member member) {
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/com/example/just/Document/MemberDocument.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.just.Document;

import com.example.just.Dao.Comment;
import com.example.just.Dao.Notification;
import com.example.just.Dao.Post;
import com.example.just.Dao.Role;
import java.util.ArrayList;
Expand Down Expand Up @@ -60,8 +59,6 @@ public class MemberDocument {
@Field(type = FieldType.Nested)
private List<Comment> likedComments = new ArrayList<>();

@Field(type = FieldType.Nested)
private List<Notification> notifications;
}


39 changes: 39 additions & 0 deletions src/main/java/com/example/just/Dto/FCMMessageDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.example.just.Dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Builder
@AllArgsConstructor
@Getter
public class FCMMessageDto {
private boolean validateOnly;
private FCMMessage message;

@Builder
@AllArgsConstructor
@Getter
public static class FCMMessage{
private Notification notification;
private String token;
private Data data;
}

@Builder
@AllArgsConstructor
@Getter
public static class Notification{
private String title;
private String body;
}

@Builder
@AllArgsConstructor
@Getter
public static class Data{
private String name;
private String description;
}

}
39 changes: 0 additions & 39 deletions src/main/java/com/example/just/Dto/NotificationDto.java

This file was deleted.

Loading

0 comments on commit 79d271c

Please sign in to comment.