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,7 +1,9 @@
package com.howWeather.howWeather_backend.domain.ai_model.repository;

import com.howWeather.howWeather_backend.domain.ai_model.entity.ClothingRecommendation;
import jakarta.persistence.QueryHint;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.QueryHints;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -10,6 +12,7 @@

@Repository
public interface ClothingRecommendationRepository extends JpaRepository<ClothingRecommendation, Long> {
@QueryHints({ @QueryHint(name = "javax.persistence.cache.retrieveMode", value = "BYPASS") })
List<ClothingRecommendation> findByMemberIdAndDate(Long memberId, LocalDate date);

void deleteByDateBefore(LocalDate date);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ public List<RecommendPredictDto> getRecommendList(Member member) {
List<RecommendPredictDto> result = new ArrayList<>();
for (ClothingRecommendation recommendation : modelPredictList) {
RecommendPredictDto dto = makeResultForPredict(closet, recommendation, member);
if (dto.getUppersTypeList() != null && !dto.getUppersTypeList().isEmpty()) {

boolean isUppersExist = dto.getUppersTypeList() != null && !dto.getUppersTypeList().isEmpty();
boolean isFeelingExist = dto.getFeelingList() != null && !dto.getFeelingList().isEmpty();

if (isUppersExist && isFeelingExist) {
result.add(dto);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.howWeather.howWeather_backend.global.cipher.AESCipher;
import com.howWeather.howWeather_backend.global.exception.CustomException;
import com.howWeather.howWeather_backend.global.exception.ErrorCode;
import jakarta.persistence.EntityManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand All @@ -41,10 +42,10 @@
@Service
@RequiredArgsConstructor
public class MyAccountService {
private final EntityManager entityManager;
private final WeatherForecastRepository weatherForecastRepository;
private final MemberRepository memberRepository;
private final ClothingRecommendationRepository recommendationRepository;
private final RecommendationService recommendationService;
private final DailyCombinationScheduler dailyCombinationScheduler;
private final AiInternalService aiInternalService;
private final RestTemplate restTemplate;
Expand Down Expand Up @@ -320,6 +321,8 @@ public void saveRecommendationsInternal(Map<String, String> encryptedData, Strin
}

log.info("[추천 데이터 저장 완료] memberId={}", member.getId());
recommendationRepository.flush();
entityManager.clear();
} else {
List<ClothingRecommendation> existingData =
recommendationRepository.findByMemberIdAndDate(member.getId(), LocalDate.now());
Expand All @@ -339,8 +342,9 @@ public void saveRecommendationsInternal(Map<String, String> encryptedData, Strin
.build();

recommendationRepository.save(updatedEntity);
recommendationRepository.flush();
}
recommendationRepository.flush();
entityManager.clear();

log.info("[기존 데이터 지역명 업데이트 완료] memberId={}", member.getId());
}
Expand All @@ -352,6 +356,7 @@ public void saveRecommendationsInternal(Map<String, String> encryptedData, Strin
throw new CustomException(ErrorCode.UNKNOWN_ERROR, "지역명 업데이트 중 오류가 발생했습니다.");
}
}

private ClothingRecommendation convertToEntityWithBuilder(ModelRecommendationResult dto, Long memberId, String regionName) {
return ClothingRecommendation.builder()
.memberId(memberId)
Expand Down
Loading