Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/190 회원 삭제 api 기능 수정 #199

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
import com.umc.TheGoods.domain.member.Auth;
import com.umc.TheGoods.domain.member.Member;
import com.umc.TheGoods.domain.member.Term;
import com.umc.TheGoods.domain.mypage.Account;
import com.umc.TheGoods.domain.mypage.Address;
import com.umc.TheGoods.domain.mypage.ContactTime;
import com.umc.TheGoods.domain.mypage.Declaration;
import com.umc.TheGoods.domain.mypage.*;
import com.umc.TheGoods.domain.order.OrderItem;
import com.umc.TheGoods.service.ItemService.ItemQueryService;
import com.umc.TheGoods.web.dto.item.ItemResponseDTO;
Expand Down Expand Up @@ -169,21 +166,6 @@ public static Auth toEmailAuth(String email, String code, Boolean expired) {
.build();
}

public static MemberResponseDTO.EmailAuthConfirmResultDTO toEmailAuthConfirmResultDTO(Boolean checkEmail, String jwt) {


return MemberResponseDTO.EmailAuthConfirmResultDTO.builder()
.checkEmail(checkEmail)
.jwt(jwt)
.build();
}

public static MemberResponseDTO.SocialLoginResultDTO toSocialLoginResultDTO(String result) {

return MemberResponseDTO.SocialLoginResultDTO.builder()
.result(result)
.build();
}

