-
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.
THT-Server-250 [App] 회원가입전 계정 문의하기 API
- Loading branch information
Showing
5 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
tht-apis/src/main/java/com/tht/thtapis/facade/user/InquiryFacade.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,21 @@ | ||
package com.tht.thtapis.facade.user; | ||
|
||
import com.tht.domain.entity.inquiry.InquiryService; | ||
import com.tht.thtapis.facade.Facade; | ||
import com.tht.thtapis.facade.setting.InquiryRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Facade | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class InquiryFacade { | ||
|
||
private final InquiryService inquiryService; | ||
|
||
@Transactional | ||
public void inquiryForLogin(final InquiryRequest request) { | ||
inquiryService.beforeLogin(request.contents(), request.userEmail(), request.isEmailAgree()); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
tht-apis/src/main/java/com/tht/thtapis/ui/InquiryController.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,25 @@ | ||
package com.tht.thtapis.ui; | ||
|
||
import com.tht.thtapis.facade.setting.InquiryRequest; | ||
import com.tht.thtapis.facade.user.InquiryFacade; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
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.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class InquiryController { | ||
|
||
private final InquiryFacade inquiryFacade; | ||
|
||
@PostMapping("/users/login/inquiry") | ||
public ResponseEntity<Object> inquiryUserJoin(@RequestBody @Valid InquiryRequest request) { | ||
|
||
inquiryFacade.inquiryForLogin(request); | ||
return ResponseEntity.status(HttpStatus.CREATED).build(); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
tht-apis/src/test/java/com/tht/thtapis/documentation/InquiryDocs.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,62 @@ | ||
package com.tht.thtapis.documentation; | ||
|
||
import com.epages.restdocs.apispec.ResourceSnippetParameters; | ||
import com.epages.restdocs.apispec.Schema; | ||
import com.tht.thtapis.controller.config.ControllerTestConfig; | ||
import com.tht.thtapis.facade.setting.InquiryRequest; | ||
import com.tht.thtapis.facade.user.InquiryFacade; | ||
import com.tht.thtapis.fixture.setting.InquiryRequestFixture; | ||
import com.tht.thtapis.ui.InquiryController; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.web.servlet.ResultActions; | ||
|
||
import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document; | ||
import static com.epages.restdocs.apispec.ResourceDocumentation.resource; | ||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; | ||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.*; | ||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@WebMvcTest(InquiryController.class) | ||
class InquiryDocs extends ControllerTestConfig { | ||
|
||
@MockBean | ||
InquiryFacade inquiryFacade; | ||
|
||
@Test | ||
@DisplayName("로그인 및 회원가입 전 문의하기 docs") | ||
void inquiryDocs() throws Exception { | ||
|
||
InquiryRequest request = InquiryRequestFixture.make(); | ||
String requestBody = ControllerTestConfig.objectMapper.writeValueAsString(request); | ||
|
||
final ResultActions resultActions = mockMvc.perform(post("/users/login/inquiry") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.accept(MediaType.APPLICATION_JSON) | ||
.content(requestBody) | ||
).andDo( | ||
document("로그인 및 회원가입 전 문의하기", | ||
preprocessRequest(prettyPrint()), | ||
preprocessResponse(prettyPrint()), | ||
resource( | ||
ResourceSnippetParameters.builder() | ||
.tag("유저 - 로그인") | ||
.description("로그인 및 회원가입 전 문의하기") | ||
.requestFields( | ||
fieldWithPath("userEmail").description("문의 답장 받을 이메일"), | ||
fieldWithPath("contents").description("유저 디바이스 키"), | ||
fieldWithPath("isEmailAgree").description("메일 정보동의 제공 여부") | ||
) | ||
.requestSchema(Schema.schema("InquiryRequest")) | ||
.build() | ||
)) | ||
); | ||
|
||
resultActions.andExpect(status().isCreated()); | ||
|
||
} | ||
} |
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