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
@@ -1,18 +1,18 @@
package com.tryna.domain.alarm.controller;

import com.tryna.domain.alarm.controller.docs.AlarmControllerDocs;
import com.tryna.domain.alarm.dto.ActionItemReminderResponse;
import com.tryna.domain.alarm.dto.AlarmCorrectionResponse;
import com.tryna.domain.alarm.dto.AlarmDetailResponse;
import com.tryna.domain.alarm.dto.AlarmListResponse;
import com.tryna.domain.alarm.dto.AlarmPushTokenRequest;
import com.tryna.domain.alarm.dto.AlarmStateResponse;
import com.tryna.domain.alarm.dto.EventReminderResponse;
import com.tryna.domain.alarm.service.AlarmPushTokenService;
import com.tryna.domain.alarm.service.AlarmQueryService;
import com.tryna.domain.alarm.service.AlarmStateService;
import com.tryna.domain.alarm.service.AlarmTermService;
package com.tryna.domain.reminder.controller;

import com.tryna.domain.reminder.controller.docs.AlarmControllerDocs;
import com.tryna.domain.reminder.dto.ActionItemReminderResponse;
import com.tryna.domain.reminder.dto.AlarmCorrectionResponse;
import com.tryna.domain.reminder.dto.AlarmDetailResponse;
import com.tryna.domain.reminder.dto.AlarmListResponse;
import com.tryna.domain.reminder.dto.AlarmPushTokenRequest;
import com.tryna.domain.reminder.dto.AlarmStateResponse;
import com.tryna.domain.reminder.dto.EventReminderResponse;
import com.tryna.domain.reminder.service.AlarmPushTokenService;
import com.tryna.domain.reminder.service.AlarmQueryService;
import com.tryna.domain.reminder.service.AlarmReminderScheduleService;
import com.tryna.domain.reminder.service.AlarmStateService;
import com.tryna.domain.reminder.service.AlarmTermService;
import com.tryna.global.exception.AuthErrorCode;
import com.tryna.global.exception.BusinessException;
import com.tryna.global.response.ApiResponse;
Expand Down Expand Up @@ -45,10 +45,16 @@ public class AlarmController implements AlarmControllerDocs {
@PostMapping("/term")
@Override
public ResponseEntity<ApiResponse<Void>> agreeAlarmTerm() {
alarmTermService.agreeAlarmTerm(resolveOptionalUserId());
boolean newlyAgreed = alarmTermService.agreeAlarmTerm(resolveOptionalUserId());

if (newlyAgreed) {
return ResponseEntity.ok(
ApiResponse.success("F100_ALARM_TERM_200", "알람 약관 동의에 성공했습니다.", null)
);
}

return ResponseEntity.ok(
ApiResponse.success("F100_ALARM_TERM_200", "알람 약관 동의에 성공했습니다.", null)
ApiResponse.success("F100_ALARM_TERM_200", "이미 알람 약관에 동의되어 있습니다.", null)
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.tryna.domain.alarm.controller.docs;
package com.tryna.domain.reminder.controller.docs;

import com.tryna.domain.alarm.dto.ActionItemReminderResponse;
import com.tryna.domain.alarm.dto.AlarmCorrectionResponse;
import com.tryna.domain.alarm.dto.AlarmDetailResponse;
import com.tryna.domain.alarm.dto.AlarmListResponse;
import com.tryna.domain.alarm.dto.AlarmPushTokenRequest;
import com.tryna.domain.alarm.dto.AlarmStateResponse;
import com.tryna.domain.alarm.dto.EventReminderResponse;
import com.tryna.domain.reminder.dto.ActionItemReminderResponse;
import com.tryna.domain.reminder.dto.AlarmCorrectionResponse;
import com.tryna.domain.reminder.dto.AlarmDetailResponse;
import com.tryna.domain.reminder.dto.AlarmListResponse;
import com.tryna.domain.reminder.dto.AlarmPushTokenRequest;
import com.tryna.domain.reminder.dto.AlarmStateResponse;
import com.tryna.domain.reminder.dto.EventReminderResponse;
import com.tryna.global.response.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand All @@ -27,6 +27,7 @@ public interface AlarmControllerDocs {
description = """
ALARM 약관에 동의하고 사용자의 알람 발송 상태(alarm_state)를 활성화합니다.
terms 테이블의 ALARM 약관에 대한 user_agreed_terms 이력을 생성합니다.
이미 동의한 사용자가 재요청하면 200과 함께 이미 동의되어 있다는 메시지를 반환합니다.
""",
operationId = "agreeAlarmTerm"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tryna.domain.alarm.dto;
package com.tryna.domain.reminder.dto;

import com.tryna.domain.reminder.entity.Reminders;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tryna.domain.alarm.dto;
package com.tryna.domain.reminder.dto;

import com.tryna.domain.reminder.entity.Reminders;
import com.tryna.domain.reminder.enums.TargetType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tryna.domain.alarm.dto;
package com.tryna.domain.reminder.dto;

import com.tryna.domain.reminder.entity.Reminders;
import com.tryna.domain.reminder.enums.TargetType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tryna.domain.alarm.dto;
package com.tryna.domain.reminder.dto;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tryna.domain.alarm.dto;
package com.tryna.domain.reminder.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tryna.domain.alarm.dto;
package com.tryna.domain.reminder.dto;

public record AlarmStateResponse(
boolean alarmState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tryna.domain.alarm.dto;
package com.tryna.domain.reminder.dto;

import com.tryna.domain.reminder.entity.Reminders;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tryna.domain.alarm.service;
package com.tryna.domain.reminder.service;

import com.tryna.domain.auth.repository.FcmTokenRedisRepository;
import com.tryna.global.exception.AlarmErrorCode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.tryna.domain.alarm.service;
package com.tryna.domain.reminder.service;

import com.tryna.domain.alarm.dto.AlarmDetailResponse;
import com.tryna.domain.alarm.dto.AlarmListResponse;
import com.tryna.domain.alarm.util.AlarmCursorCodec;
import com.tryna.domain.reminder.dto.AlarmDetailResponse;
import com.tryna.domain.reminder.dto.AlarmListResponse;
import com.tryna.domain.reminder.entity.Reminders;
import com.tryna.domain.reminder.repository.RemindersRepository;
import com.tryna.domain.reminder.util.AlarmCursorCodec;
import com.tryna.domain.user.entity.Users;
import com.tryna.domain.user.repository.UserRepository;
import com.tryna.global.exception.AlarmErrorCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.tryna.domain.action.entity.ActionItems;
import com.tryna.domain.action.repository.ActionItemOccurrenceStatesRepository;
import com.tryna.domain.alarm.service.FcmPushService;
import com.tryna.domain.reminder.service.FcmPushService;
import com.tryna.domain.auth.repository.FcmTokenRedisRepository;
import com.tryna.domain.event.entity.Events;
import com.tryna.domain.event.util.EventRecurrenceCalculator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.tryna.domain.action.entity.ActionItems;
import com.tryna.domain.action.enums.ItemType;
import com.tryna.domain.action.repository.ActionItemsRepository;
import com.tryna.domain.alarm.dto.ActionItemReminderResponse;
import com.tryna.domain.alarm.dto.AlarmCorrectionResponse;
import com.tryna.domain.alarm.dto.EventReminderResponse;
import com.tryna.domain.reminder.dto.ActionItemReminderResponse;
import com.tryna.domain.reminder.dto.AlarmCorrectionResponse;
import com.tryna.domain.reminder.dto.EventReminderResponse;
import com.tryna.domain.auth.repository.FcmTokenRedisRepository;
import com.tryna.domain.event.entity.Events;
import com.tryna.domain.event.repository.EventsRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.tryna.domain.alarm.service;
package com.tryna.domain.reminder.service;

import com.tryna.domain.alarm.dto.AlarmStateResponse;
import com.tryna.domain.reminder.dto.AlarmStateResponse;
import com.tryna.domain.term.entity.Terms;
import com.tryna.domain.term.enums.TermType;
import com.tryna.domain.term.repository.TermsRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tryna.domain.alarm.service;
package com.tryna.domain.reminder.service;

import com.tryna.domain.term.entity.Terms;
import com.tryna.domain.term.entity.mapping.UserAgreedTerms;
Expand Down Expand Up @@ -29,7 +29,7 @@ public class AlarmTermService {
* ALARM 약관 동의 이력을 저장하고 사용자의 alarm_state를 true로 변경합니다.
*/
@Transactional
public void agreeAlarmTerm(Long userId) {
public boolean agreeAlarmTerm(Long userId) {
Users user = userRepository.findByUserIdAndDeletedAtIsNull(userId)
.orElseThrow(() -> new BusinessException(AuthErrorCode.AUTH_401));

Expand All @@ -38,10 +38,11 @@ public void agreeAlarmTerm(Long userId) {
.orElseThrow(() -> new BusinessException(AlarmErrorCode.F100_ALARM_TERM_400));

if (userAgreedTermsRepository.existsByUser_UserIdAndTerm_TermId(userId, alarmTerm.getTermId())) {
throw new BusinessException(AlarmErrorCode.F100_ALARM_TERM_400);
return false;
}

userAgreedTermsRepository.save(UserAgreedTerms.create(user, alarmTerm));
user.updateAlarmState(true);
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tryna.domain.alarm.service;
package com.tryna.domain.reminder.service;

import com.google.firebase.FirebaseApp;
import com.google.firebase.messaging.BatchResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tryna.domain.alarm.util;
package com.tryna.domain.reminder.util;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down
Loading