From 2aeb07ecfc341be2331d946c15be8b2221de0eaa Mon Sep 17 00:00:00 2001 From: zzzzseong Date: Tue, 23 Jan 2024 21:04:18 +0900 Subject: [PATCH 1/6] =?UTF-8?q?refactor(Member):=20MemberService=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EB=B0=9C=ED=96=89=20=EB=B0=8F=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=ED=95=A8=EC=88=98=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/service/MemberServiceImplV2.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java b/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java index a7b6c589..400a4185 100644 --- a/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java +++ b/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java @@ -106,14 +106,7 @@ public void login(MemberRequestDto request, HttpServletResponse response) { Member member = ((MemberDetailsImpl) authentication.getPrincipal()).getMember(); - String accessToken = jwtUtil.generateAccessToken(member.getEmail(), member.getRole()); - String refreshToken = jwtUtil.generateRefreshToken(); - - //ResponseHeader에 토큰 추가 - jwtUtil.setJwtHeader(response, accessToken, refreshToken); - - //Redis에 refreshToken 저장 - redisUtil.saveRefreshToken(refreshToken, member.getEmail()); + setTokenHeaderAndRedis(response, member); } catch(BadCredentialsException e) { throw new GlobalException(MemberErrorCode.INVALID_AUTH); @@ -246,8 +239,10 @@ private void setTokenHeaderAndRedis(HttpServletResponse response, Member socialM String aToken = jwtUtil.generateAccessToken(socialMember.getEmail(), socialMember.getRole()); String rToken = jwtUtil.generateRefreshToken(); + //ResponseHeader에 토큰 추가 jwtUtil.setJwtHeader(response, aToken, rToken); + //Redis에 refreshToken 저장 redisUtil.saveRefreshToken(rToken, socialMember.getEmail()); } } From 79d86e754e7faae4631f8fe55baed955f93eb49c Mon Sep 17 00:00:00 2001 From: zzzzseong Date: Fri, 26 Jan 2024 17:54:42 +0900 Subject: [PATCH 2/6] =?UTF-8?q?fix(GameChat):=20=EC=9D=91=EC=9B=90=20?= =?UTF-8?q?=EC=B1=84=ED=8C=85=20=ED=83=80=EC=9E=84=EC=A1=B4=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gamechat/controller/MessageController.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/sportsecho/gamechat/controller/MessageController.java b/src/main/java/com/sportsecho/gamechat/controller/MessageController.java index 1042e46f..d100cae3 100644 --- a/src/main/java/com/sportsecho/gamechat/controller/MessageController.java +++ b/src/main/java/com/sportsecho/gamechat/controller/MessageController.java @@ -3,6 +3,10 @@ import com.sportsecho.gamechat.dto.GameChatRequestDto; import com.sportsecho.gamechat.dto.GameChatResponseDto; import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; import java.util.Date; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -34,14 +38,9 @@ public GameChatResponseDto publish( @DestinationVariable("gameId") Long gameId, GameChatRequestDto request ) { - // 현재 시간을 Date 객체로 얻기 - Date now = new Date(); + LocalDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Seoul")).toLocalDateTime(); - // SimpleDateFormat을 사용하여 형식 지정 - SimpleDateFormat formatter = new SimpleDateFormat("HH:mm"); - - // 현재 시간을 지정한 형식으로 문자열로 변환 - String formattedTime = formatter.format(now); + String formattedTime = now.format(DateTimeFormatter.ofPattern("HH:mm")); return GameChatResponseDto.builder() .sender(request.getSender()) From d38b5cdd757d0006fe253ca8faeef691c5f1a228 Mon Sep 17 00:00:00 2001 From: zzzzseong Date: Fri, 26 Jan 2024 18:00:19 +0900 Subject: [PATCH 3/6] =?UTF-8?q?fix(Member):=20=EC=82=AC=EC=9A=A9=EC=9E=90?= =?UTF-8?q?=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=EC=8B=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=ED=95=9C=EA=B5=AD=EC=96=B4=20=ED=8C=A8=ED=84=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sportsecho/member/service/MemberServiceImplV2.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java b/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java index 94e1ee85..f522a263 100644 --- a/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java +++ b/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java @@ -64,7 +64,7 @@ public MemberResponseDto signup(MemberRequestDto request, MemberRole role) { if(memberRepository.findByEmail(request.getEmail()).isPresent()) throw new GlobalException(MemberErrorCode.DUPLICATED_EMAIL); - if(!request.getMemberName().matches("^[a-zA-Z0-9]{4,20}$")) + if(!request.getMemberName().matches("^[a-zA-Z0-9가-힣]{4,20}$")) throw new GlobalException(MemberErrorCode.INVALID_MEMBER_NAME); //MemberMapper를 이용한 Entity 생성 From e68d189f12687175cc8417dda9e7190a94334d0c Mon Sep 17 00:00:00 2001 From: Kim Jihyun Date: Sat, 27 Jan 2024 17:35:42 +0900 Subject: [PATCH 4/6] =?UTF-8?q?refactor=20:=20time=20trace=20cart,=20purch?= =?UTF-8?q?ase=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/sportsecho/common/aop/TimeTraceAop.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sportsecho/common/aop/TimeTraceAop.java b/src/main/java/com/sportsecho/common/aop/TimeTraceAop.java index f12a7f56..e02a5656 100644 --- a/src/main/java/com/sportsecho/common/aop/TimeTraceAop.java +++ b/src/main/java/com/sportsecho/common/aop/TimeTraceAop.java @@ -24,7 +24,7 @@ public void memberProduct() { public void purchase() { } - @Around("user() || memberProduct() || purchase()") + @Around("user()") public Object execute(ProceedingJoinPoint joinPoint) throws Throwable { long start = System.currentTimeMillis(); From 7d5599bbc7984c5b6691ba8b93a373922543d745 Mon Sep 17 00:00:00 2001 From: Kim Jihyun Date: Sat, 27 Jan 2024 17:36:13 +0900 Subject: [PATCH 5/6] =?UTF-8?q?fix(purchase)=20:=20mapper=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sportsecho/purchase/mapper/PurchaseMapper.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/sportsecho/purchase/mapper/PurchaseMapper.java b/src/main/java/com/sportsecho/purchase/mapper/PurchaseMapper.java index be51f51e..884cfac8 100644 --- a/src/main/java/com/sportsecho/purchase/mapper/PurchaseMapper.java +++ b/src/main/java/com/sportsecho/purchase/mapper/PurchaseMapper.java @@ -1,9 +1,7 @@ package com.sportsecho.purchase.mapper; import com.sportsecho.hotdeal.dto.request.PurchaseHotdealRequestDto; -import com.sportsecho.hotdeal.entity.Hotdeal; import com.sportsecho.member.entity.Member; -import com.sportsecho.product.entity.Product; import com.sportsecho.purchase.dto.PurchaseRequestDto; import com.sportsecho.purchase.dto.PurchaseResponseDto; import com.sportsecho.purchase.entity.Purchase; @@ -22,6 +20,7 @@ public interface PurchaseMapper { @Mapping(target = "purchaseDate", source = "createdAt") PurchaseResponseDto toResponseDto(Purchase purchase); + @Mapping(target = "id", ignore = true) @Mapping(target = "totalPrice", constant = "0") @Mapping(target = "member", source = "member") @Mapping(target = "purchaseProductList", ignore = true) @@ -32,10 +31,9 @@ public interface PurchaseMapper { @Mapping(target = "address", source = "requestDto.address") @Mapping(target = "phone", source = "requestDto.phone") @Mapping(target = "member", source = "member") - @Mapping(target = "purchaseProductList", ignore = true) - Purchase fromPurchaseHotdealReqeustDto(PurchaseHotdealRequestDto requestDto, int discountedPrice, - Member member); + Purchase fromPurchaseHotdealReqeustDto(PurchaseHotdealRequestDto requestDto, + int discountedPrice, Member member); @AfterMapping From 93d641d1f209e316aab78d1366f416d52f8d6234 Mon Sep 17 00:00:00 2001 From: Kim Jihyun Date: Sat, 27 Jan 2024 17:36:28 +0900 Subject: [PATCH 6/6] =?UTF-8?q?refactor(purchase)=20:=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BC=80=EC=9D=B4=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../purchase/service/PurchaseServiceImplV1Test.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/sportsecho/purchase/service/PurchaseServiceImplV1Test.java b/src/test/java/com/sportsecho/purchase/service/PurchaseServiceImplV1Test.java index e21d9757..d1ebb15a 100644 --- a/src/test/java/com/sportsecho/purchase/service/PurchaseServiceImplV1Test.java +++ b/src/test/java/com/sportsecho/purchase/service/PurchaseServiceImplV1Test.java @@ -141,11 +141,16 @@ void getPurchaseListTest_success() { //given purchaseService.purchase(requestDto, member); + memberProduct = MemberProductTestUtil.getMemberProduct(member, product); + memberProductRepository.save(memberProduct); + purchaseService.purchase(requestDto, member); + //when List responseDtoList = purchaseService.getPurchaseList(member); //then - assertEquals(1, responseDtoList.size()); + assertEquals(2, responseDtoList.size()); + assertEquals(requestDto.getAddress(), responseDtoList.get(0).getAddress()); assertEquals(memberProduct.getProductsQuantity() * product.getPrice(), responseDtoList.get(0).getTotalPrice()); @@ -153,6 +158,10 @@ void getPurchaseListTest_success() { responseDtoList.get(0).getPurchaseProductList().get(0).getTitle()); assertEquals(memberProduct.getProductsQuantity(), responseDtoList.get(0).getPurchaseProductList().get(0).getProductsQuantity()); + + assertEquals(requestDto.getAddress(), responseDtoList.get(1).getAddress()); + assertEquals(product.getTitle(), + responseDtoList.get(1).getPurchaseProductList().get(0).getTitle()); } @Test