-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from CodingWasabi/feature-35/survey
🔥[FEAT]-#35- 비회원 성향 검사 구현
- Loading branch information
Showing
13 changed files
with
113 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/codingwasabi/trti/util/annonymous/AnonymousController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.codingwasabi.trti.util.annonymous; | ||
|
||
import com.codingwasabi.trti.util.annonymous.dto.ResponseAnonymousResultDto; | ||
import com.codingwasabi.trti.util.survey.dto.RequestSurveyDto; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/anonymous") | ||
public class AnonymousController { | ||
private final AnonymousService anonymousService; | ||
|
||
@PostMapping("/survey") | ||
public ResponseEntity<ResponseAnonymousResultDto> submitSurvey(@RequestBody RequestSurveyDto requestSurveyDto) { | ||
return ResponseEntity.ok(anonymousService.submitSurvey(requestSurveyDto)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/codingwasabi/trti/util/annonymous/AnonymousService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.codingwasabi.trti.util.annonymous; | ||
|
||
import com.codingwasabi.trti.domain.result.model.Result; | ||
import com.codingwasabi.trti.util.annonymous.dto.ResponseAnonymousResultDto; | ||
import com.codingwasabi.trti.util.survey.dto.RequestSurveyDto; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
public class AnonymousService { | ||
|
||
@Transactional | ||
public ResponseAnonymousResultDto submitSurvey(RequestSurveyDto requestSurveyDto) { | ||
return ResponseAnonymousResultDto.from(Result.from(requestSurveyDto.getAnswers())); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/codingwasabi/trti/util/annonymous/dto/ResponseAnonymousResultDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.codingwasabi.trti.util.annonymous.dto; | ||
|
||
import com.codingwasabi.trti.domain.member.model.response.ResponseMemberDetailResultDto; | ||
import com.codingwasabi.trti.domain.result.model.Result; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class ResponseAnonymousResultDto { | ||
private List<ResponseMemberDetailResultDto> answers; | ||
|
||
public static ResponseAnonymousResultDto from(Result result) { | ||
return new ResponseAnonymousResultDto(getDetailResult(result)); | ||
} | ||
|
||
private static List<ResponseMemberDetailResultDto> getDetailResult(Result result) { | ||
List<ResponseMemberDetailResultDto> resultList = new ArrayList<>(); | ||
resultList.add(ResponseMemberDetailResultDto.from(result.getToMove())); | ||
resultList.add(ResponseMemberDetailResultDto.from(result.getToEat_1())); | ||
resultList.add(ResponseMemberDetailResultDto.from(result.getToEat_2())); | ||
resultList.add(ResponseMemberDetailResultDto.from(result.getToStay_1())); | ||
resultList.add(ResponseMemberDetailResultDto.from(result.getToStay_2())); | ||
resultList.add(ResponseMemberDetailResultDto.from(result.getToStay_3())); | ||
resultList.add(ResponseMemberDetailResultDto.from(result.getToActive())); | ||
|
||
return resultList; | ||
} | ||
} |