Skip to content

Commit

Permalink
hotfix: 트랜젝션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
0703kyj committed Jan 7, 2025
1 parent ddae61f commit 61fda87
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import com.uket.domain.user.entity.Users;
import com.uket.domain.user.exception.UserException;
import com.uket.domain.user.repository.UserRepository;
import jakarta.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
Expand All @@ -33,15 +33,18 @@ public class FormService {
private final FormRepository formRepository;
private final OptionsRepository optionsRepository;

@Transactional(readOnly = true)
public Survey findById(Long surveyId) {
return surveyRepository.findById(surveyId)
.orElseThrow(() -> new FormException(ErrorCode.NOT_FOUND_SURVEY));
}

@Transactional(readOnly = true)
public List<Form> findFormsBySurveyId(Long surveyId) {
return formRepository.findBySurveyId(surveyId);
}

@Transactional(readOnly = true)
public AnswerDto findAnswerByFormIdAndUserId(Long formId, Long userId, boolean isNecessary) {
Answer answer = answerRepository.findAnswerByFormIdAndUserId(formId, userId);
/*
Expand Down Expand Up @@ -69,6 +72,7 @@ public AnswerDto findAnswerByFormIdAndUserId(Long formId, Long userId, boolean i
return AnswerDto.from(answer);
}

@Transactional(readOnly = true)
public List<OptionDto> findOptionsByFormId(Long formId) {
List<OptionDto> optionDtos = new ArrayList<>();
List<Options> options = optionsRepository.findByFormId(formId);
Expand Down

0 comments on commit 61fda87

Please sign in to comment.