diff --git a/src/main/java/com/umc/naoman/domain/member/controller/MemberController.java b/src/main/java/com/umc/naoman/domain/member/controller/MemberController.java index 8096528..2f67fe0 100644 --- a/src/main/java/com/umc/naoman/domain/member/controller/MemberController.java +++ b/src/main/java/com/umc/naoman/domain/member/controller/MemberController.java @@ -4,8 +4,13 @@ import com.umc.naoman.domain.member.dto.MemberResponse; import com.umc.naoman.domain.member.entity.Member; import com.umc.naoman.domain.member.service.MemberService; +import com.umc.naoman.global.error.ErrorResponse; import com.umc.naoman.global.result.ResultResponse; import com.umc.naoman.global.result.code.MemberResultCode; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; @@ -19,11 +24,36 @@ @RequiredArgsConstructor public class MemberController { private final MemberService memberService; + private final MemberConverter memberConverter; @GetMapping("/{memberId}") // memberId를 사용해 특정 회원 정보 조회 + @Operation( summary = "특정 회원 정보 조회 API", description = "[PathVariable]\n memberId\n[request]\n" + + "[response]\n uesrname, email, 소셜 프로필 이미지 url") + @ApiResponses({ + @io.swagger.v3.oas.annotations.responses.ApiResponse + (responseCode = "SM005", description = "특정 회원 정보 조회 성공."), + @io.swagger.v3.oas.annotations.responses.ApiResponse + (responseCode = "EM001", description = "해당 memberId를 가진 회원이 존재하지 않습니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + }) public ResultResponse getMemberInfo(@PathVariable(name = "memberId") Long memberId) { Member member = memberService.findMember(memberId); return ResultResponse.of(MemberResultCode.MEMBER_INFO, - MemberConverter.toMemberInfo(member)); + memberConverter.toMemberInfo(member)); + } + + @GetMapping("/terms/{memberId}") + @Operation(summary = "마케팅 약관 동의 여부 조회 API", description = "[PathVariable]\n memberId\n[request]\n" + + "[response]\n 마케팅 동의 여부 -> 동의 => true, 비동의 => false") + @ApiResponses({ + @io.swagger.v3.oas.annotations.responses.ApiResponse + (responseCode = "SM006", description = "마케팅 약관 동의 여부 조회 성공."), + @io.swagger.v3.oas.annotations.responses.ApiResponse + (responseCode = "EM001", description = "해당 memberId를 가진 회원이 존재하지 않습니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + }) + public ResultResponse getMarketingAgreed(@PathVariable(name = "memberId") Long memberId) { + Member member = memberService.findMember(memberId); + return ResultResponse.of(MemberResultCode.CHECK_MARKETING_AGREED, memberConverter.toMarketingAgreed(member)); } } diff --git a/src/main/java/com/umc/naoman/domain/member/converter/MemberConverter.java b/src/main/java/com/umc/naoman/domain/member/converter/MemberConverter.java index 6aa9976..ac5472b 100644 --- a/src/main/java/com/umc/naoman/domain/member/converter/MemberConverter.java +++ b/src/main/java/com/umc/naoman/domain/member/converter/MemberConverter.java @@ -40,7 +40,7 @@ public SignupRequest toSignupRequest(Claims payload, boolean marketingAgreed) { .build(); } - public static MemberResponse.MemberInfo toMemberInfo(Member member) { + public MemberResponse.MemberInfo toMemberInfo(Member member) { return MemberResponse.MemberInfo.builder() .name(member.getName()) .email(member.getEmail()) @@ -48,4 +48,10 @@ public static MemberResponse.MemberInfo toMemberInfo(Member member) { .build(); } + public MemberResponse.MarketingAgreed toMarketingAgreed(Member member) { + return MemberResponse.MarketingAgreed.builder() + .marketingAgreed(member.getMarketingAgreed()) + .build(); + } + } diff --git a/src/main/java/com/umc/naoman/domain/member/dto/MemberResponse.java b/src/main/java/com/umc/naoman/domain/member/dto/MemberResponse.java index 35a66c0..ba0f426 100644 --- a/src/main/java/com/umc/naoman/domain/member/dto/MemberResponse.java +++ b/src/main/java/com/umc/naoman/domain/member/dto/MemberResponse.java @@ -34,4 +34,11 @@ public static class MemberInfo { //특정 회원 조회 private String email; private String image; } + + @Builder + @Getter + @AllArgsConstructor + public static class MarketingAgreed { + private Boolean marketingAgreed; + } } diff --git a/src/main/java/com/umc/naoman/domain/member/entity/Member.java b/src/main/java/com/umc/naoman/domain/member/entity/Member.java index 0984a0c..fa2df16 100644 --- a/src/main/java/com/umc/naoman/domain/member/entity/Member.java +++ b/src/main/java/com/umc/naoman/domain/member/entity/Member.java @@ -40,7 +40,7 @@ public class Member extends BaseTimeEntity { @Column(name = "social_type", nullable = false) private SocialType socialType; @Column(name = "marketing_agreed") - private boolean marketingAgreed; + private Boolean marketingAgreed; public Member update(String name, String image) { this.name = name; diff --git a/src/main/java/com/umc/naoman/global/result/code/MemberResultCode.java b/src/main/java/com/umc/naoman/global/result/code/MemberResultCode.java index 98d17de..430d615 100644 --- a/src/main/java/com/umc/naoman/global/result/code/MemberResultCode.java +++ b/src/main/java/com/umc/naoman/global/result/code/MemberResultCode.java @@ -13,6 +13,7 @@ public enum MemberResultCode implements ResultCode { EDIT_MYPAGE_INFO(200, "SM002", "내 정보를 성공적으로 수정하였습니다."), CHECK_MEMBER_REGISTRATION(200, "SM000", "해당 이메일을 가진 회원의 가입 여부를 성공적으로 조회하였습니다."), MEMBER_INFO (200,"SM005","회원 정보를 성공적으로 조회하였습니다."), + CHECK_MARKETING_AGREED(200,"SM006","마케팅동의여부를 성공적으로 조회하였습니다."), ; private final int status; private final String code;