Skip to content

Commit

Permalink
chore: 회원탈퇴
Browse files Browse the repository at this point in the history
  • Loading branch information
GayeongKimm committed Aug 1, 2024
1 parent b030379 commit 97cd243
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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<LoadProfileRes> loadProfile(){
return memberProfileService.loadProfile();
}
}

Original file line number Diff line number Diff line change
@@ -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()
);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<LoadProfileRes> loadProfile(){
MemberEntity member = getCurrentMember.current();

return ResponseData.of(HttpStatus.OK, "조회 성공", LoadProfileRes.of(memberRepository.findByMemberId(member.getMemberId())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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, "성공");
}

Expand Down

0 comments on commit 97cd243

Please sign in to comment.