Skip to content

Commit

Permalink
Merge pull request #31 from Na-o-man/feature/#14/members-marketingter…
Browse files Browse the repository at this point in the history
…ms-api

[FEAT] 마케팅 이용약관 동의 여부 조회 api 구현
  • Loading branch information
bflykky authored Jul 31, 2024
2 parents 045a4fb + 274fbf1 commit 3a6287c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<MemberResponse.MemberInfo> 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<MemberResponse.MarketingAgreed> getMarketingAgreed(@PathVariable(name = "memberId") Long memberId) {
Member member = memberService.findMember(memberId);
return ResultResponse.of(MemberResultCode.CHECK_MARKETING_AGREED, memberConverter.toMarketingAgreed(member));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ 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())
.image(member.getImage())
.build();
}

public MemberResponse.MarketingAgreed toMarketingAgreed(Member member) {
return MemberResponse.MarketingAgreed.builder()
.marketingAgreed(member.getMarketingAgreed())
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ public static class MemberInfo { //특정 회원 조회
private String email;
private String image;
}

@Builder
@Getter
@AllArgsConstructor
public static class MarketingAgreed {
private Boolean marketingAgreed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3a6287c

Please sign in to comment.