diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberController.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberController.java index f722937..f35610d 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberController.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberController.java @@ -14,17 +14,8 @@ @RequiredArgsConstructor public class MemberController { private final MemberService memberService; - private final MemberProfileService memberProfileService; - @PatchMapping("/profile") - public Response modifyMember( - @RequestBody MemberModifyReq memberModifyReq){ - return memberProfileService.memberModify(memberModifyReq); - } - @PatchMapping() - public Response deleteMember( - @RequestParam String memberId - ){ - return memberService.deleteMember(memberId); + public Response deleteMember(){ + return memberService.deleteMember(); } } diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberProfileController.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberProfileController.java new file mode 100644 index 0000000..64230af --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberProfileController.java @@ -0,0 +1,32 @@ +package kr.hs.dgsw.SOPO_server_v2.domain.member.presentation.controller; + +import io.swagger.v3.oas.annotations.tags.Tag; +import kr.hs.dgsw.SOPO_server_v2.domain.member.presentation.dto.req.MemberModifyReq; +import kr.hs.dgsw.SOPO_server_v2.domain.member.presentation.dto.res.LoadProfileRes; +import kr.hs.dgsw.SOPO_server_v2.domain.member.service.MemberProfileService; +import kr.hs.dgsw.SOPO_server_v2.domain.member.service.MemberService; +import kr.hs.dgsw.SOPO_server_v2.global.response.Response; +import kr.hs.dgsw.SOPO_server_v2.global.response.ResponseData; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +@Tag(name = "Profile", description = "Profile Api") +@RestController +@RequestMapping(value = "/profile") +@RequiredArgsConstructor +public class MemberProfileController { + + private final MemberProfileService memberProfileService; + + @PatchMapping("") + public Response modifyMember( + @RequestBody MemberModifyReq memberModifyReq) { + return memberProfileService.memberModify(memberModifyReq); + } + + @GetMapping + public ResponseData loadProfile(){ + return memberProfileService.loadProfile(); + } +} + diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/dto/res/loadProfileRes.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/dto/res/loadProfileRes.java index c7252ea..0dbb12e 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/dto/res/loadProfileRes.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/dto/res/loadProfileRes.java @@ -1,8 +1,21 @@ package kr.hs.dgsw.SOPO_server_v2.domain.member.presentation.dto.res; -public record loadProfileRes( - String memberName, - String memberEmail +import kr.hs.dgsw.SOPO_server_v2.domain.member.entity.MemberEntity; +public record LoadProfileRes( + String memberId, + String memberName, + String memberEmail, + String memberSchool ) { + + public static LoadProfileRes of(MemberEntity member){ + return new LoadProfileRes( + member.getMemberId(), + member.getMemberName(), + member.getMemberEmail(), + member.getMemberSchool() + ); + + } } diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/service/MemberProfileService.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/service/MemberProfileService.java index d60916d..6a608e3 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/service/MemberProfileService.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/service/MemberProfileService.java @@ -3,11 +3,13 @@ import kr.hs.dgsw.SOPO_server_v2.domain.auth.service.AuthEmailService; import kr.hs.dgsw.SOPO_server_v2.domain.member.entity.MemberEntity; import kr.hs.dgsw.SOPO_server_v2.domain.member.presentation.dto.req.MemberModifyReq; +import kr.hs.dgsw.SOPO_server_v2.domain.member.presentation.dto.res.LoadProfileRes; import kr.hs.dgsw.SOPO_server_v2.domain.member.repository.MemberRepository; import kr.hs.dgsw.SOPO_server_v2.global.error.custom.email.CodeIsWrongException; import kr.hs.dgsw.SOPO_server_v2.global.error.custom.member.NeedAuthCode; import kr.hs.dgsw.SOPO_server_v2.global.infra.security.GetCurrentMember; import kr.hs.dgsw.SOPO_server_v2.global.response.Response; +import kr.hs.dgsw.SOPO_server_v2.global.response.ResponseData; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -53,7 +55,10 @@ public Response memberModify(MemberModifyReq memberModifyReq) { return Response.of(HttpStatus.OK, "성공"); } - public Response loadProfile(){ - return null; + @Transactional(rollbackFor = Exception.class) + public ResponseData loadProfile(){ + MemberEntity member = getCurrentMember.current(); + + return ResponseData.of(HttpStatus.OK, "조회 성공", LoadProfileRes.of(memberRepository.findByMemberId(member.getMemberId()))); } } diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/service/MemberService.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/service/MemberService.java index 6495ca3..724a077 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/service/MemberService.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/service/MemberService.java @@ -19,14 +19,9 @@ public class MemberService { private final GetCurrentMember getCurrentMember; @Transactional(rollbackFor = Exception.class) - public Response deleteMember(String memberId){ - MemberEntity member = memberRepository.findByMemberId(memberId); - - if (!getCurrentMember.current().equals(member)) - throw MemberNotCoincideException.EXCEPTION; - + public Response deleteMember(){ + MemberEntity member = memberRepository.findByMemberId(getCurrentMember.current();); member.setMemberState(MemberState.DELETED); - return Response.of(HttpStatus.OK, "성공"); }