Skip to content

Commit

Permalink
"FEAT": 이메일 알림 구현중
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaalsghks8 committed Dec 21, 2024
1 parent 24ce1f8 commit 803753a
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 64 deletions.
1 change: 1 addition & 0 deletions server_9dokme/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ dependencies {
//jwt
implementation 'io.jsonwebtoken:jjwt:0.9.1'


}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,39 @@
import com.example.server_9dokme.book.dto.request.BookUpdateRequest;
import com.example.server_9dokme.book.dto.response.BookInfoResponse;
import com.example.server_9dokme.book.service.BookService;
import com.example.server_9dokme.member.entity.Keyword;
import com.example.server_9dokme.member.repository.KeywordRepository;
import org.springframework.web.bind.annotation.RequestBody;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/admin")
@RequiredArgsConstructor
public class AdminController {

private final BookService bookService;



// 책 정보(pdf) 등록
@PostMapping("/books")
public ResponseEntity<BookInfoResponse> createBook(@RequestBody BookCreateRequest request) {
BookInfoResponse response = bookService.createBook(request);

String bookTitle = response.title();




//푸시알림 로직 처리
//send Notification(String[] sendMessageUserList, String bookTitle, String message)

return ResponseEntity.ok(response);
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.server_9dokme.Notification.repository;

import com.example.server_9dokme.Notification.entity.Notification;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

public interface NotificationRepository extends JpaRepository<Notification,Integer> {

Page<Notification> findAllByMember_MemberId(Long memberId, Pageable pageable);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.example.server_9dokme.Notification.service;


import com.example.server_9dokme.Notification.entity.Notification;
import com.example.server_9dokme.Notification.repository.NotificationRepository;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
@Data
@NoArgsConstructor
public class NotificationService {

@Autowired
private NotificationRepository notificationRepository;

public Page<Notification> findAllNotification(Long memberId, int pageNo){

Pageable pageable = PageRequest.of(pageNo,8);

Page<Notification> notifications = notificationRepository.findAllByMember_MemberId(memberId,pageable);

return notifications;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ public BookInfoResponse createBook(BookCreateRequest request) {
request.rent()
);
bookRepository.save(book);




return toResponse(book);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.example.server_9dokme.member.entity;


import com.example.server_9dokme.common.entity.BaseEntity;
import jakarta.persistence.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Data
@NoArgsConstructor
public class Device extends BaseEntity {

@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private String deviceId;

private Boolean notificationStatement;

private String userFirebaseToken;

@ManyToOne
@JoinColumn(name ="member_id")
private Member member;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.example.server_9dokme.subscribe.entity.Subscribe;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Data
Expand Down Expand Up @@ -43,6 +44,8 @@ public enum SocialType {

private String billingKey;



@Builder
public Member(Long subscribeId, String userRole, String password, String nickName, String socialId, SocialType socialType, String customerKey, String authKey, String billingKey) {
this.subscribeId = subscribeId;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.server_9dokme.member.repository;

import com.example.server_9dokme.member.entity.Device;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface DeviceRepository extends JpaRepository<Device, String> {

@Query("SELECT d.deviceId " +
"FROM Device d " +
"JOIN d.member m " +
"JOIN Keyword k ON k.member.memberId = m.memberId " +
"WHERE k.keyword LIKE %:title%")
List<String> findDeviceIdsByTitle(@Param("title") String title);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.example.server_9dokme.member.entity.Keyword;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface KeywordRepository extends JpaRepository<Keyword,Integer> {

List<Keyword> findAllByKeywordContaining(String keyword);
}

0 comments on commit 803753a

Please sign in to comment.