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
Expand Up @@ -4,23 +4,16 @@
import OneQ.OnSurvey.domain.participation.entity.ScreeningAnswer;
import OneQ.OnSurvey.domain.participation.model.dto.AnswerInsertDto;
import OneQ.OnSurvey.domain.participation.model.dto.ParticipationCompletionDto;
import OneQ.OnSurvey.domain.participation.model.dto.ParticipationStatus;
import OneQ.OnSurvey.domain.participation.service.answer.AnswerCommand;
import OneQ.OnSurvey.domain.participation.service.response.ResponseCommand;
import OneQ.OnSurvey.domain.question.model.dto.type.DefaultQuestionDto;
import OneQ.OnSurvey.domain.question.service.QuestionQueryService;
import OneQ.OnSurvey.domain.survey.SurveyErrorCode;
import OneQ.OnSurvey.domain.survey.entity.Survey;
import OneQ.OnSurvey.domain.survey.model.SurveyStatus;
import OneQ.OnSurvey.domain.survey.model.request.InsertQuestionAnswerRequest;
import OneQ.OnSurvey.domain.survey.model.request.InsertScreeningAnswerRequest;
import OneQ.OnSurvey.domain.survey.model.request.SurveyParticipationCompletionRequest;
import OneQ.OnSurvey.domain.survey.model.response.*;
import OneQ.OnSurvey.domain.survey.repository.SurveyRepository;
import OneQ.OnSurvey.domain.survey.service.command.SurveyCommandService;
import OneQ.OnSurvey.domain.survey.service.query.SurveyQuery;
import OneQ.OnSurvey.global.auth.custom.CustomUserDetails;
import OneQ.OnSurvey.global.common.exception.CustomException;
import OneQ.OnSurvey.global.common.response.SuccessResponse;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
Expand All @@ -32,9 +25,6 @@
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/survey-participation")
Expand All @@ -47,9 +37,6 @@ public class ParticipationController {
private final ResponseCommand responseCommand;
private final SurveyCommandService surveyCommandService;

private final QuestionQueryService questionQueryService;
private final SurveyRepository surveyRepository;

@GetMapping("surveys/ongoing/all")
@Operation(summary = "열려있는 설문을 모두 조회합니다.")
public SuccessResponse<SurveyParticipationResponse> getOngoingSurveyList(
Expand All @@ -68,89 +55,6 @@ public SuccessResponse<SurveyParticipationResponse> getOngoingSurveyList(
return SuccessResponse.ok(results);
}

@Deprecated(forRemoval = true)
@GetMapping("surveys/ongoing")
@Operation(summary = "노출 중인 설문을 조회합니다.")
public SuccessResponse<SurveyParticipationResponse> getSurveyListOnGoing(
@AuthenticationPrincipal CustomUserDetails principal,
@RequestParam(required = false, defaultValue = "0") Long lastSurveyId,
@RequestParam(defaultValue = "15") Integer size
) {
log.info("[PARTICIPATION] 노출 중 설문 조회 - lastSurveyId: {}, size: {}", lastSurveyId, size);

Pageable recommendedPageable = PageRequest.of(0, size, Sort.by("id"));
Pageable impendingPageable = PageRequest.of(0, size, Sort.by(
Sort.Order.asc("deadline"),
Sort.Order.asc("id")
));

SurveyParticipationResponse.SliceSurveyData recommended = surveyQueryService.getParticipationSurveyList(
lastSurveyId, recommendedPageable, SurveyStatus.ONGOING, principal.getMemberId(), principal.getUserKey()
);
SurveyParticipationResponse.SliceSurveyData impending = surveyQueryService.getParticipationSurveyList(
lastSurveyId, LocalDateTime.now(), impendingPageable, SurveyStatus.ONGOING, principal.getMemberId(), principal.getUserKey()
);

SurveyParticipationResponse response = SurveyParticipationResponse.builder()
.recommended(recommended.getSurveyDataList())
.impending(impending.getSurveyDataList())
.recommendedHasNext(recommended.getHasNext())
.impendingHasNext(impending.getHasNext())
.build();

return SuccessResponse.ok(response);
}

@Deprecated(forRemoval = true)
@GetMapping("surveys/ongoing/recommended")
@Operation(summary = "사용자 추천 설문을 조회합니다.")
public SuccessResponse<SurveyParticipationResponse> getRecommendedSurveyList(
@AuthenticationPrincipal CustomUserDetails principal,
@RequestParam(required = false, defaultValue = "0") Long lastSurveyId,
@RequestParam(defaultValue = "15") Integer size
) {
log.info("[PARTICIPATION] 사용자 추천 설문 조회 - lastSurveyId: {}, size: {}", lastSurveyId, size);

Pageable pageable = PageRequest.of(0, size, Sort.by("id"));
SurveyParticipationResponse.SliceSurveyData recommended =
surveyQueryService.getParticipationSurveyList(lastSurveyId, pageable, SurveyStatus.ONGOING, principal.getMemberId(), principal.getUserKey()
);

SurveyParticipationResponse response = SurveyParticipationResponse.builder()
.recommended(recommended.getSurveyDataList())
.recommendedHasNext(recommended.getHasNext())
.build();

return SuccessResponse.ok(response);
}

@Deprecated(forRemoval = true)
@GetMapping("surveys/ongoing/impending")
@Operation(summary = "마감 임박 설문을 조회합니다.")
public SuccessResponse<SurveyParticipationResponse> getImpendingSurveyList(
@AuthenticationPrincipal CustomUserDetails principal,
@RequestParam(required = false, defaultValue = "0") Long lastSurveyId,
@RequestParam(required = false) LocalDateTime lastDeadline,
@RequestParam(defaultValue = "15") Integer size
) {
log.info("[PARTICIPATION] 마감 임박 설문 조회 - lastSurveyId: {}, lastDeadline: {}, size: {}", lastSurveyId, lastDeadline, size);

Pageable pageable = PageRequest.of(0, size, Sort.by(
Sort.Order.asc("deadline"),
Sort.Order.asc("id")
));
SurveyParticipationResponse.SliceSurveyData impending =
surveyQueryService.getParticipationSurveyList(lastSurveyId, lastDeadline, pageable, SurveyStatus.ONGOING, principal.getMemberId(), principal.getUserKey()
);

SurveyParticipationResponse response = SurveyParticipationResponse.builder()
.impending(impending.getSurveyDataList())
.impendingHasNext(impending.getHasNext())
.build();

return SuccessResponse.ok(response);
}

@GetMapping("surveys/info")
@Operation(summary = "선택한 설문의 기본 정보를 조회합니다.")
public SuccessResponse<ParticipationInfoResponse> getSurveyInfo(
Expand All @@ -174,36 +78,6 @@ public SuccessResponse<ParticipationQuestionResponse> getQuestionsOfSurveyId(
return SuccessResponse.ok(surveyQueryService.getParticipationQuestionInfo(surveyId, section, principal.getUserKey()));
}

/**
* @deprecated
* @code GET /surveys/info
* @code GET /surveys/questions
*/
@Deprecated(forRemoval = true)
@GetMapping("surveys")
@Operation(summary = "선택한 설문을 조회합니다.")
public SuccessResponse<DeprecatedQuestionResponse> getTotalSurveyInfoOfSurveyId(
@RequestParam Long surveyId,
@AuthenticationPrincipal CustomUserDetails principal
) {
log.info("[PARTICIPATION] 응답하고자 하는 설문 문항조회 - surveyId: {}", surveyId);

Survey survey = surveyQueryService.getSurveyById(surveyId);

if (surveyQueryService.checkValidSegmentation(surveyId, principal.getUserKey())) {
log.warn("[PARTICIPATION] 세그먼트 불일치로 인한 설문 응답 불가 - surveyId: {}, userKey: {}", surveyId, principal.getUserKey());
throw new CustomException(SurveyErrorCode.SURVEY_WRONG_SEGMENTATION);
}

List<DefaultQuestionDto> questionDtoList = questionQueryService.getQuestionDtoListBySurveyId(surveyId);
ParticipationStatus participationStatus = surveyRepository.getParticipationStatus(surveyId, principal.getMemberId());

DeprecatedQuestionResponse body =
DeprecatedQuestionResponse.of(survey, questionDtoList, participationStatus);

return SuccessResponse.ok(body);
}

@GetMapping("surveys/screenings")
@Operation(summary = "세그멘테이션에 일치하는 설문의 스크리닝 문항을 조회합니다.")
public SuccessResponse<ParticipationScreeningListResponse> getRecommendedScreenings(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package OneQ.OnSurvey.domain.survey.model.dto;

import OneQ.OnSurvey.domain.member.value.Interest;
import OneQ.OnSurvey.domain.participation.model.dto.ParticipationStatus;

import java.time.LocalDateTime;
import java.util.Set;

public record ParticipationInfoVO(
Long surveyId,
String title,
String description,
Integer totalSections,
LocalDateTime deadline,
Set<Interest> interests,
ParticipationStatus participationStatus,
Boolean isFree
) {
public ParticipationInfoVO(
Long surveyId,
String title,
String description,
Integer totalSections,
LocalDateTime deadline,
Set<Interest> interests,
Long screeningId,
Boolean eIsScreened,
Boolean eIsResponded,
Boolean isFree
) {
this(
surveyId, title, description, totalSections, deadline, interests,
ParticipationStatus.generateStatus(screeningId, eIsScreened, eIsResponded),
isFree
);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package OneQ.OnSurvey.domain.survey.model.response;

import OneQ.OnSurvey.domain.member.value.Interest;
import OneQ.OnSurvey.domain.participation.model.dto.ParticipationStatus;
import OneQ.OnSurvey.domain.survey.entity.Survey;
import OneQ.OnSurvey.domain.survey.model.dto.ParticipationInfoVO;

import java.time.LocalDateTime;
import java.util.Set;
Expand All @@ -11,6 +10,7 @@ public record ParticipationInfoResponse(
Long surveyId,
String title,
String description,
Integer totalSections,
LocalDateTime deadline,
Set<Interest> interests,
Integer responseCount,
Expand All @@ -20,19 +20,12 @@ public record ParticipationInfoResponse(
Boolean isFree
) {
public static ParticipationInfoResponse from(
Survey survey, int responseCount, ParticipationStatus participationStatus
ParticipationInfoVO vo, int responseCount
) {
return new ParticipationInfoResponse(
survey.getId(),
survey.getTitle(),
survey.getDescription(),
survey.getDeadline(),
survey.getInterests(),
responseCount,
participationStatus.isScreenRequired(),
participationStatus.isScreened(),
participationStatus.isSurveyResponded(),
survey.getIsFree()
vo.surveyId(), vo.title(), vo.description(), vo.totalSections(), vo.deadline(), vo.interests(), responseCount,
vo.participationStatus().isScreenRequired(), vo.participationStatus().isScreened(), vo.participationStatus().isSurveyResponded(),
vo.isFree()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package OneQ.OnSurvey.domain.survey.repository;

import OneQ.OnSurvey.domain.member.dto.MemberSegmentation;
import OneQ.OnSurvey.domain.participation.model.dto.ParticipationStatus;
import OneQ.OnSurvey.domain.survey.entity.Survey;
import OneQ.OnSurvey.domain.survey.model.SurveyStatus;
import OneQ.OnSurvey.domain.survey.model.dto.OngoingSurveyStats;
import OneQ.OnSurvey.domain.survey.model.dto.OpenSurveyStats;
import OneQ.OnSurvey.domain.survey.model.dto.SurveyDetailData;
import OneQ.OnSurvey.domain.survey.model.dto.ParticipationInfoVO;
import OneQ.OnSurvey.domain.survey.model.dto.SurveyListView;
import OneQ.OnSurvey.domain.survey.model.dto.SurveySearchQuery;
import OneQ.OnSurvey.domain.survey.model.dto.SurveyWithEligibility;
Expand All @@ -30,13 +30,10 @@ List<Long> getSurveyIdListByFilters(
Slice<SurveyWithEligibility> getSurveyListWithEligibility(
Long lastSurveyId, LocalDateTime lastDeadline, Pageable pageable,
SurveyStatus status, Long creatorId, Collection<Long> excludedIds, MemberSegmentation memberSegmentation);

Survey save(Survey survey);

SurveyStatus getSurveyStatusById(Long surveyId);
ParticipationStatus getParticipationStatus(Long surveyId, Long memberId);
List<Long> closeDueSurveys();

List<OngoingSurveyStats> findOngoingSurveys();
OpenSurveyStats findOpenSurveyStats();
ParticipationInfoVO getParticipationInfoVO(Long surveyId, Long memberId);
}
Loading
Loading