public static MemberResponseDTO.SocialJoinResultDTO toSocialJoinResultDTO(String phone, String email) {

Expand Down Expand Up @@ -307,20 +289,6 @@ public static Member toUpdateProfile(Member member, ProfileImg profileImg, Strin
.build();
}

public static MemberResponseDTO.RoleUpdateResultDTO toUpdateRole(Member member) {

return MemberResponseDTO.RoleUpdateResultDTO.builder()
.role(member.getMemberRole())
.build();
}

public static MemberResponseDTO.PhoneNameUpdateResultDTO toUpdatePhoneName(Member member) {

return MemberResponseDTO.PhoneNameUpdateResultDTO.builder()
.name(member.getName())
.phone(member.getPhone())
.build();
}

public static Address toAddress(MemberRequestDTO.AddressDTO request,Member member){
return Address.builder()
Expand All @@ -347,6 +315,7 @@ public static Account toAccount(MemberRequestDTO.AccountDTO request, Member memb
}



public static MemberResponseDTO.AddressResultDTO toPostAddressDTO(String address){

return MemberResponseDTO.AddressResultDTO.builder()
Expand All @@ -364,25 +333,6 @@ public static MemberResponseDTO.AccountResultDTO toPostAccountDTO(String account
}


public static MemberResponseDTO.MyPageOrderItemDTO toMyPageOrderItemDTO(OrderItem orderItem, Item item){

List<ItemResponseDTO.ItemImgResponseDTO> itemImgResponseDTOList = item.getItemImgList().stream()
.map(ItemConverter::getItemImgDTO)
.filter(ItemResponseDTO.ItemImgResponseDTO::getIsThumbNail).collect(Collectors.toList());

List<String> itemOptionList = item.getItemOptionList().stream()
.map(ItemOption::getName).collect(Collectors.toList());

return MemberResponseDTO.MyPageOrderItemDTO.builder()
.id(orderItem.getId())
.imageUrl(itemImgResponseDTOList.get(0).getItemImgUrl())
.option(itemOptionList)
.name(item.getName())
.orderStatus(orderItem.getStatus())
.price(item.getPrice())
.time(orderItem.getCreatedAt())
.build();
}

public static List<MemberResponseDTO.AccountDTO> toGetAccountDTO(List<Account> account){

Expand Down Expand Up @@ -411,6 +361,14 @@ public static List<MemberResponseDTO.AddressDTO> toGetAddressDTO(List<Address> a
return addressList;
}

public static MemberResponseDTO.AddressAndAccountDTO toGetAddressAndAccountDTO(List<Address> address, List<Account> account){


return MemberResponseDTO.AddressAndAccountDTO.builder()
.accountDTO(toGetAccountDTO(account))
.addressDTO(toGetAddressDTO(address))
.build();
}

public static Declaration toDeclaration(Member member, MemberRequestDTO.DeclareDTO request){

Expand Down Expand Up @@ -472,4 +430,13 @@ public static MemberResponseDTO.ContactResponseDTO toContactDTO(ContactTime cont
.build();
}

public static WithdrawReason toWithdrawReason(MemberRequestDTO.WithdrawReasonDTO request){
return WithdrawReason.builder()
.reason(request.getReason())
.caution(request.getCaution())
.build();
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ public abstract class BaseDateTimeEntity {

@LastModifiedDate
private LocalDateTime updatedAt;

}
16 changes: 10 additions & 6 deletions src/main/java/com/umc/TheGoods/domain/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.hibernate.annotations.DynamicInsert;

import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -112,6 +114,8 @@ public class Member extends BaseDateTimeEntity {
@ColumnDefault("false")
private Boolean infoTerm;

private LocalDateTime deletedAt;


@OneToMany(mappedBy = "member", cascade = CascadeType.ALL)
private List<MemberTerm> memberTermList = new ArrayList<>();
Expand All @@ -134,18 +138,17 @@ public class Member extends BaseDateTimeEntity {
@OneToOne(mappedBy = "member")
private Revenue revenue;

@OneToOne(mappedBy = "member")
private WithdrawReason withdrawReason;

@OneToOne(mappedBy = "member")
private ProfileImg profileImg;


//notification 양방향 매핑
@OneToMany(mappedBy = "member", cascade = CascadeType.ALL)
private List<Notification> notification = new ArrayList<>();

// item 양방향 매핑
@OneToMany(mappedBy = "member", cascade = CascadeType.ALL)
@OneToMany(mappedBy = "member", cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH})
private List<Item> itemList = new ArrayList<>();

@OneToMany(mappedBy = "member", cascade = CascadeType.ALL)
Expand All @@ -164,7 +167,7 @@ public class Member extends BaseDateTimeEntity {
private List<Cart> cartList = new ArrayList<>();

// orders 양방향 매핑
@OneToMany(mappedBy = "member", cascade = CascadeType.ALL)
@OneToMany(mappedBy = "member", cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH})
private List<Orders> ordersList = new ArrayList<>();

// tag_search 양방향 매핑
Expand Down Expand Up @@ -210,14 +213,15 @@ public class Member extends BaseDateTimeEntity {
private List<Inquiry> incommingInquiryList = new ArrayList<>();

// Payment 양방향 매핑
@OneToMany(mappedBy = "member", cascade = CascadeType.ALL)
@OneToMany(mappedBy = "member", cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH})
private List<Payment> paymentList = new ArrayList<>();

public void setProfileImg(ProfileImg profileImg) {
this.profileImg = profileImg;
}

public void setMemberStatus(MemberStatus memberStatus){
public void setMemberStatus(MemberStatus memberStatus, LocalDateTime time){
this.memberStatus = memberStatus;
this.deletedAt = time;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,4 @@ public class WithdrawReason extends BaseDateTimeEntity {
@Column(nullable = false)
private Integer reason; // 탈퇴 사유


@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
private Member member;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Optional;

public interface MemberRepository extends JpaRepository<Member, Long> {
Expand Down Expand Up @@ -79,10 +81,5 @@ public interface MemberRepository extends JpaRepository<Member, Long> {
@Query("UPDATE Member m SET m.infoTerm = :infoTerm WHERE m.id = :memberId")
void changeInfoTerm(Long memberId, Boolean infoTerm);

@Transactional
@Modifying(clearAutomatically = true)
@Query("UPDATE Member m SET m.name = :name, m.email = :email, m.phone = :phone, m.birthday = :birthday, m.gender = :gender, m.password = :password, m.nickname = :nickname WHERE m.id = :memberId")
void reregister(Long memberId, String nickname, String name, String password, String email, Date birthday
,Gender gender, String phone);

List<Member> findAllByDeletedAtBefore(LocalDateTime dateTime);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
import java.util.Optional;

public interface WithdrawReasonRepository extends JpaRepository<WithdrawReason, Long> {
Optional<WithdrawReason> findByMember_Id(Long id);

}
Loading
Loading