Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…erver into feature/home/receiver
  • Loading branch information
Kang1221 committed May 1, 2024
2 parents d39fe29 + 11ce126 commit c5e2f79
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
13 changes: 11 additions & 2 deletions src/main/java/zero/eight/donut/config/firebase/FcmUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class FcmUtils {
private final GiverRepository giverRepository;
private final ReceiverRepository receiverRepository;
private final FcmTokenRepository fcmTokenRepository;
private final FirebaseMessaging firebaseMessaging;



Expand Down Expand Up @@ -60,10 +59,20 @@ public FcmMemberDto getMemberDto() throws Exception {
public String sendMessage(Long memberId, String title, String body) throws FirebaseMessagingException {
// 알림 수신자의 FCM 토큰 조회
String fcmToken = getFcmToken(memberId);
log.info("fcmToken -> {}", fcmToken);

// FCM 메세지 생성
Message message = makeMessage(fcmToken, title, body);
log.info("message -> {}", message);

// FCM 발신
return firebaseMessaging.send(message);
//return firebaseMessaging.send(message);
try {
return FirebaseMessaging.getInstance().send(message);
} catch (Exception e) {
log.info(e.getMessage());
return "Falied to send notification";
}
}

public String getFcmToken(Long memberId) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/zero/eight/donut/controller/FcmController.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ public ApiResponse<?> test30() throws FirebaseMessagingException {
}

@GetMapping("/mock/37/{email}")
public ApiResponse<?> mock37(@PathVariable("email") String email, @RequestParam("product") String product) throws FirebaseMessagingException {
public ApiResponse<?> mock37(@PathVariable(name = "email") String email, @RequestParam(name = "product") String product) throws FirebaseMessagingException {
return ApiResponse.success(Success.FCM_TEST_SUCCESS, fcmService.mock37(email, product));
}

@GetMapping("/mock/30/{email}")
public ApiResponse<?> mock30(@PathVariable("email") String email, @RequestParam("product") String product) throws FirebaseMessagingException {
public ApiResponse<?> mock30(@PathVariable(name = "email") String email, @RequestParam(name = "product") String product) throws FirebaseMessagingException {
return ApiResponse.success(Success.FCM_TEST_SUCCESS, fcmService.mock30(email, product));
}

@GetMapping("/mock/7/{email}")
public ApiResponse<?> mock7(@PathVariable("email") String email, @RequestParam("product") String product) throws FirebaseMessagingException {
return ApiResponse.success(Success.FCM_TEST_SUCCESS, fcmService.mock30(email, product));
@GetMapping("/mock/7/{name}")
public ApiResponse<?> mock7(@PathVariable(name = "name") String name, @RequestParam(name = "store") String store) throws FirebaseMessagingException {
return ApiResponse.success(Success.FCM_TEST_SUCCESS, fcmService.mock7(name, store));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public class HistoryGiverController {
private final AuthService authService;

@GetMapping("/info/{donateDate}")
public ApiResponse<?> getDonationList(@PathVariable("donateDate")LocalDateTime donateDate){
public ApiResponse<?> getDonationList(@PathVariable(name = "donateDate")LocalDateTime donateDate){
return historyGiverService.getDonationList(donateDate);
}

@GetMapping("/info/detail/{giftId}")
public ApiResponse<?> getDonationDetail(@PathVariable("giftId")Long giftId){
public ApiResponse<?> getDonationDetail(@PathVariable(name = "giftId")Long giftId){
return historyGiverService.getDonationDetail(giftId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public ApiResponse<?> receiverHome(){
}

@GetMapping("/box/{boxId}")
public ApiResponse<?> receiverGetOneBox(@PathVariable("boxId") Long boxId){
public ApiResponse<?> receiverGetOneBox(@PathVariable(name = "boxId") Long boxId){
return homeReceiverService.receiverGetOneBox(boxId);
}

@GetMapping("/gift/{giftId}")
public ApiResponse<?> receiverGetOneGuft(@PathVariable("giftId") Long giftId){
public ApiResponse<?> receiverGetOneGuft(@PathVariable(name = "giftId") Long giftId){
return homeReceiverService.receiverGetOneGift(giftId);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package zero.eight.donut.dto.fcm;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public class FcmTokenRequestDto {
private final String token;
private String token;
}
1 change: 1 addition & 0 deletions src/main/java/zero/eight/donut/service/FcmService.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public ApiResponse<?> registerFcmToken(FcmTokenRequestDto requestDto) throws Exc
() -> fcmTokenRepository.save(FcmToken.builder()
.token(token)
.memberId(member.getId())
.role(member.getRole())
.build())
);

Expand Down

0 comments on commit c5e2f79

Please sign in to comment.