From 3b0c8c633b8f2bcba24f63fe0761c55b9252f57d Mon Sep 17 00:00:00 2001 From: xb205 <62425964+devxb@users.noreply.github.com> Date: Fri, 1 Mar 2024 13:34:00 +0900 Subject: [PATCH] =?UTF-8?q?[feat]:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=ED=95=9C?= =?UTF-8?q?=20=EC=9C=A0=EC=A0=80=EC=9D=98=20gallery=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20(#380)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JwtDecryptInterceptorConfigurer.java | 1 + .../me/nalab/gallery/app/GalleryGetApp.kt | 26 +++ .../gallery/controller/GalleryController.kt | 7 + .../me/nalab/gallery/domain/GalleryService.kt | 6 + support/e2e/v1_10_get_logined_gallery.hurl | 221 ++++++++++++++++++ 5 files changed, 261 insertions(+) create mode 100644 gallery/src/main/kotlin/me/nalab/gallery/app/GalleryGetApp.kt create mode 100644 support/e2e/v1_10_get_logined_gallery.hurl diff --git a/auth/auth-interceptor/src/main/java/me/nalab/auth/interceptor/JwtDecryptInterceptorConfigurer.java b/auth/auth-interceptor/src/main/java/me/nalab/auth/interceptor/JwtDecryptInterceptorConfigurer.java index fde209cd..84bc105d 100644 --- a/auth/auth-interceptor/src/main/java/me/nalab/auth/interceptor/JwtDecryptInterceptorConfigurer.java +++ b/auth/auth-interceptor/src/main/java/me/nalab/auth/interceptor/JwtDecryptInterceptorConfigurer.java @@ -29,6 +29,7 @@ public class JwtDecryptInterceptorConfigurer implements WebMvcConfigurer { "/v1/users", "/v1/gallerys/previews", "/v1/surveys/*/bookmarks", + "/v1/gallerys/logins", "/v1/gallerys", }; diff --git a/gallery/src/main/kotlin/me/nalab/gallery/app/GalleryGetApp.kt b/gallery/src/main/kotlin/me/nalab/gallery/app/GalleryGetApp.kt new file mode 100644 index 00000000..3c7f33d6 --- /dev/null +++ b/gallery/src/main/kotlin/me/nalab/gallery/app/GalleryGetApp.kt @@ -0,0 +1,26 @@ +package me.nalab.gallery.app + +import me.nalab.gallery.domain.GalleryService +import me.nalab.gallery.domain.response.GalleryDto +import me.nalab.survey.application.port.`in`.web.findfeedback.FeedbackFindUseCase +import me.nalab.survey.application.port.`in`.web.survey.find.SurveyFindUseCase +import me.nalab.survey.application.port.`in`.web.target.find.TargetFindUseCase +import org.springframework.stereotype.Service + +@Service +class GalleryGetApp( + private val targetFindUseCase: TargetFindUseCase, + private val surveyFindUseCase: SurveyFindUseCase, + private val feedbackFindUseCase: FeedbackFindUseCase, + private val galleryService: GalleryService, +) { + + fun getGalleryByTargetId(targetId: Long): GalleryDto { + val gallery = galleryService.getGalleryByTargetId(targetId) + val target = targetFindUseCase.findTarget(targetId) + val survey = surveyFindUseCase.getSurveyByTargetId(targetId) + val feedbacks = feedbackFindUseCase.findAllFeedbackDtoBySurveyId(survey.id) + + return toGalleryDto(gallery, target, survey, feedbacks) + } +} diff --git a/gallery/src/main/kotlin/me/nalab/gallery/controller/GalleryController.kt b/gallery/src/main/kotlin/me/nalab/gallery/controller/GalleryController.kt index 96ef14cf..915e2862 100644 --- a/gallery/src/main/kotlin/me/nalab/gallery/controller/GalleryController.kt +++ b/gallery/src/main/kotlin/me/nalab/gallery/controller/GalleryController.kt @@ -1,5 +1,6 @@ package me.nalab.gallery.controller +import me.nalab.gallery.app.GalleryGetApp import me.nalab.gallery.app.GalleryPreviewApp import me.nalab.gallery.app.GalleryRegisterApp import me.nalab.gallery.controller.request.GalleryRegisterRequest @@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.* @RestController @RequestMapping("/v1/gallerys") class GalleryController( + private val galleryGetApp: GalleryGetApp, private val galleryPreviewApp: GalleryPreviewApp, private val galleryRegisterApp: GalleryRegisterApp, ) { @@ -29,4 +31,9 @@ class GalleryController( return galleryRegisterApp.registerGalleryByTargetId(targetId, request.job) } + @GetMapping("/logins") + @ResponseStatus(HttpStatus.OK) + fun getGallery(@RequestAttribute("logined") targetId: Long): GalleryDto = + galleryGetApp.getGalleryByTargetId(targetId) + } diff --git a/gallery/src/main/kotlin/me/nalab/gallery/domain/GalleryService.kt b/gallery/src/main/kotlin/me/nalab/gallery/domain/GalleryService.kt index f22f3aa3..e98c79c8 100644 --- a/gallery/src/main/kotlin/me/nalab/gallery/domain/GalleryService.kt +++ b/gallery/src/main/kotlin/me/nalab/gallery/domain/GalleryService.kt @@ -4,10 +4,16 @@ import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @Service +@Transactional(readOnly = true) class GalleryService( private val galleryRepository: GalleryRepository, ) { + fun getGalleryByTargetId(targetId: Long): Gallery { + return galleryRepository.findByTargetIdOrNull(targetId) + ?: throw IllegalArgumentException("targetId \"$targetId\" 에 해당하는 Gallery를 찾을 수 없습니다.") + } + @Transactional fun registerGallery(gallery: Gallery): Gallery { require(galleryRepository.findByTargetIdOrNull(gallery.getTargetId()) == null) { diff --git a/support/e2e/v1_10_get_logined_gallery.hurl b/support/e2e/v1_10_get_logined_gallery.hurl new file mode 100644 index 00000000..49eb0ab5 --- /dev/null +++ b/support/e2e/v1_10_get_logined_gallery.hurl @@ -0,0 +1,221 @@ +POST http://nalab-server:8080/v1/oauth/default # Default provider를 통해서 로그인 진행 +{ + "nickname": "logined_gallery", + "email": "loginedgallery@123456" +} + +HTTP 200 +[Asserts] +header "Content-type" == "application/json" + +jsonpath "$.access_token" exists +jsonpath "$.token_type" exists + +[Captures] +token_type: jsonpath "$.token_type" +auth_token: jsonpath "$.access_token" + +########## + +POST http://nalab-server:8080/v1/surveys # 발급받은 토큰으로 survey를 생성한다. +Authorization: {{ token_type }} {{ auth_token }} +{ + "question_count": 2, + "question": [ + { + "type": "choice", + "form_type": "tendency", + "title": "저는 UI, UI, GUI 중에 어떤 분야를 가장 잘하는 것 같나요?", + "choices": [ + { + "content": "UI", + "order": 1 + }, + { + "content": "UX", + "order": 2 + }, + { + "content": "GUI", + "order": 3 + } + ], + "max_selectable_count": 1, + "order": 1 + }, + { + "type": "short", + "form_type": "strength", + "title": "저는 UX, UI, GUI 중에 어떤 분야에 더 강점이 있나요?", + "order": 2 + } + ] +} + +HTTP 201 +[Asserts] +header "Content-type" == "application/json" + +jsonpath "$.survey_id" exists + +[Captures] +survey_id: jsonpath "$.survey_id" + +########## + +GET http://nalab-server:8080/v1/surveys/{{ survey_id }} # 생성된 survey를 조회한다. + +HTTP 200 +[Asserts] +header "Content-type" == "application/json" + +jsonpath "$.survey_id" exists + +jsonpath "$.target.id" exists +jsonpath "$.target.nickname" == "logined_gallery" + +jsonpath "$.question_count" == 2 +jsonpath "$.question.[0].question_id" exists +jsonpath "$.question.[0].type" == "choice" +jsonpath "$.question.[0].form_type" == "tendency" +jsonpath "$.question.[0].title" == "저는 UI, UI, GUI 중에 어떤 분야를 가장 잘하는 것 같나요?" +jsonpath "$.question.[0].order" == 1 +jsonpath "$.question.[0].max_selectable_count" == 1 +jsonpath "$.question.[0].choices.[0].choice_id" exists +jsonpath "$.question.[0].choices.[0].content" == "UI" +jsonpath "$.question.[0].choices.[0].order" == 1 +jsonpath "$.question.[0].choices.[1].choice_id" exists +jsonpath "$.question.[0].choices.[1].content" == "UX" +jsonpath "$.question.[0].choices.[1].order" == 2 +jsonpath "$.question.[0].choices.[2].choice_id" exists +jsonpath "$.question.[0].choices.[2].content" == "GUI" +jsonpath "$.question.[0].choices.[2].order" == 3 +jsonpath "$.question.[1].question_id" exists +jsonpath "$.question.[1].type" == "short" +jsonpath "$.question.[1].form_type" == "strength" +jsonpath "$.question.[1].title" == "저는 UX, UI, GUI 중에 어떤 분야에 더 강점이 있나요?" +jsonpath "$.question.[1].order" == 2 + +[Captures] +target_id: jsonpath "$.target.id" +tendency_question_id: jsonpath "$.question.[0].question_id" +tendency_question_choice_id: jsonpath "$.question.[0].choices.[0].choice_id" +strength_question_id: jsonpath "$.question.[1].question_id" + + +########## + +POST http://nalab-server:8080/v1/surveys/{{ survey_id }}/bookmarks # survey_id를 북마크한다. +Authorization: {{ token_type }} {{ auth_token }} + +HTTP 200 +[Asserts] +header "Content-type" == "application/json" + +jsonpath "$.target_id" == {{ target_id }} +jsonpath "$.survey_id" == {{ survey_id }} +jsonpath "$.nickname" == "logined_gallery" + +########## + +POST http://nalab-server:8080/v1/feedbacks # 생성된 survey에 feedback을 남긴다. + +[QueryStringParams] +survey-id: {{ survey_id }} + +{ + "reviewer": { + "collaboration_experience": true, + "position": "pm" + }, + "question_feedback": [ + { + "question_id": {{ tendency_question_id }}, + "type": "choice", + "choices": [ + {{ tendency_question_choice_id }} + ] + }, + { + "question_id": {{ strength_question_id }}, + "type": "short", + "reply": [ + "Hello world" + ] + } + ] +} + +HTTP 201 +[Asserts] + +########## + +GET http://nalab-server:8080/v1/feedbacks # 북마크를 위해 feedback id 저장 +Authorization: {{ token_type }} {{ auth_token }} + +[QueryStringParams] +survey-id: {{ survey_id }} + +HTTP 200 +[Asserts] +header "Content-type" == "application/json" + +[Captures] +form_question_feedback_id: jsonpath "$.question_feedback.[0].feedbacks.[0].form_question_feedback_id" + +########## + +PATCH http://nalab-server:8080/v1/feedbacks/bookmarks # 북마크를 진행한다. +Authorization: {{ token_type }} {{ auth_token }} + +[QueryStringParams] +form-question-feedback-id: {{form_question_feedback_id}} + +########## + +POST http://nalab-server:8080/v1/gallerys # gallery를 등록한다 +Authorization: {{ token_type }} {{ auth_token }} +{ + "job": "designer" +} + +HTTP 200 +[Asserts] +header "Content-type" == "application/json" + +jsonpath "$.target.target_id" == {{ target_id }} +jsonpath "$.target.nickname" == "logined_gallery" +jsonpath "$.target.position" == null +jsonpath "$.target.job" == "DESIGNER" +jsonpath "$.target.image_url" == "empty_image" + +jsonpath "$.survey.survey_id" == {{ survey_id }} +jsonpath "$.survey.feedback_count" == 1 +jsonpath "$.survey.bookmarked_count" == 1 +jsonpath "$.survey.feedbacks.[0]" == "Hello world" +jsonpath "$.survey.tendencies.[0].name" == "UI" +jsonpath "$.survey.tendencies.[0].count" == 1 + +########## + +GET http://nalab-server:8080/v1/gallerys/logins # 내 gallery 를 조회한다 +Authorization: {{ token_type }} {{ auth_token }} + +HTTP 200 +[Asserts] +header "Content-type" == "application/json" + +jsonpath "$.target.target_id" == {{ target_id }} +jsonpath "$.target.nickname" == "logined_gallery" +jsonpath "$.target.position" == null +jsonpath "$.target.job" == "DESIGNER" +jsonpath "$.target.image_url" == "empty_image" + +jsonpath "$.survey.survey_id" == {{ survey_id }} +jsonpath "$.survey.feedback_count" == 1 +jsonpath "$.survey.bookmarked_count" == 1 +jsonpath "$.survey.feedbacks.[0]" == "Hello world" +jsonpath "$.survey.tendencies.[0].name" == "UI" +jsonpath "$.survey.tendencies.[0].count" == 1 +