Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 환율 컬럼명 변경 #155

Merged
merged 1 commit into from
Jun 10, 2024
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,5 +1,6 @@
package com.hanaro.triptogether.exchangeRate.domain.entity;

import com.hanaro.triptogether.exchangeRate.dto.request.ExchangeRateResponse;
import com.hanaro.triptogether.member.domain.Member;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -52,6 +53,15 @@ public class ExchangeRate {
@JoinColumn(name = "deleted_by", insertable=false, updatable=false)
private Member deletedBy;

public ExchangeRateResponse toDto(String cur_icon) {
return ExchangeRateResponse.builder()
.cur_code(curCode)
.cur_name(curName)
.cur_icon(cur_icon)
.cur_rate(String.valueOf(curRate))
.build();
}

@PrePersist
protected void onCreate() {
LocalDateTime now = LocalDateTime.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
@Getter
@Setter
public class ExchangeRateResponse {
private String cur_unit; // 통화코드
private String cur_name; //국가 이름
private String cur_code;
private String cur_name;
private String cur_icon;
private String deal_bas_r; // 매매 기준율
private String cur_rate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ public class ExchangeDto {
private String kftc_deal_bas_r; // 서울외국환중개장부가격


public ExchangeRateResponse toDto(String cur_icon) {
return ExchangeRateResponse.builder()
.cur_unit(cur_unit)
.cur_name(cur_nm)
.cur_icon(cur_icon)
.deal_bas_r(deal_bas_r)
.build();
}

public ExchangeRate saveExchangeRate() {
return ExchangeRate.builder()
.curRate(BigDecimalConverter.convertStringToBigDecimal(deal_bas_r))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
import com.hanaro.triptogether.exchangeRate.domain.entity.ExchangeRateAlarm;
import com.hanaro.triptogether.exchangeRate.domain.repository.ExchangeRateAlarmRepository;
import com.hanaro.triptogether.exchangeRate.domain.repository.ExchangeRateRepository;
import com.hanaro.triptogether.exchangeRate.dto.response.ExchangeDto;
import com.hanaro.triptogether.exchangeRate.dto.request.ExchangeRateAlarmRequestDto;
import com.hanaro.triptogether.exchangeRate.dto.request.ExchangeRateInfoResponseDto;
import com.hanaro.triptogether.exchangeRate.dto.request.ExchangeRateResponse;
import com.hanaro.triptogether.exchangeRate.dto.request.FcmSendDto;
import com.hanaro.triptogether.exchangeRate.dto.response.ExchangeRateAlarmResponseDto;
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 lombok.RequiredArgsConstructor;
Expand All @@ -36,19 +34,18 @@ public class ExchangeService {
private final MemberRepository memberRepository;
private final ExchangeRateRepository exchangeRateRepository;

private final ExchangeUtils exchangeUtils;
private final FirebaseFCMService firebaseFCMService;

public ExchangeRateInfoResponseDto getExchangeRate(){

List<ExchangeDto> exchangeDtoList = exchangeUtils.getExchangeDataAsDtoList();
List<ExchangeRateResponse> exchangeRateResponseDtos = new ArrayList<>();
for(ExchangeDto exchangeDto: exchangeDtoList){
ExchangeRate exchangeRate = exchangeRateRepository.findExchangeRateByCurCode(exchangeDto.getCur_unit());
exchangeRateResponseDtos.add(exchangeDto.toDto(exchangeRate.getCurIcon()));
List<ExchangeRate> exchangeRateDtoList = exchangeRateRepository.findAll();
List<ExchangeRateResponse> exchangeRateResponses = new ArrayList<>();
for(ExchangeRate exchangeDto: exchangeRateDtoList){
ExchangeRate exchangeRate = exchangeRateRepository.findExchangeRateByCurCode(exchangeDto.getCurCode());
exchangeRateResponses.add(exchangeDto.toDto(exchangeRate.getCurIcon()));

}
return ExchangeRateInfoResponseDto.builder().exchangeRateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))).exchangeRates(exchangeRateResponseDtos).build();
return ExchangeRateInfoResponseDto.builder().exchangeRateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))).exchangeRates(exchangeRateResponses).build();
}

public List<ExchangeRateAlarmResponseDto> getExchangeRateAlarmList(Long memberIdx) {
Expand Down
Loading