Skip to content

Commit

Permalink
Merge pull request #136 from SportsEcho/dev1
Browse files Browse the repository at this point in the history
V0.1.2 배포
  • Loading branch information
zomeong authored Jan 28, 2024
2 parents 0fd2aac + 6067f36 commit e4d3923
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/sportsecho/common/aop/TimeTraceAop.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 생성
Expand Down Expand Up @@ -96,14 +96,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);
Expand Down Expand Up @@ -236,8 +229,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());
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,27 @@ void getPurchaseListTest_success() {
//given
purchaseService.purchase(requestDto, member);

memberProduct = MemberProductTestUtil.getMemberProduct(member, product);
memberProductRepository.save(memberProduct);
purchaseService.purchase(requestDto, member);

//when
List<PurchaseResponseDto> 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());
assertEquals(product.getTitle(),
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
Expand Down

0 comments on commit e4d3923

Please sign in to comment.