From db7844431913486803cbeff534758de1b537fa34 Mon Sep 17 00:00:00 2001 From: joon Date: Thu, 11 Apr 2024 20:39:12 +0900 Subject: [PATCH 1/3] =?UTF-8?q?:recycle:=20refactor:=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EA=B8=B0=EB=8A=A5=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EC=82=AC=ED=95=AD=20=EC=88=98=EC=A0=95(#171)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../converter/member/MemberConverter.java | 61 +--------------- .../umc/TheGoods/domain/item/Category.java | 3 - .../domain/mapping/member/MemberCategory.java | 37 ---------- .../domain/mapping/member/MemberTag.java | 34 --------- .../umc/TheGoods/domain/member/Member.java | 7 -- .../member/MemberCategoryRepository.java | 14 ---- .../member/MemberTagRepository.java | 14 ---- .../MemberService/MemberCommandService.java | 2 - .../MemberCommandServiceImpl.java | 72 ------------------- .../MemberService/MemberQueryService.java | 3 - .../MemberService/MemberQueryServiceImpl.java | 24 ------- .../com/umc/TheGoods/test/TestController.java | 6 +- .../com/umc/TheGoods/test/TestConverter.java | 1 - .../test/service/TestCommandServiceImpl.java | 12 ---- .../web/controller/MyPageController.java | 29 -------- .../web/dto/member/MemberRequestDTO.java | 12 +--- 16 files changed, 6 insertions(+), 325 deletions(-) delete mode 100644 src/main/java/com/umc/TheGoods/domain/mapping/member/MemberCategory.java delete mode 100644 src/main/java/com/umc/TheGoods/domain/mapping/member/MemberTag.java delete mode 100644 src/main/java/com/umc/TheGoods/repository/member/MemberCategoryRepository.java delete mode 100644 src/main/java/com/umc/TheGoods/repository/member/MemberTagRepository.java diff --git a/src/main/java/com/umc/TheGoods/converter/member/MemberConverter.java b/src/main/java/com/umc/TheGoods/converter/member/MemberConverter.java index a5d0a030..50e86342 100644 --- a/src/main/java/com/umc/TheGoods/converter/member/MemberConverter.java +++ b/src/main/java/com/umc/TheGoods/converter/member/MemberConverter.java @@ -8,8 +8,6 @@ import com.umc.TheGoods.domain.item.ItemOption; import com.umc.TheGoods.domain.item.Tag; import com.umc.TheGoods.domain.mapping.Tag.CategoryTag; -import com.umc.TheGoods.domain.mapping.member.MemberCategory; -import com.umc.TheGoods.domain.mapping.member.MemberTag; import com.umc.TheGoods.domain.mapping.member.MemberTerm; import com.umc.TheGoods.domain.member.Auth; import com.umc.TheGoods.domain.member.Member; @@ -49,13 +47,13 @@ public static MemberResponseDTO.JoinResultDTO toJoinResultDTO(Member member) { public static Member toMember(MemberRequestDTO.JoinDTO request, BCryptPasswordEncoder encoder) { return Member.builder() .nickname(request.getNickname()) + .name(request.getName()) .password(encoder.encode(request.getPassword())) .email(request.getEmail()) .birthday(request.getBirthday()) .gender(request.getGender()) .phone(request.getPhone()) .memberRole(MemberRole.BUYER) - .memberCategoryList(new ArrayList<>()) .memberTermList(new ArrayList<>()) .itemList(new ArrayList<>()) .build(); @@ -78,7 +76,6 @@ public static MemberResponseDTO.NewTokenDTO toNewTokenDTO(String accessToken, St public static Member toUpdatePassword(Member member, String password) { List memberTermList = member.getMemberTermList(); - List memberCategoryList = member.getMemberCategoryList(); List memberItemList = member.getItemList(); if (memberItemList == null) { memberItemList = new ArrayList<>(); @@ -88,11 +85,9 @@ public static Member toUpdatePassword(Member member, String password) { memberTermList = new ArrayList<>(); } - if (memberCategoryList == null) { - memberCategoryList = new ArrayList<>(); - } return Member.builder() .id(member.getId()) + .name(member.getName()) .nickname(member.getNickname()) .password(password) .email(member.getEmail()) @@ -100,33 +95,11 @@ public static Member toUpdatePassword(Member member, String password) { .gender(member.getGender()) .phone(member.getPhone()) .memberRole(MemberRole.BUYER) - .memberCategoryList(memberCategoryList) .memberTermList(memberTermList) .itemList(memberItemList) .build(); } - public static List toMemberCategoryList(List categoryList) { - - - return categoryList.stream() - .map(category -> - MemberCategory.builder() - .category(category) - .build() - ).collect(Collectors.toList()); - - } - - public static List toMemberTagList(List tagList){ - - return tagList.stream().map(tag -> - MemberTag.builder() - .tag(tag) - .build() - ).collect(Collectors.toList()); - - } public static List toMemberTermList(HashMap termList) { @@ -308,7 +281,6 @@ public static MemberResponseDTO.PasswordUpdateResultDTO toPasswordUpdateResultDT public static Member toUpdateProfile(Member member, ProfileImg profileImg, String nickname, String introduce) { List memberTermList = member.getMemberTermList(); - List memberCategoryList = member.getMemberCategoryList(); List memberItemList = member.getItemList(); if (memberItemList == null) { memberItemList = new ArrayList<>(); @@ -318,11 +290,9 @@ public static Member toUpdateProfile(Member member, ProfileImg profileImg, Strin memberTermList = new ArrayList<>(); } - if (memberCategoryList == null) { - memberCategoryList = new ArrayList<>(); - } return Member.builder() .id(member.getId()) + .name(member.getName()) .nickname(nickname) .password(member.getPassword()) .email(member.getEmail()) @@ -330,7 +300,6 @@ public static Member toUpdateProfile(Member member, ProfileImg profileImg, Strin .gender(member.getGender()) .phone(member.getPhone()) .memberRole(MemberRole.BUYER) - .memberCategoryList(memberCategoryList) .memberTermList(memberTermList) .itemList(memberItemList) .introduce(introduce) @@ -442,30 +411,6 @@ public static List toGetAddressDTO(List
a return addressList; } - public static MemberResponseDTO.CustomInfoDTO toCustomInfoDTO(List categoryList, List tagList){ - List category = categoryList.stream().map( - c ->{ - return MemberResponseDTO.CategoryDTO - .builder() - .id(c.getId()) - .name(c.getName()) - .build();} - ).collect(Collectors.toList()); - - List tag = tagList.stream().map( - t ->{ - return MemberResponseDTO.TagDTO.builder() - .id(t.getId()) - .name(t.getName()) - .build(); - } - ).collect(Collectors.toList()); - - return MemberResponseDTO.CustomInfoDTO.builder() - .categoryList(category) - .tagList(tag) - .build(); - } public static Declaration toDeclaration(Member member, MemberRequestDTO.DeclareDTO request){ diff --git a/src/main/java/com/umc/TheGoods/domain/item/Category.java b/src/main/java/com/umc/TheGoods/domain/item/Category.java index 3550fa94..3002c225 100644 --- a/src/main/java/com/umc/TheGoods/domain/item/Category.java +++ b/src/main/java/com/umc/TheGoods/domain/item/Category.java @@ -2,7 +2,6 @@ import com.umc.TheGoods.domain.common.BaseDateTimeEntity; import com.umc.TheGoods.domain.mapping.Tag.CategoryTag; -import com.umc.TheGoods.domain.mapping.member.MemberCategory; import lombok.*; import javax.persistence.*; @@ -24,8 +23,6 @@ public class Category extends BaseDateTimeEntity { @Column(nullable = false, length = 30) private String name; - @OneToMany(mappedBy = "category", cascade = CascadeType.ALL) - private List memberCategoryList = new ArrayList<>(); @OneToMany(mappedBy = "category", cascade = CascadeType.ALL) private List categoryTagList = new ArrayList<>(); diff --git a/src/main/java/com/umc/TheGoods/domain/mapping/member/MemberCategory.java b/src/main/java/com/umc/TheGoods/domain/mapping/member/MemberCategory.java deleted file mode 100644 index 7a085406..00000000 --- a/src/main/java/com/umc/TheGoods/domain/mapping/member/MemberCategory.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.umc.TheGoods.domain.mapping.member; - -import com.umc.TheGoods.domain.common.BaseDateTimeEntity; -import com.umc.TheGoods.domain.item.Category; -import com.umc.TheGoods.domain.member.Member; -import com.umc.TheGoods.web.dto.member.MemberResponseDTO; -import lombok.*; - -import javax.persistence.*; - -@Entity -@Getter -@Builder -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor -public class MemberCategory extends BaseDateTimeEntity { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "member_category_id") - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "member_id") - private Member member; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "category_id") - private Category category; - - public void setMember(Member member) { - this.member = member; - member.getMemberCategoryList().add(this); // Add the current MemberCategory to the new Member - - } - -} diff --git a/src/main/java/com/umc/TheGoods/domain/mapping/member/MemberTag.java b/src/main/java/com/umc/TheGoods/domain/mapping/member/MemberTag.java deleted file mode 100644 index 5796a5c3..00000000 --- a/src/main/java/com/umc/TheGoods/domain/mapping/member/MemberTag.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.umc.TheGoods.domain.mapping.member; - -import com.umc.TheGoods.domain.item.Category; -import com.umc.TheGoods.domain.item.Tag; -import com.umc.TheGoods.domain.member.Member; -import lombok.*; - -import javax.persistence.*; - -@Entity -@Getter -@Builder -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor -public class MemberTag { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "member_tag_id") - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "member_id") - private Member member; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "tag_id") - private Tag tag; - - public void setMember(Member member) { - this.member = member; - member.getMemberTagList().add(this); - - } -} diff --git a/src/main/java/com/umc/TheGoods/domain/member/Member.java b/src/main/java/com/umc/TheGoods/domain/member/Member.java index 88316a3c..a4106bfb 100644 --- a/src/main/java/com/umc/TheGoods/domain/member/Member.java +++ b/src/main/java/com/umc/TheGoods/domain/member/Member.java @@ -16,8 +16,6 @@ import com.umc.TheGoods.domain.mapping.ViewSearch.TagSearch; import com.umc.TheGoods.domain.mapping.comment.CommentLike; import com.umc.TheGoods.domain.mapping.comment.CommentMention; -import com.umc.TheGoods.domain.mapping.member.MemberCategory; -import com.umc.TheGoods.domain.mapping.member.MemberTag; import com.umc.TheGoods.domain.mapping.member.MemberTerm; import com.umc.TheGoods.domain.mapping.post.PostLike; import com.umc.TheGoods.domain.mypage.*; @@ -114,11 +112,6 @@ public class Member extends BaseDateTimeEntity { @ColumnDefault("false") private Boolean infoTerm; - @OneToMany(mappedBy = "member", cascade = CascadeType.ALL) - private List memberCategoryList = new ArrayList<>(); - - @OneToMany(mappedBy = "member", cascade = CascadeType.ALL) - private List memberTagList = new ArrayList<>(); @OneToMany(mappedBy = "member", cascade = CascadeType.ALL) private List memberTermList = new ArrayList<>(); diff --git a/src/main/java/com/umc/TheGoods/repository/member/MemberCategoryRepository.java b/src/main/java/com/umc/TheGoods/repository/member/MemberCategoryRepository.java deleted file mode 100644 index 30c61089..00000000 --- a/src/main/java/com/umc/TheGoods/repository/member/MemberCategoryRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.umc.TheGoods.repository.member; - -import com.umc.TheGoods.domain.mapping.member.MemberCategory; -import com.umc.TheGoods.domain.member.Member; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.List; - -public interface MemberCategoryRepository extends JpaRepository { - - List findAllByMember(Member member); - - void deleteByMember(Member member); -} diff --git a/src/main/java/com/umc/TheGoods/repository/member/MemberTagRepository.java b/src/main/java/com/umc/TheGoods/repository/member/MemberTagRepository.java deleted file mode 100644 index d8c318d4..00000000 --- a/src/main/java/com/umc/TheGoods/repository/member/MemberTagRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.umc.TheGoods.repository.member; - -import com.umc.TheGoods.domain.mapping.member.MemberCategory; -import com.umc.TheGoods.domain.mapping.member.MemberTag; -import com.umc.TheGoods.domain.member.Member; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.List; - -public interface MemberTagRepository extends JpaRepository { - List findAllByMember(Member member); - - void deleteByMember(Member member); -} diff --git a/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandService.java b/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandService.java index f98573c0..d557d7cd 100644 --- a/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandService.java +++ b/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandService.java @@ -48,7 +48,6 @@ public interface MemberCommandService { Member profileModify(MultipartFile profile, String nickname, String introduce, Member member); - Member updateRole(Member member); void updatePhoneName(MemberRequestDTO.PhoneNameUpdateDTO request, Member member); @@ -68,7 +67,6 @@ public interface MemberCommandService { void deleteAddress(Member member, Long addressId); - void updateCustomInfo(Long memberId, MemberRequestDTO.CustomInfoDTO request); void postDeclare(Member member, MemberRequestDTO.DeclareDTO request); diff --git a/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandServiceImpl.java b/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandServiceImpl.java index 99219a1f..aaa93c7f 100644 --- a/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandServiceImpl.java +++ b/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandServiceImpl.java @@ -15,9 +15,6 @@ import com.umc.TheGoods.domain.item.Category; import com.umc.TheGoods.domain.item.Item; import com.umc.TheGoods.domain.item.Tag; - -import com.umc.TheGoods.domain.mapping.member.MemberCategory; -import com.umc.TheGoods.domain.mapping.member.MemberTag; import com.umc.TheGoods.domain.mapping.member.MemberTerm; import com.umc.TheGoods.domain.member.Auth; import com.umc.TheGoods.domain.member.Member; @@ -73,8 +70,6 @@ public class MemberCommandServiceImpl implements MemberCommandService { private final RedisService redisService; private final WithdrawReasonRepository withdrawReasonRepository; private final TagRepository tagRepository; - private final MemberTagRepository memberTagRepository; - private final MemberCategoryRepository memberCategoryRepository; private final DeclarationRepository declarationRepository; private final ContactTimeRepository contactTimeRepository; private final ItemRepository itemRepository; @@ -118,18 +113,6 @@ public Member join(MemberRequestDTO.JoinDTO request) { //저장 Member member = MemberConverter.toMember(request, encoder); - // 카테고리 저장 로직 - List categoryList = request.getMemberCategory().stream() - .map(category -> { - return categoryRepository.findById(category).orElseThrow(() -> new MemberHandler(ErrorStatus.CATEGORY_NOT_FOUND)); - }).collect(Collectors.toList()); - - List memberCategoryList = MemberConverter.toMemberCategoryList(categoryList); - - memberCategoryList.forEach(memberCategory -> { - memberCategory.setMember(member); - }); - // 약관동의 저장 로직 HashMap termMap = new HashMap<>(); for (int i = 0; i < request.getMemberTerm().size(); i++) { @@ -588,20 +571,6 @@ public Member profileModify(MultipartFile profile, String nickname, String intro return member; } - @Override - public Member updateRole(Member member) { - - if (member.getMemberRole() == MemberRole.BUYER) { - - memberRepository.changeMemberRole(member.getId(), MemberRole.SELLER); - - return member; - } else { - memberRepository.changeMemberRole(member.getId(), MemberRole.BUYER); - return member; - } - - } @Override public void updatePhoneName(MemberRequestDTO.PhoneNameUpdateDTO request, Member member) { @@ -758,49 +727,8 @@ public void updateNotification(Member member, Integer type) { } - @Transactional - @Override - public void updateCustomInfo(Long memberId, MemberRequestDTO.CustomInfoDTO request) { - //정보 동의 약관 변경 - memberRepository.changeInfoTerm(memberId,request.getInfoTerm()); - Member member = memberRepository.findById(memberId).orElseThrow(()-> new MemberHandler(ErrorStatus.MEMBER_NOT_FOUND)); - - // 카테고리 저장 로직 - // request에서 받아온 카테고리 List 형태로 변환 - List categoryList = request.getCategoryList().stream() - .map(category -> { - return categoryRepository.findById(category).orElseThrow(() -> new MemberHandler(ErrorStatus.CATEGORY_NOT_FOUND)); - }).collect(Collectors.toList()); - //Member와 Category는 n:m관계여서 Category List로 MemberCategory Entity List로 변환 - List memberCategoryList = MemberConverter.toMemberCategoryList(categoryList); - - //기존에 있던 해당 Member의 MemberCategory 비우기 - memberCategoryRepository.deleteByMember(member); - member.getMemberCategoryList().clear(); - - //memberCategory에 member 매핑해주기 - memberCategoryList.forEach(memberCategory -> { - memberCategory.setMember(member); - }); - - //memberTagList도 memberCategoryList와 로직은 동일합니다 - List tagList = request.getTagList().stream() - .map(tag ->{ - return tagRepository.findById(tag).orElseThrow(() -> new MemberHandler(ErrorStatus.TAG_NOT_FOUND)); - }).collect(Collectors.toList()); - - List memberTagList = MemberConverter.toMemberTagList(tagList); - - memberTagRepository.deleteByMember(member); - member.getMemberTagList().clear(); - memberTagList.forEach(memberTag -> { - memberTag.setMember(member); - }); - memberRepository.save(member); - - } @Override public void postDeclare(Member member, MemberRequestDTO.DeclareDTO request) { diff --git a/src/main/java/com/umc/TheGoods/service/MemberService/MemberQueryService.java b/src/main/java/com/umc/TheGoods/service/MemberService/MemberQueryService.java index b7403f35..76b0d420 100644 --- a/src/main/java/com/umc/TheGoods/service/MemberService/MemberQueryService.java +++ b/src/main/java/com/umc/TheGoods/service/MemberService/MemberQueryService.java @@ -26,9 +26,6 @@ public interface MemberQueryService { List findAccountById(Long id); - List findCategoryByMember(Member member); - - List findTagByMember(Member member); List findDeclarationByMember(Member member); } diff --git a/src/main/java/com/umc/TheGoods/service/MemberService/MemberQueryServiceImpl.java b/src/main/java/com/umc/TheGoods/service/MemberService/MemberQueryServiceImpl.java index 001613ef..ce0c47d8 100644 --- a/src/main/java/com/umc/TheGoods/service/MemberService/MemberQueryServiceImpl.java +++ b/src/main/java/com/umc/TheGoods/service/MemberService/MemberQueryServiceImpl.java @@ -6,8 +6,6 @@ import com.umc.TheGoods.domain.item.Category; import com.umc.TheGoods.domain.item.Tag; import com.umc.TheGoods.domain.mapping.Tag.CategoryTag; -import com.umc.TheGoods.domain.mapping.member.MemberCategory; -import com.umc.TheGoods.domain.mapping.member.MemberTag; import com.umc.TheGoods.domain.member.Member; import com.umc.TheGoods.domain.mypage.Account; import com.umc.TheGoods.domain.mypage.Address; @@ -36,8 +34,6 @@ public class MemberQueryServiceImpl implements MemberQueryService { private final AccountRepository accountRepository; private final CategoryRepository categoryRepository; - private final MemberCategoryRepository memberCategoryRepository; - private final MemberTagRepository memberTagRepository; private final TagRepository tagRepository; private final DeclarationRepository declarationRepository; @@ -81,29 +77,9 @@ public List findAccountById(Long id){ return accountRepository.findAllByMember_Id(id); } - @Override - public List findCategoryByMember(Member member) { - - List memberCategoryList = memberCategoryRepository.findAllByMember(member); - - List categoryList = memberCategoryList.stream().map(m ->{ - return categoryRepository.findById(m.getCategory().getId()).orElseThrow(() -> new MemberHandler(ErrorStatus.CATEGORY_NOT_FOUND)); - }).collect(Collectors.toList()); - - return categoryList; - } - - @Override - public List findTagByMember(Member member) { - List memberTagList = memberTagRepository.findAllByMember(member); - List tagList = memberTagList.stream().map(t ->{ - return tagRepository.findById(t.getTag().getId()).orElseThrow(() -> new MemberHandler(ErrorStatus.TAG_NOT_FOUND)); - }).collect(Collectors.toList()); - return tagList; - } @Override public List findDeclarationByMember(Member member) { diff --git a/src/main/java/com/umc/TheGoods/test/TestController.java b/src/main/java/com/umc/TheGoods/test/TestController.java index 076b9a99..aff155d6 100644 --- a/src/main/java/com/umc/TheGoods/test/TestController.java +++ b/src/main/java/com/umc/TheGoods/test/TestController.java @@ -96,11 +96,9 @@ public String setTestData() { Date date = new Date(); List termAgreeList = new ArrayList<>(); termAgreeList.add(true); - List memberCategoryList = new ArrayList<>(); - memberCategoryList.add(1L); - MemberRequestDTO.JoinDTO joinBuyerDTO = new MemberRequestDTO.JoinDTO("구매자 테스트 계정", "12345678", "test@gmail.com", date, "01012345678", Gender.MALE, termAgreeList, memberCategoryList); - MemberRequestDTO.JoinDTO noLoginUserDTO = new MemberRequestDTO.JoinDTO("no_login_user", "12345678", "nologinuser@gmail.com", date, "01087654321", Gender.MALE, termAgreeList, memberCategoryList); + MemberRequestDTO.JoinDTO joinBuyerDTO = new MemberRequestDTO.JoinDTO("구매자 테스트 계정","테스트", "12345678", "test@gmail.com", date, "01012345678", Gender.MALE, termAgreeList); + MemberRequestDTO.JoinDTO noLoginUserDTO = new MemberRequestDTO.JoinDTO("no_login_user","비회원", "12345678", "nologinuser@gmail.com", date, "01087654321", Gender.MALE, termAgreeList); memberCommandService.join(joinBuyerDTO); diff --git a/src/main/java/com/umc/TheGoods/test/TestConverter.java b/src/main/java/com/umc/TheGoods/test/TestConverter.java index 16695d54..19a28c62 100644 --- a/src/main/java/com/umc/TheGoods/test/TestConverter.java +++ b/src/main/java/com/umc/TheGoods/test/TestConverter.java @@ -31,7 +31,6 @@ public static Member toTestMember(TestRequestDTO.setMemberDTO request, BCryptPas .gender(Gender.FEMALE) .phone("01012345678") .memberRole(MemberRole.SELLER) - .memberCategoryList(new ArrayList<>()) .memberTermList(new ArrayList<>()) .itemList(new ArrayList<>()) .build(); diff --git a/src/main/java/com/umc/TheGoods/test/service/TestCommandServiceImpl.java b/src/main/java/com/umc/TheGoods/test/service/TestCommandServiceImpl.java index 215002f8..2b1a04ab 100644 --- a/src/main/java/com/umc/TheGoods/test/service/TestCommandServiceImpl.java +++ b/src/main/java/com/umc/TheGoods/test/service/TestCommandServiceImpl.java @@ -12,7 +12,6 @@ import com.umc.TheGoods.domain.item.Tag; import com.umc.TheGoods.domain.mapping.Tag.CategoryTag; import com.umc.TheGoods.domain.mapping.Tag.ItemTag; -import com.umc.TheGoods.domain.mapping.member.MemberCategory; import com.umc.TheGoods.domain.mapping.member.MemberTerm; import com.umc.TheGoods.domain.member.Member; import com.umc.TheGoods.domain.member.Term; @@ -69,17 +68,6 @@ public Member addMember(TestRequestDTO.setMemberDTO request, MultipartFile multi //저장 Member member = TestConverter.toTestMember(request, encoder); - // 카테고리 저장 로직 - List categoryList = request.getMemberCategory().stream() - .map(category -> { - return categoryRepository.findById(category).orElseThrow(() -> new MemberHandler(ErrorStatus.CATEGORY_NOT_FOUND)); - }).collect(Collectors.toList()); - - List memberCategoryList = MemberConverter.toMemberCategoryList(categoryList); - - memberCategoryList.forEach(memberCategory -> { - memberCategory.setMember(member); - }); // 약관동의 저장 로직 HashMap termMap = new HashMap<>(); diff --git a/src/main/java/com/umc/TheGoods/web/controller/MyPageController.java b/src/main/java/com/umc/TheGoods/web/controller/MyPageController.java index eb10f66a..3a756391 100644 --- a/src/main/java/com/umc/TheGoods/web/controller/MyPageController.java +++ b/src/main/java/com/umc/TheGoods/web/controller/MyPageController.java @@ -61,18 +61,7 @@ public ApiResponse profileModify(@Requ } - @PutMapping(value = "/role/update") - @Operation(summary = "사용자 역할 전환 api", description = "BUYER은 SELLER로 SELLER는 BUYER로 역할 변경") - public ApiResponse updateRole(Authentication authentication) { - Member member = memberQueryService.findMemberById(Long.valueOf(authentication.getName().toString())).orElseThrow(() -> new MemberHandler(ErrorStatus.MEMBER_NOT_FOUND)); - - Member update = memberCommandService.updateRole(member); - - - - return ApiResponse.onSuccess(MemberConverter.toUpdateRole(update)); - } @PostMapping(value = "/address") @@ -220,26 +209,8 @@ public ApiResponse updateNotification(Authentication authentication, @Request return ApiResponse.of(SuccessStatus.MEMBER_NOTIFICATION_UPDATE,null); } - @PostMapping(value = "/custom/info") - @Operation(summary = "mypage 고객 맞춤 정보 변경 api", description = "request로 카테고리와 태그, 정보이용 동의를 보내면 카테고리와 태그 정보 수정됩니다.") - public ApiResponse updateCustomInfo(Authentication authentication, - @RequestBody MemberRequestDTO.CustomInfoDTO request){ - Member member = memberQueryService.findMemberById(Long.valueOf(authentication.getName().toString())).orElseThrow(() -> new MemberHandler(ErrorStatus.MEMBER_NOT_FOUND)); - - //회원 맞춤 정보 update하는 로직 - memberCommandService.updateCustomInfo(member.getId(),request); - return ApiResponse.of(SuccessStatus.MEMBER_CUSTOM_INFO_UPDATE,null); - } - @GetMapping(value = "/custom/info") - @Operation(summary = "mypage 고객 맞춤 정보 조회 api",description = "회원의 카테고리와 태그 정보 가져올 수 있습니다.") - public ApiResponse getCustomInfo(Authentication authentication){ - Member member = memberQueryService.findMemberById(Long.valueOf(authentication.getName().toString())).orElseThrow(() -> new MemberHandler(ErrorStatus.MEMBER_NOT_FOUND)); - List categoryList = memberQueryService.findCategoryByMember(member); - List tagList = memberQueryService.findTagByMember(member); - return ApiResponse.onSuccess(MemberConverter.toCustomInfoDTO(categoryList, tagList)); - } /**\ * 신고 기능 diff --git a/src/main/java/com/umc/TheGoods/web/dto/member/MemberRequestDTO.java b/src/main/java/com/umc/TheGoods/web/dto/member/MemberRequestDTO.java index 2bc048f0..0e8059f3 100644 --- a/src/main/java/com/umc/TheGoods/web/dto/member/MemberRequestDTO.java +++ b/src/main/java/com/umc/TheGoods/web/dto/member/MemberRequestDTO.java @@ -19,25 +19,15 @@ public class MemberRequestDTO { @AllArgsConstructor public static class JoinDTO { private String nickname; + private String name; private String password; private String email; private Date birthday; private String phone; private Gender gender; private List memberTerm;//약관 동의 - @ExistCategory - private List memberCategory; - } - @Getter - @Setter - @NoArgsConstructor - @AllArgsConstructor - public static class CustomInfoDTO{ - private List TagList; - private List CategoryList; - private Boolean InfoTerm; } From bd450e2a1ad4bc280cf017c2c72a9d8034df831a Mon Sep 17 00:00:00 2001 From: joon Date: Sun, 14 Apr 2024 17:37:00 +0900 Subject: [PATCH 2/3] =?UTF-8?q?:sparkles:=20Feat:=20=EC=97=B0=EB=9D=BD=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5=20=EC=8B=9C=EA=B0=84=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?api=20=EA=B5=AC=ED=98=84(#171)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TheGoods/apiPayload/code/status/ErrorStatus.java | 9 +++++---- .../umc/TheGoods/converter/member/MemberConverter.java | 8 ++++++++ .../service/MemberService/MemberCommandService.java | 3 +++ .../MemberService/MemberCommandServiceImpl.java | 7 +++++++ .../umc/TheGoods/web/controller/MyPageController.java | 10 ++++++++++ .../umc/TheGoods/web/dto/member/MemberResponseDTO.java | 9 +++++++++ 6 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/umc/TheGoods/apiPayload/code/status/ErrorStatus.java b/src/main/java/com/umc/TheGoods/apiPayload/code/status/ErrorStatus.java index 875ad2ef..3a53b753 100644 --- a/src/main/java/com/umc/TheGoods/apiPayload/code/status/ErrorStatus.java +++ b/src/main/java/com/umc/TheGoods/apiPayload/code/status/ErrorStatus.java @@ -50,15 +50,16 @@ public enum ErrorStatus implements BaseErrorCode { // Member MEMBER_NICKNAME_DUPLICATED(HttpStatus.BAD_REQUEST, "MEMBER4001", "중복된 닉네임 입니다."), MEMBER_PASSWORD_ERROR(HttpStatus.BAD_REQUEST, "MEMBER4002", "비밀번호가 잘못되었습니다."), - MEMBER_EMAIL_NOT_FOUND(HttpStatus.BAD_REQUEST, "MEMBER4003", "이메일이 존재하지 않습니다."), + MEMBER_EMAIL_NOT_FOUND(HttpStatus.NOT_FOUND, "MEMBER4003", "이메일이 존재하지 않습니다."), MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "MEMBER4004", "해당 회원을 찾을 수 없습니다."), MEMBER_PHONE_AUTH_ERROR(HttpStatus.BAD_REQUEST, "MEMBER4005", "유효하지 않는 번호입니다."), MEMBER_EMAIL_AUTH_ERROR(HttpStatus.BAD_REQUEST, "MEMBER4006", "유효하지 않는 이메일입니다."), MEMBER_PASSWORD_NOT_EQUAL(HttpStatus.BAD_REQUEST, "MEMBER4007", "비밀번호가 일치하지 않습니다."), - MEMBER_ACCOUNT_NOT_FOUND(HttpStatus.BAD_REQUEST, "MEMBER4008", "계좌가 존재하지 않습니다"), - MEMBER_ADDRESS_NOT_FOUND(HttpStatus.BAD_REQUEST, "MEMBER4009", "주소가 존재하지 않습니다"), + MEMBER_ACCOUNT_NOT_FOUND(HttpStatus.NOT_FOUND, "MEMBER4008", "계좌가 존재하지 않습니다"), + MEMBER_ADDRESS_NOT_FOUND(HttpStatus.NOT_FOUND, "MEMBER4009", "주소가 존재하지 않습니다"), MEMBER_INACTIVATE(HttpStatus.NOT_ACCEPTABLE, "MEMBER40010", "탈퇴한 회원입니다."), - MEMBER_NOT_OWNER(HttpStatus.NOT_ACCEPTABLE, "MEMBER40010", "해당 회원이 아닙니다."), + MEMBER_NOT_OWNER(HttpStatus.NOT_ACCEPTABLE, "MEMBER40011", "해당 회원이 아닙니다."), + MEMBER_CONTACT_NOT_FOUND(HttpStatus.NOT_FOUND,"MEMBER40012", "연락 가능 시간을 조회할 수 없습니다."), //JWT diff --git a/src/main/java/com/umc/TheGoods/converter/member/MemberConverter.java b/src/main/java/com/umc/TheGoods/converter/member/MemberConverter.java index 50e86342..3dedcf68 100644 --- a/src/main/java/com/umc/TheGoods/converter/member/MemberConverter.java +++ b/src/main/java/com/umc/TheGoods/converter/member/MemberConverter.java @@ -464,4 +464,12 @@ public static ContactTime toContactTime(Member member, MemberRequestDTO.ContactD .build(); } + public static MemberResponseDTO.ContactResponseDTO toContactDTO(ContactTime contactTime){ + return MemberResponseDTO.ContactResponseDTO.builder() + .start(contactTime.getStartTime()) + .end(contactTime.getEndTime()) + .allTime(contactTime.getAllTime()) + .build(); + } + } diff --git a/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandService.java b/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandService.java index d557d7cd..4926fc78 100644 --- a/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandService.java +++ b/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandService.java @@ -6,6 +6,7 @@ import com.umc.TheGoods.domain.member.Member; 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.redis.domain.RefreshToken; import com.umc.TheGoods.web.dto.member.MemberRequestDTO; import com.umc.TheGoods.web.dto.member.MemberResponseDTO; @@ -74,4 +75,6 @@ public interface MemberCommandService { void postContact(Long memberId, MemberRequestDTO.ContactDTO request); + ContactTime getContact(Member member); + } diff --git a/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandServiceImpl.java b/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandServiceImpl.java index aaa93c7f..4d016a5d 100644 --- a/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandServiceImpl.java +++ b/src/main/java/com/umc/TheGoods/service/MemberService/MemberCommandServiceImpl.java @@ -759,5 +759,12 @@ public void postContact(Long memberId, MemberRequestDTO.ContactDTO request){ contactTimeRepository.save(contactTime); } + + @Override + public ContactTime getContact(Member member) { + ContactTime contactTime = contactTimeRepository.findById(member.getId()).orElseThrow(() -> new MemberHandler(ErrorStatus.MEMBER_CONTACT_NOT_FOUND)); + + return contactTime; + } } diff --git a/src/main/java/com/umc/TheGoods/web/controller/MyPageController.java b/src/main/java/com/umc/TheGoods/web/controller/MyPageController.java index 3a756391..d9bfe986 100644 --- a/src/main/java/com/umc/TheGoods/web/controller/MyPageController.java +++ b/src/main/java/com/umc/TheGoods/web/controller/MyPageController.java @@ -13,6 +13,7 @@ import com.umc.TheGoods.domain.member.Member; 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.service.MemberService.MemberCommandService; import com.umc.TheGoods.service.MemberService.MemberQueryService; @@ -264,6 +265,15 @@ public ApiResponse postContact(Authentication authentication, return ApiResponse.of(SuccessStatus.MEMBER_CONTACT_SUCCESS,null); } + @GetMapping(value = "/contact") + @Operation(summary = "mypage 연락가능 시간 조회 api") + public ApiResponse getContact(Authentication authentication){ + + Member member = memberQueryService.findMemberById(Long.valueOf(authentication.getName().toString())).orElseThrow(() -> new MemberHandler(ErrorStatus.MEMBER_NOT_FOUND)); + ContactTime contactTime = memberCommandService.getContact(member); + return ApiResponse.onSuccess(MemberConverter.toContactDTO(contactTime)); + } + @GetMapping(value = "/profile") @Operation(summary = "프로필 조회 api", description = "프로필이미지, 닉네임, 주소, 계좌, 팔로잉 수, 찜 수를 조회할 수 있습니다.") public ApiResponse getProfile(Authentication authentication) { diff --git a/src/main/java/com/umc/TheGoods/web/dto/member/MemberResponseDTO.java b/src/main/java/com/umc/TheGoods/web/dto/member/MemberResponseDTO.java index cfa981cd..242f99d2 100644 --- a/src/main/java/com/umc/TheGoods/web/dto/member/MemberResponseDTO.java +++ b/src/main/java/com/umc/TheGoods/web/dto/member/MemberResponseDTO.java @@ -322,6 +322,15 @@ public static class DeclareResponseDTO{ List declareDTOList; } + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class ContactResponseDTO{ + Integer start; + Integer end; + Boolean allTime; + } From 18b2a03c1be6eee74e173ba64baa1040175693f1 Mon Sep 17 00:00:00 2001 From: joon Date: Sun, 14 Apr 2024 17:37:25 +0900 Subject: [PATCH 3/3] =?UTF-8?q?:recycle:=20Refactor:=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20validation=20=EC=B6=94=EA=B0=80(#171)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TheGoods/web/dto/member/MemberRequestDTO.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/umc/TheGoods/web/dto/member/MemberRequestDTO.java b/src/main/java/com/umc/TheGoods/web/dto/member/MemberRequestDTO.java index 0e8059f3..d1259595 100644 --- a/src/main/java/com/umc/TheGoods/web/dto/member/MemberRequestDTO.java +++ b/src/main/java/com/umc/TheGoods/web/dto/member/MemberRequestDTO.java @@ -9,6 +9,9 @@ import javax.persistence.Column; import javax.persistence.criteria.CriteriaBuilder; +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; import java.util.Date; import java.util.List; @@ -18,12 +21,21 @@ public class MemberRequestDTO { @NoArgsConstructor @AllArgsConstructor public static class JoinDTO { + @NotBlank(message = "닉네임을 입력해주세요") private String nickname; + @NotBlank(message = "이름을 입력해주세요") private String name; + @NotBlank(message = "비밀번호를 입력해주세요") + @Pattern(regexp = "(?=.*[0-9])(?=.*[a-zA-Z])(?=.*\\W)(?=\\S+$).{8,16}", message = "비밀번호는 8~16자 영문, 숫자, 특수문자를 사용하세요.") private String password; + @NotBlank(message = "이메일을 입력해주세요") + @Email(message = "이메일 형식이 올바르지 않습니다.") private String email; + @NotBlank(message = "생일을 입력해주세요") private Date birthday; + @NotBlank(message = "휴대폰 번호를 입력해주세요") private String phone; + @NotBlank(message = "성별을 입력해주세요") private Gender gender; private List memberTerm;//약관 동의