Skip to content

Commit

Permalink
Merge pull request #220 from bankidz/dev
Browse files Browse the repository at this point in the history
refactor: notice / notification으로 저장될 때 url 수정
  • Loading branch information
sanbonai06 authored Sep 11, 2022
2 parents 6db97ec + be9953a commit f874f8c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.ceos.bankids.controller;

import com.ceos.bankids.config.CommonResponse;
import com.ceos.bankids.constant.ErrorCode;
import com.ceos.bankids.controller.request.NoticeRequest;
import com.ceos.bankids.domain.User;
import com.ceos.bankids.dto.AllSendNotificationDTO;
import com.ceos.bankids.dto.NoticeDTO;
import com.ceos.bankids.dto.NoticeListDTO;
import com.ceos.bankids.exception.ForbiddenException;
import com.ceos.bankids.service.NoticeServiceImpl;
import io.swagger.annotations.ApiOperation;
import java.util.HashMap;
Expand Down Expand Up @@ -35,9 +37,9 @@ public CommonResponse<NoticeDTO> postNotice(@AuthenticationPrincipal User authUs
@RequestBody NoticeRequest noticeRequest) {

log.info("api = 공지사항 작성");
// if (authUser.getId() != 1L) {
// throw new ForbiddenException(ErrorCode.NOTICE_AUTH_ERROR.getErrorCode());
// }
if (authUser.getId() != 1L) {
throw new ForbiddenException(ErrorCode.NOTICE_AUTH_ERROR.getErrorCode());
}
String title = noticeRequest.getTitle();
String body = noticeRequest.getBody();
String message = noticeRequest.getMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.ceos.bankids.config.CommonResponse;
import com.ceos.bankids.constant.ChallengeStatus;
import com.ceos.bankids.constant.ErrorCode;
import com.ceos.bankids.constant.NotificationCategory;
import com.ceos.bankids.domain.Challenge;
import com.ceos.bankids.domain.ChallengeUser;
Expand All @@ -12,10 +13,10 @@
import com.ceos.bankids.dto.NotificationDTO;
import com.ceos.bankids.dto.NotificationIsReadDTO;
import com.ceos.bankids.dto.NotificationListDTO;
import com.ceos.bankids.exception.ForbiddenException;
import com.ceos.bankids.repository.NotificationRepository;
import com.ceos.bankids.repository.UserRepository;
import com.ceos.bankids.service.ExpoNotificationServiceImpl;
import com.ceos.bankids.service.NoticeServiceImpl;
import io.swagger.annotations.ApiOperation;
import java.util.HashMap;
import java.util.List;
Expand All @@ -39,7 +40,6 @@
public class NotificationController {

private final ExpoNotificationServiceImpl expoNotificationService;
private final NoticeServiceImpl noticeService;
private final UserRepository userRepository;
private final NotificationRepository notificationRepository;

Expand All @@ -49,9 +49,9 @@ public CommonResponse<String> allSendNotification(
@RequestBody AllSendNotificationDTO allSendNotificationRequest,
@AuthenticationPrincipal User authUser) {

// if (authUser.getId() != 1L) {
// throw new ForbiddenException(ErrorCode.NOTICE_AUTH_ERROR.getErrorCode());
// }
if (authUser.getId() != 1L) {
throw new ForbiddenException(ErrorCode.NOTICE_AUTH_ERROR.getErrorCode());
}

String title = allSendNotificationRequest.getTitle();
String message = allSendNotificationRequest.getMessage();
Expand All @@ -62,10 +62,14 @@ public CommonResponse<String> allSendNotification(
if (user.getNoticeOptIn() && user.getExpoToken()
.startsWith("ExponentPushToken")) {
expoNotificationService.sendMessage(user, title, message,
allSendNotificationRequest.getNewMap(), notificationCategory, "/");
allSendNotificationRequest.getNewMap(), notificationCategory,
"/manage/notices/" + allSendNotificationRequest.getNewMap()
.get("noticeId"));
} else {
Notification notification = Notification.builder().user(user).title(title)
.message(message).notificationCategory(notificationCategory).linkUrl("/")
.message(message).notificationCategory(notificationCategory)
.linkUrl("/manage/notices/" + allSendNotificationRequest.getNewMap()
.get("noticeId"))
.build();
notificationRepository.save(notification);
}
Expand Down

0 comments on commit f874f8c

Please sign in to comment.