Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public PagedEnrollRequestInfo getRequestEnrollList(@JwtValidation Long userId,
@GetMapping("/receive/all")
@Operation(summary = "내가 작성한 게시글에 대한 직관 신청 목록 전체 조회 API", description = "내가 작성한 게시글에 대한 직관 신청 목록을 전체 조회하는 API 입니다.")
public PagedEnrollReceiveInfo getReceiveEnrollList(@JwtValidation Long userId,
@PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC)
@Parameter(hidden = true) Pageable pageable) {
return enrollService.getReceiveEnrollList(userId, pageable);
}
Expand All @@ -70,6 +71,7 @@ public PagedEnrollReceiveInfo getReceiveEnrollList(@JwtValidation Long userId,
@Operation(summary = "내가 작성한 게시글에 대한 직관 신청 목록 조회 API", description = "내가 작성한 게시글에 대한 직관 신청 목록을 조회하는 API 입니다.")
public PagedEnrollReceiveInfo getReceiveEnrollListByBoardId(@JwtValidation Long userId,
@RequestParam Long boardId,
@PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC)
@Parameter(hidden = true) Pageable pageable) {
return enrollService.getReceiveEnrollListByBoardId(userId, boardId, pageable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import com.back.catchmate.domain.notification.dto.NotificationResponse.NotificationInfo;
import com.back.catchmate.domain.notification.dto.NotificationResponse.PagedNotificationInfo;
import com.back.catchmate.domain.notification.service.NotificationService;
import com.back.catchmate.global.dto.StateResponse;
import com.back.catchmate.global.jwt.JwtValidation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -24,6 +28,7 @@ public class NotificationController {
@GetMapping("/receive")
@Operation(summary = "내가 받은 알림 목록 조회 API", description = "내가 받은 알림 목록을 조회하는 API 입니다.")
public PagedNotificationInfo getNotificationList(@JwtValidation Long userId,
@PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC)
@Parameter(hidden = true) Pageable pageable) {
return notificationService.getNotificationList(userId, pageable);
}
Expand All @@ -34,4 +39,11 @@ public NotificationInfo getNotification(@JwtValidation Long userId,
@PathVariable Long notificationId) {
return notificationService.getNotification(userId, notificationId);
}

@DeleteMapping("/receive/{notificationId}")
@Operation(summary = "내가 받은 알림 삭제 API", description = "내가 받은 알림을 삭제하는 API 입니다.")
public StateResponse deleteNotification(@JwtValidation Long userId,
@PathVariable Long notificationId) {
return notificationService.deleteNotification(userId, notificationId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.back.catchmate.domain.notification.dto.NotificationResponse.NotificationInfo;
import com.back.catchmate.domain.notification.dto.NotificationResponse.PagedNotificationInfo;
import com.back.catchmate.global.dto.StateResponse;
import org.springframework.data.domain.Pageable;

public interface NotificationService {
Expand All @@ -10,4 +11,6 @@ public interface NotificationService {
PagedNotificationInfo getNotificationList(Long userId, Pageable pageable);

NotificationInfo getNotification(Long userId, Long notificationId);

StateResponse deleteNotification(Long userId, Long notificationId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.back.catchmate.domain.notification.repository.NotificationRepository;
import com.back.catchmate.domain.user.entity.User;
import com.back.catchmate.domain.user.repository.UserRepository;
import com.back.catchmate.global.dto.StateResponse;
import com.back.catchmate.global.error.ErrorCode;
import com.back.catchmate.global.error.exception.BaseException;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -64,4 +65,17 @@ public NotificationInfo getNotification(Long userId, Long notificationId) {

return notificationConverter.toNotificationInfo(notification, notification.getBoard());
}

@Override
@Transactional
public StateResponse deleteNotification(Long userId, Long notificationId) {
User user = userRepository.findById(userId)
.orElseThrow(() -> new BaseException(ErrorCode.USER_NOT_FOUND));

Notification notification = notificationRepository.findByIdAndUserId(notificationId, user.getId())
.orElseThrow(() -> new BaseException(ErrorCode.NOTIFICATION_NOT_FOUND));

notificationRepository.delete(notification);
return new StateResponse(true);
}
}
Loading