From ee059a629575f8a0b34b7ec2572557a536e60a7c Mon Sep 17 00:00:00 2001 From: seeunjang Date: Thu, 6 Jun 2024 18:29:58 +0900 Subject: [PATCH 1/3] =?UTF-8?q?PET-312=20feat=20:=20=EB=9E=9C=EB=94=A9=20A?= =?UTF-8?q?PI=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/LandingRequest.java | 26 ++++++++++++++++ .../userapplication/mapper/LandingMapper.java | 15 +++++++++ .../service/LandingCreateUseCase.java | 22 +++++++++++++ .../com/pawith/userdomain/entity/Landing.java | 31 +++++++++++++++++++ .../repository/LandingRepository.java | 7 +++++ .../service/LandingSaveService.java | 17 ++++++++++ .../userpresentation/UserController.java | 8 +++++ 7 files changed, 126 insertions(+) create mode 100644 Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/dto/request/LandingRequest.java create mode 100644 Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/mapper/LandingMapper.java create mode 100644 Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/service/LandingCreateUseCase.java create mode 100644 Domain-Module/User-Module/User-Domain/src/main/java/com/pawith/userdomain/entity/Landing.java create mode 100644 Domain-Module/User-Module/User-Domain/src/main/java/com/pawith/userdomain/repository/LandingRepository.java create mode 100644 Domain-Module/User-Module/User-Domain/src/main/java/com/pawith/userdomain/service/LandingSaveService.java diff --git a/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/dto/request/LandingRequest.java b/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/dto/request/LandingRequest.java new file mode 100644 index 00000000..c122273c --- /dev/null +++ b/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/dto/request/LandingRequest.java @@ -0,0 +1,26 @@ +package com.pawith.userapplication.dto.request; + +import java.util.regex.Pattern; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class LandingRequest { + + private static final Pattern EMAIL_PATTERN = Pattern.compile("^[A-Za-z0-9+_.-]+@(.+)$"); + + private String email; + private String name; + + public void setEmail(String email) { + if (!EMAIL_PATTERN.matcher(email).matches()) { + throw new IllegalArgumentException("Email should be valid"); + } + this.email = email; + } + +} diff --git a/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/mapper/LandingMapper.java b/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/mapper/LandingMapper.java new file mode 100644 index 00000000..58b6aa84 --- /dev/null +++ b/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/mapper/LandingMapper.java @@ -0,0 +1,15 @@ +package com.pawith.userapplication.mapper; + +import com.pawith.userapplication.dto.request.LandingRequest; +import com.pawith.userdomain.entity.Landing; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class LandingMapper { + + public static Landing toLandingEntity(LandingRequest landingRequest) { + return new Landing(landingRequest.getEmail(), landingRequest.getName()); + } + +} diff --git a/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/service/LandingCreateUseCase.java b/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/service/LandingCreateUseCase.java new file mode 100644 index 00000000..8d4559f1 --- /dev/null +++ b/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/service/LandingCreateUseCase.java @@ -0,0 +1,22 @@ +package com.pawith.userapplication.service; + +import com.pawith.commonmodule.annotation.ApplicationService; +import com.pawith.userapplication.dto.request.LandingRequest; +import com.pawith.userapplication.mapper.LandingMapper; +import com.pawith.userdomain.entity.Landing; +import com.pawith.userdomain.service.LandingSaveService; +import lombok.RequiredArgsConstructor; +import org.springframework.transaction.annotation.Transactional; + +@ApplicationService +@RequiredArgsConstructor +public class LandingCreateUseCase { + private final LandingSaveService landingSaveService; + + @Transactional + public void createLanding(LandingRequest request){ + Landing landing = LandingMapper.toLandingEntity(request); + landingSaveService.saveUserLanding(landing); + } + +} diff --git a/Domain-Module/User-Module/User-Domain/src/main/java/com/pawith/userdomain/entity/Landing.java b/Domain-Module/User-Module/User-Domain/src/main/java/com/pawith/userdomain/entity/Landing.java new file mode 100644 index 00000000..5fbc803b --- /dev/null +++ b/Domain-Module/User-Module/User-Domain/src/main/java/com/pawith/userdomain/entity/Landing.java @@ -0,0 +1,31 @@ +package com.pawith.userdomain.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Landing { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "landing_id") + private Long id; + + private String email; + + private String name; + + public Landing(String email, String name) { + this.email = email; + this.name = name; + } + +} diff --git a/Domain-Module/User-Module/User-Domain/src/main/java/com/pawith/userdomain/repository/LandingRepository.java b/Domain-Module/User-Module/User-Domain/src/main/java/com/pawith/userdomain/repository/LandingRepository.java new file mode 100644 index 00000000..967d810f --- /dev/null +++ b/Domain-Module/User-Module/User-Domain/src/main/java/com/pawith/userdomain/repository/LandingRepository.java @@ -0,0 +1,7 @@ +package com.pawith.userdomain.repository; + +import com.pawith.userdomain.entity.Landing; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface LandingRepository extends JpaRepository { +} diff --git a/Domain-Module/User-Module/User-Domain/src/main/java/com/pawith/userdomain/service/LandingSaveService.java b/Domain-Module/User-Module/User-Domain/src/main/java/com/pawith/userdomain/service/LandingSaveService.java new file mode 100644 index 00000000..a229bb38 --- /dev/null +++ b/Domain-Module/User-Module/User-Domain/src/main/java/com/pawith/userdomain/service/LandingSaveService.java @@ -0,0 +1,17 @@ +package com.pawith.userdomain.service; + +import com.pawith.commonmodule.annotation.DomainService; +import com.pawith.userdomain.entity.Landing; +import com.pawith.userdomain.repository.LandingRepository; +import lombok.RequiredArgsConstructor; + +@DomainService +@RequiredArgsConstructor +public class LandingSaveService { + private final LandingRepository landingRepository; + + public void saveUserLanding(Landing landing) { + landingRepository.save(landing); + } + +} diff --git a/Domain-Module/User-Module/User-Presentation/src/main/java/com/pawith/userpresentation/UserController.java b/Domain-Module/User-Module/User-Presentation/src/main/java/com/pawith/userpresentation/UserController.java index 063f6bdd..18f9dcf3 100644 --- a/Domain-Module/User-Module/User-Presentation/src/main/java/com/pawith/userpresentation/UserController.java +++ b/Domain-Module/User-Module/User-Presentation/src/main/java/com/pawith/userpresentation/UserController.java @@ -1,6 +1,7 @@ package com.pawith.userpresentation; import com.pawith.userapplication.dto.request.PathHistoryCreateRequest; +import com.pawith.userapplication.dto.request.LandingRequest; import com.pawith.userapplication.dto.request.UserNicknameChangeRequest; import com.pawith.userapplication.dto.request.WithdrawReasonCreateRequest; import com.pawith.userapplication.dto.response.UserInfoResponse; @@ -21,6 +22,7 @@ public class UserController { private final PathHistoryCreateUseCase pathHistoryCreateUseCase; private final UserDeleteUseCase userDeleteUseCase; private final WithdrawReasonCreateUseCase withdrawReasonCreateUseCase; + private final LandingCreateUseCase landingCreateUseCase; @PutMapping("/name") public void putNicknameOnUser(@RequestBody UserNicknameChangeRequest request){ @@ -56,4 +58,10 @@ public UserJoinTermResponse getTerm() { public void postWithdrawReason(@RequestBody WithdrawReasonCreateRequest withDrawCreateRequest){ withdrawReasonCreateUseCase.createWithdrawReason(withDrawCreateRequest); } + + @PostMapping("/landing") + public void postLanding(@RequestBody LandingRequest landingRequest){ + landingCreateUseCase.createLanding(landingRequest); + } + } From 84e47c8028644b5fc6b0e771e908106c6e269cf8 Mon Sep 17 00:00:00 2001 From: seeunjang Date: Thu, 6 Jun 2024 18:30:18 +0900 Subject: [PATCH 2/3] =?UTF-8?q?PET-312=20feat=20:=20=EB=9E=9C=EB=94=A9=20A?= =?UTF-8?q?PI=20=ED=86=A0=ED=81=B0=20=EA=B2=80=EC=A6=9D=20=EB=AC=B4?= =?UTF-8?q?=EC=8B=9C=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/pawith/authapplication/consts/IgnoredPathConsts.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Domain-Module/Auth-Module/Auth-Application/src/main/java/com/pawith/authapplication/consts/IgnoredPathConsts.java b/Domain-Module/Auth-Module/Auth-Application/src/main/java/com/pawith/authapplication/consts/IgnoredPathConsts.java index fe3d0c98..115c4fec 100644 --- a/Domain-Module/Auth-Module/Auth-Application/src/main/java/com/pawith/authapplication/consts/IgnoredPathConsts.java +++ b/Domain-Module/Auth-Module/Auth-Application/src/main/java/com/pawith/authapplication/consts/IgnoredPathConsts.java @@ -17,7 +17,8 @@ public class IgnoredPathConsts { "/oauth/**", HttpMethod.GET, "/jwt", HttpMethod.GET, "/reissue",HttpMethod.POST, - "/actuator/**", HttpMethod.GET + "/actuator/**", HttpMethod.GET, + "/user/landing", HttpMethod.POST ); -} \ No newline at end of file +} From 0a56931199394c4bf7af7b4fca11ef7731d1139a Mon Sep 17 00:00:00 2001 From: seeunjang Date: Thu, 6 Jun 2024 19:21:51 +0900 Subject: [PATCH 3/3] =?UTF-8?q?PET-312=20fix=20:=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=97=90=EB=9F=AC=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/UserInfoResponse.java | 16 +++++----- .../userpresentation/UserControllerTest.java | 29 ++++++++++--------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/dto/response/UserInfoResponse.java b/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/dto/response/UserInfoResponse.java index 92e5379e..beae64b2 100644 --- a/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/dto/response/UserInfoResponse.java +++ b/Domain-Module/User-Module/User-Application/src/main/java/com/pawith/userapplication/dto/response/UserInfoResponse.java @@ -1,16 +1,16 @@ package com.pawith.userapplication.dto.response; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; @Getter +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class UserInfoResponse { - private final String nickname; - private final String email; - private final String profileImageUrl; + private String nickname; + private String email; + private String profileImageUrl; - public UserInfoResponse(String nickname, String email, String profileImageUrl) { - this.nickname = nickname; - this.email = email; - this.profileImageUrl = profileImageUrl; - } } diff --git a/Domain-Module/User-Module/User-Presentation/src/test/java/com/pawith/userpresentation/UserControllerTest.java b/Domain-Module/User-Module/User-Presentation/src/test/java/com/pawith/userpresentation/UserControllerTest.java index c68a3ce4..f9367198 100644 --- a/Domain-Module/User-Module/User-Presentation/src/test/java/com/pawith/userpresentation/UserControllerTest.java +++ b/Domain-Module/User-Module/User-Presentation/src/test/java/com/pawith/userpresentation/UserControllerTest.java @@ -41,6 +41,8 @@ class UserControllerTest extends BaseRestDocsTest { private UserDeleteUseCase userDeleteUseCase; @MockBean private WithdrawReasonCreateUseCase withdrawReasonCreateUseCase; + @MockBean + private LandingCreateUseCase landingCreateUseCase; private static final String USER_REQUEST_URL = "/user"; private static final String ACCESS_TOKEN = "Bearer accessToken"; @@ -183,22 +185,23 @@ void getTerm() throws Exception { @DisplayName("서비스 탈퇴 이유 저장 API 테스트") void postWithdrawReason() throws Exception { //given - final WithdrawReasonCreateRequest withdrawReasonCreateRequest = FixtureMonkeyUtils.getConstructBasedFixtureMonkey().giveMeOne(WithdrawReasonCreateRequest.class); + final WithdrawReasonCreateRequest withdrawReasonCreateRequest = FixtureMonkeyUtils.getConstructBasedFixtureMonkey() + .giveMeOne(WithdrawReasonCreateRequest.class); final MockHttpServletRequestBuilder request = post(USER_REQUEST_URL + "/withdraw") - .content(objectMapper.writeValueAsString(withdrawReasonCreateRequest)) - .contentType("application/json") - .header(AUTHORIZATION_HEADER, ACCESS_TOKEN); + .content(objectMapper.writeValueAsString(withdrawReasonCreateRequest)) + .contentType("application/json") + .header(AUTHORIZATION_HEADER, ACCESS_TOKEN); //when ResultActions result = mvc.perform(request); //then result.andExpect(status().isOk()) - .andDo(resultHandler.document( - requestHeaders( - headerWithName(AUTHORIZATION_HEADER).description("access 토큰") - ), - requestFields( - fieldWithPath("reason").description("탈퇴 이유") - ) - )); + .andDo(resultHandler.document( + requestHeaders( + headerWithName(AUTHORIZATION_HEADER).description("access 토큰") + ), + requestFields( + fieldWithPath("reason").description("탈퇴 이유") + ) + )); } -} \ No newline at end of file +}