Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/integration' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ChoiWonYu committed Sep 13, 2024
2 parents 2ce9dba + d4b68c1 commit eb94e67
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.first.flash.account.auth.application.dto.LoginRequestDto;
import com.first.flash.account.auth.application.dto.LoginResponseDto;
import com.first.flash.account.auth.domain.Provider;
import com.first.flash.account.auth.domain.TokenManager;
import com.first.flash.account.auth.infrastructure.dto.SocialInfo;
import com.first.flash.account.member.domain.Member;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.first.flash.account.member.application.dto.ConfirmNickNameRequest;
import com.first.flash.account.member.application.dto.ConfirmNickNameResponse;
import com.first.flash.account.member.application.dto.ManageConsentRequest;
import com.first.flash.account.member.application.dto.ManageConsentResponse;
import com.first.flash.account.member.application.dto.MemberCompleteRegistrationRequest;
import com.first.flash.account.member.application.dto.MemberCompleteRegistrationResponse;
import com.first.flash.account.member.application.dto.MemberInfoResponse;
Expand Down Expand Up @@ -70,6 +72,14 @@ public MemberInfoResponse deleteMember() {
return MemberInfoResponse.toDto(member);
}

@Transactional
public ManageConsentResponse manageMarketingConsent(final ManageConsentRequest request) {
Boolean hasAgreedToMarketing = request.hasAgreedToMarketing();
Member member = findMemberByAuthInfo();
member.manageMarketingConsent(hasAgreedToMarketing);
return ManageConsentResponse.toDto(member);
}

private Member findMemberByAuthInfo() {
UUID id = AuthUtil.getId();
return findById(id);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.first.flash.account.member.application.dto;

import jakarta.validation.constraints.NotNull;

public record ManageConsentRequest(@NotNull(message = "마케팅 수신 동의 여부는 필수입니다.") Boolean hasAgreedToMarketing) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.first.flash.account.member.application.dto;

import com.first.flash.account.member.domain.Member;

public record ManageConsentResponse(boolean hasAgreedToMarketing) {

public static ManageConsentResponse toDto(final Member member) {
return new ManageConsentResponse(member.getHasAgreedToMarketing());
}
}
22 changes: 5 additions & 17 deletions src/main/java/com/first/flash/account/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,12 @@ public class Member {
private Double height;
private Double reach;
private String profileImageUrl;
private Boolean hasAgreedToMarketing;
@Enumerated(EnumType.STRING)
private Gender gender;
@Enumerated(EnumType.STRING)
private Role role;

public static Member of(final UUID id, final String email, final String nickName,
final String instagramId, final Double height, final Double reach,
final String profileImageUrl, final Gender gender, final String socialId) {
return Member.builder()
.id(id)
.email(email)
.nickName(nickName)
.socialId(socialId)
.instagramId(instagramId)
.height(height)
.reach(reach)
.profileImageUrl(profileImageUrl)
.gender(gender)
.role(Role.ROLE_USER)
.build();
}

public void completeRegistration(final String nickName, final String instagramId,
final Double height, final Gender gender, final Double reach,
final String profileImageUrl) {
Expand All @@ -72,4 +56,8 @@ public boolean hasSameNickName(final String nickName) {
public boolean isCompleteRegistration() {
return Objects.nonNull(nickName);
}

public void manageMarketingConsent(final Boolean hasAgreedToMarketing) {
this.hasAgreedToMarketing = hasAgreedToMarketing;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.first.flash.account.member.application.ReportService;
import com.first.flash.account.member.application.dto.ConfirmNickNameRequest;
import com.first.flash.account.member.application.dto.ConfirmNickNameResponse;
import com.first.flash.account.member.application.dto.ManageConsentRequest;
import com.first.flash.account.member.application.dto.ManageConsentResponse;
import com.first.flash.account.member.application.dto.MemberBlockResponse;
import com.first.flash.account.member.application.dto.MemberCompleteRegistrationRequest;
import com.first.flash.account.member.application.dto.MemberCompleteRegistrationResponse;
Expand Down Expand Up @@ -128,4 +130,19 @@ public ResponseEntity<MemberReportResponse> reportMember(
@RequestBody @Valid final MemberReportRequest request) {
return ResponseEntity.ok(reportService.reportMember(reportedContentId, request));
}

@Operation(summary = "마케팅 수신 동의 여부 설정", description = "마케팅 수신 동의 여부 설정")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "동의 여부 설정 완료",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ManageConsentResponse.class))),
@ApiResponse(responseCode = "400", description = "유효하지 않은 요청 형식",
content = @Content(mediaType = "application/json", examples = {
@ExampleObject(name = "요청값 누락", value = "{\"hasAgreedToMarketing\": \"동의 여부는 필수입니다.\"}"),
}))
})
@PostMapping("/marketing-consent")
public ResponseEntity<ManageConsentResponse> manageMarketingConsent(
@RequestBody @Valid final ManageConsentRequest request) {
return ResponseEntity.ok(memberService.manageMarketingConsent(request));
}
}

0 comments on commit eb94e67

Please sign in to comment.