diff --git a/src/main/java/OneQ/OnSurvey/domain/admin/api/AdminController.java b/src/main/java/OneQ/OnSurvey/domain/admin/api/AdminController.java index 9ccf251b..eb928821 100644 --- a/src/main/java/OneQ/OnSurvey/domain/admin/api/AdminController.java +++ b/src/main/java/OneQ/OnSurvey/domain/admin/api/AdminController.java @@ -111,9 +111,9 @@ public SuccessResponse changeSurveyOwner( @PathVariable Long surveyId, @RequestBody ChangeSurveyOwnerRequest request ) { - log.info("[ADMIN] 설문 소유자 변경 요청 - surveyId: {}, newMemberId: {}", surveyId, request.newMemberId()); + log.info("[ADMIN] 설문 소유자 변경 요청 - surveyId: {}, memberId: {}, userKey: {}", surveyId, request.newMemberId(), request.newUserKey()); - adminFacade.changeSurveyOwner(surveyId, request.newMemberId()); + adminFacade.changeSurveyOwner(surveyId, request.newMemberId(), request.newUserKey()); return SuccessResponse.ok("설문 소유자가 변경되었습니다."); } diff --git a/src/main/java/OneQ/OnSurvey/domain/admin/api/dto/response/AdminSurveyDetailResponse.java b/src/main/java/OneQ/OnSurvey/domain/admin/api/dto/response/AdminSurveyDetailResponse.java index 744f8528..61de6b2b 100644 --- a/src/main/java/OneQ/OnSurvey/domain/admin/api/dto/response/AdminSurveyDetailResponse.java +++ b/src/main/java/OneQ/OnSurvey/domain/admin/api/dto/response/AdminSurveyDetailResponse.java @@ -76,7 +76,9 @@ public record QuestionDto( String imageUrl, ChoicePropDto choiceProperty, RatingPropDto ratingProperty, - DatePropDto dateProperty + DatePropDto dateProperty, + GridPropDto gridProperty, + TimePropDto timeProperty ) { public static QuestionDto from(SurveyQuestion vo) { if (vo == null) return null; @@ -91,7 +93,9 @@ public static QuestionDto from(SurveyQuestion vo) { vo.imageUrl(), ChoicePropDto.from(vo.choiceProperty()), RatingPropDto.from(vo.ratingProperty()), - DatePropDto.from(vo.dateProperty()) + DatePropDto.from(vo.dateProperty()), + GridPropDto.from(vo.gridProperty()), + TimePropDto.from(vo.timeProperty()) ); } @@ -110,10 +114,10 @@ public static ChoicePropDto from(SurveyQuestion.ChoiceProp vo) { return new ChoicePropDto(vo.maxChoice(), vo.hasCustomInput(), vo.hasNoneOption(), vo.isSectionDecidable(), optionDtos); } - public record OptionDto(String content, Integer nextSection, String imageUrl) { + public record OptionDto(Long optionId, String content, Integer nextSection, String imageUrl) { public static OptionDto from(SurveyQuestion.ChoiceProp.Option vo) { if (vo == null) return null; - return new OptionDto(vo.content(), vo.nextSection(), vo.imageUrl()); + return new OptionDto(vo.optionId(), vo.content(), vo.nextSection(), vo.imageUrl()); } } } @@ -131,6 +135,35 @@ public static DatePropDto from(SurveyQuestion.DateProp vo) { return new DatePropDto(vo.defaultDate()); } } + + public record TimePropDto(Boolean isInterval) { + public static TimePropDto from(SurveyQuestion.TimeProp vo) { + if (vo == null) return null; + return new TimePropDto(vo.isInterval()); + } + } + + public record GridPropDto( + Boolean isCheckbox, + Boolean isChoiceMixed, + Boolean isChoiceDistinct, + Set gridOptions + ) { + public static GridPropDto from(SurveyQuestion.GridProp vo) { + if (vo == null) return null; + Set optionDtos = vo.gridOptions() != null + ? vo.gridOptions().stream().map(GridOptionDto::from).collect(Collectors.toSet()) + : Set.of(); + return new GridPropDto(vo.isCheckbox(), vo.isChoiceMixed(), vo.isChoiceDistinct(), optionDtos); + } + + public record GridOptionDto(Long gridOptionId, Boolean isRow, String content, Integer order) { + public static GridOptionDto from(SurveyQuestion.GridProp.GridOption vo) { + if (vo == null) return null; + return new GridOptionDto(vo.gridOptionId(), vo.isRow(), vo.content(), vo.order()); + } + } + } } public record ScreeningDto( diff --git a/src/main/java/OneQ/OnSurvey/domain/admin/application/AdminAuthService.java b/src/main/java/OneQ/OnSurvey/domain/admin/application/AdminAuthService.java deleted file mode 100644 index 53316647..00000000 --- a/src/main/java/OneQ/OnSurvey/domain/admin/application/AdminAuthService.java +++ /dev/null @@ -1,54 +0,0 @@ -package OneQ.OnSurvey.domain.admin.application; - -import OneQ.OnSurvey.domain.admin.domain.model.Admin; -import OneQ.OnSurvey.domain.admin.domain.model.AdminRole; -import OneQ.OnSurvey.domain.admin.domain.port.out.MemberPort; -import OneQ.OnSurvey.domain.admin.domain.repository.AdminRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@RequiredArgsConstructor -@Transactional(readOnly = true) -public class AdminAuthService { - - private final AdminRepository adminRepository; - private final MemberPort memberPort; - private final PasswordEncoder passwordEncoder; - - public String authenticate(String username, String rawPassword) { - - Admin admin = adminRepository.findByUsername(username); - if (admin == null || !admin.matchPassword(passwordEncoder, rawPassword)) { - return null; - } - - return admin.getAdminId(); - - } - - @Transactional - public boolean register(Long userKey, String username, String password, String name) { - Admin existingAdmin = adminRepository.findByUsername(username); - Long memberId = memberPort.validateAdminRoleAndGetMemberIdByUserKey(userKey); - if (existingAdmin != null || memberId == null) { - return false; - } - - String encodedPassword = passwordEncoder.encode(password); - - Admin newAdmin = Admin.builder() - .memberId(memberId) - .userKey(userKey) - .username(username) - .password(encodedPassword) - .name(name) - .role(AdminRole.ROLE_ADMIN) - .build(); - - adminRepository.save(newAdmin); - return true; - } -} diff --git a/src/main/java/OneQ/OnSurvey/domain/admin/application/AdminFacade.java b/src/main/java/OneQ/OnSurvey/domain/admin/application/AdminFacade.java index 69259d37..17d0ee85 100644 --- a/src/main/java/OneQ/OnSurvey/domain/admin/application/AdminFacade.java +++ b/src/main/java/OneQ/OnSurvey/domain/admin/application/AdminFacade.java @@ -99,8 +99,8 @@ public AdminSurveyDetailResponse getSurveyDetail(Long surveyId) { @Override @Transactional - public void changeSurveyOwner(Long surveyId, Long memberId) { - surveyPort.updateSurveyOwner(surveyId, memberId); + public void changeSurveyOwner(Long surveyId, Long memberId, Long userKey) { + surveyPort.updateSurveyOwner(surveyId, memberId, userKey); } @Override diff --git a/src/main/java/OneQ/OnSurvey/domain/admin/domain/model/survey/SurveyQuestion.java b/src/main/java/OneQ/OnSurvey/domain/admin/domain/model/survey/SurveyQuestion.java index 2d0cbc75..0d8408d5 100644 --- a/src/main/java/OneQ/OnSurvey/domain/admin/domain/model/survey/SurveyQuestion.java +++ b/src/main/java/OneQ/OnSurvey/domain/admin/domain/model/survey/SurveyQuestion.java @@ -18,7 +18,9 @@ public record SurveyQuestion( ChoiceProp choiceProperty, RatingProp ratingProperty, - DateProp dateProperty + DateProp dateProperty, + GridProp gridProperty, + TimeProp timeProperty ) { public record ChoiceProp ( Integer maxChoice, @@ -29,6 +31,7 @@ public record ChoiceProp ( Set