diff --git a/src/main/java/com/hanaro/triptogether/exchangeRate/domain/entity/ExchangeRateAlarm.java b/src/main/java/com/hanaro/triptogether/exchangeRate/domain/entity/ExchangeRateAlarm.java index 33e695c..90eb2b3 100644 --- a/src/main/java/com/hanaro/triptogether/exchangeRate/domain/entity/ExchangeRateAlarm.java +++ b/src/main/java/com/hanaro/triptogether/exchangeRate/domain/entity/ExchangeRateAlarm.java @@ -1,6 +1,7 @@ package com.hanaro.triptogether.exchangeRate.domain.entity; import com.hanaro.triptogether.dues.domain.entity.BaseEntity; import com.hanaro.triptogether.enumeration.ExchangeRateAlarmType; +import com.hanaro.triptogether.member.domain.Member; import com.hanaro.triptogether.team.domain.Team; import jakarta.persistence.*; import lombok.AllArgsConstructor; @@ -17,19 +18,20 @@ @NoArgsConstructor @AllArgsConstructor public class ExchangeRateAlarm extends BaseEntity { + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "alarm_idx") + @Column(name = "exchange_rate_alarm_idx") private Long alarmIdx; - @ManyToOne - @JoinColumn(name = "team_idx", nullable = false) - private Team team; - @ManyToOne @JoinColumn(name = "cur_idx", nullable = false) private ExchangeRate exchangeRate; + @ManyToOne + @JoinColumn(name = "member_idx", nullable = false) + private Member member; + @Column(name = "cur_Code", nullable = false) private String curCode; diff --git a/src/main/java/com/hanaro/triptogether/exchangeRate/dto/request/ExchangeRateAlarmRequestDto.java b/src/main/java/com/hanaro/triptogether/exchangeRate/dto/request/ExchangeRateAlarmRequestDto.java index 14ebb25..608d297 100644 --- a/src/main/java/com/hanaro/triptogether/exchangeRate/dto/request/ExchangeRateAlarmRequestDto.java +++ b/src/main/java/com/hanaro/triptogether/exchangeRate/dto/request/ExchangeRateAlarmRequestDto.java @@ -4,6 +4,7 @@ import com.hanaro.triptogether.enumeration.ExchangeRateAlarmType; import com.hanaro.triptogether.exchangeRate.domain.entity.ExchangeRate; import com.hanaro.triptogether.exchangeRate.domain.entity.ExchangeRateAlarm; +import com.hanaro.triptogether.member.domain.Member; import com.hanaro.triptogether.team.domain.Team; import lombok.Getter; import lombok.Setter; @@ -16,15 +17,15 @@ @ToString public class ExchangeRateAlarmRequestDto { - private Long teamIdx; + private Long memberIdx; private String curCode; private String curRate; private ExchangeRateAlarmType rateAlarmType; private String fcmToken; - public ExchangeRateAlarm toEntity(Team team, ExchangeRate exchangeRate) { + public ExchangeRateAlarm toEntity(Member member, ExchangeRate exchangeRate) { return ExchangeRateAlarm.builder() - .team(team) + .member(member) .fcmToken(fcmToken) .exchangeRate(exchangeRate) .rateType(rateAlarmType) diff --git a/src/main/java/com/hanaro/triptogether/exchangeRate/service/ExchangeService.java b/src/main/java/com/hanaro/triptogether/exchangeRate/service/ExchangeService.java index 471cbb5..28e56a2 100644 --- a/src/main/java/com/hanaro/triptogether/exchangeRate/service/ExchangeService.java +++ b/src/main/java/com/hanaro/triptogether/exchangeRate/service/ExchangeService.java @@ -14,6 +14,8 @@ import com.hanaro.triptogether.exchangeRate.dto.request.FcmSendDto; import com.hanaro.triptogether.exchangeRate.exception.EntityNotFoundException; import com.hanaro.triptogether.exchangeRate.utils.ExchangeUtils; +import com.hanaro.triptogether.member.domain.Member; +import com.hanaro.triptogether.member.domain.MemberRepository; import com.hanaro.triptogether.team.domain.Team; import com.hanaro.triptogether.team.domain.TeamRepository; import lombok.RequiredArgsConstructor; @@ -33,6 +35,7 @@ public class ExchangeService { private final ExchangeRateAlarmRepository exchangeRateAlarmRepository; private final TeamRepository teamRepository; + private final MemberRepository memberRepository; private final ExchangeRateRepository exchangeRateRepository; private final ExchangeUtils exchangeUtils; @@ -66,9 +69,9 @@ public void saveExchangeRate(String curCode, String curRate,String curName) { @Transactional public void setExchangeRateAlarm(ExchangeRateAlarmRequestDto requestDto){ - Team team = teamRepository.findById(requestDto.getTeamIdx()).orElseThrow(EntityNotFoundException::new); + Member member = memberRepository.findById(requestDto.getMemberIdx()).orElseThrow(EntityNotFoundException::new); ExchangeRate exchangeRate = exchangeRateRepository.findExchangeRateByCurCd(requestDto.getCurCode()); - exchangeRateAlarmRepository.save(requestDto.toEntity(team,exchangeRate)); + exchangeRateAlarmRepository.save(requestDto.toEntity(member,exchangeRate)); } @Transactional @@ -100,7 +103,6 @@ public void checkNotifyAlarms() throws IOException { } - System.out.println("ssssaaaa"+alarms.size()); } @Transactional