Skip to content

Commit

Permalink
test: 좋아요 성능 테스트를 위한 서버 재배포
Browse files Browse the repository at this point in the history
  • Loading branch information
EunChanNam committed Nov 27, 2023
1 parent b86f6e4 commit ac34a8b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
package com.inq.wishhair.wesharewishhair;

import java.util.ArrayList;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Profile;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

import com.inq.wishhair.wesharewishhair.hairstyle.domain.HairStyle;
import com.inq.wishhair.wesharewishhair.hairstyle.domain.HairStyleRepository;
import com.inq.wishhair.wesharewishhair.user.domain.UserRepository;
import com.inq.wishhair.wesharewishhair.user.domain.entity.Password;
import com.inq.wishhair.wesharewishhair.user.domain.entity.Sex;
import com.inq.wishhair.wesharewishhair.user.domain.entity.User;

import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;

@SpringBootApplication
public class WeShareWishHairApplication {
Expand All @@ -10,4 +25,27 @@ public static void main(String[] args) {
SpringApplication.run(WeShareWishHairApplication.class, args);
}

@Component
@Profile("prod")
@RequiredArgsConstructor
static class TestData {

private final UserRepository userRepository;
private final HairStyleRepository hairStyleRepository;
private final PasswordEncoder passwordEncoder;

@PostConstruct
public void setUp() {
userRepository.save(User.createUser(
"[email protected]",
Password.encrypt("hello123@", passwordEncoder),
"userA",
"hello",
Sex.MAN
));

hairStyleRepository.save(HairStyle.createHairStyle("hairStyleA", Sex.MAN, new ArrayList<>(), new ArrayList<>()));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.inq.wishhair.wesharewishhair.review.domain.likereview.LikeReview;
import com.inq.wishhair.wesharewishhair.review.domain.likereview.LikeReviewRepository;

import jakarta.persistence.EntityExistsException;
import lombok.RequiredArgsConstructor;

@Service
Expand All @@ -29,11 +28,7 @@ private Long updateLikeCountFromRedis(Long reviewId) {

@Transactional
public boolean executeLike(Long reviewId, Long userId) {
try {
likeReviewRepository.save(LikeReview.addLike(userId, reviewId));
} catch (EntityExistsException e) {
return false;
}
likeReviewRepository.save(LikeReview.addLike(userId, reviewId));

//락을 걸지않고 값이없으면 좋아요 개수를 로드해서 반영 기능 추가
redisUtils.getData(reviewId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(uniqueConstraints = @UniqueConstraint(columnNames = {"userId", "reviewId"}))
@Table(name = "like_review")
public class LikeReview {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
import com.inq.wishhair.wesharewishhair.global.exception.ErrorCode;
import com.inq.wishhair.wesharewishhair.global.exception.WishHairException;
import com.inq.wishhair.wesharewishhair.hairstyle.domain.hashtag.Tag;
import com.inq.wishhair.wesharewishhair.point.domain.PointLogRepository;
import com.inq.wishhair.wesharewishhair.review.application.ReviewService;
import com.inq.wishhair.wesharewishhair.user.presentation.dto.request.PasswordRefreshRequest;
import com.inq.wishhair.wesharewishhair.user.presentation.dto.request.PasswordUpdateRequest;
import com.inq.wishhair.wesharewishhair.user.presentation.dto.request.SignUpRequest;
import com.inq.wishhair.wesharewishhair.user.presentation.dto.request.UserUpdateRequest;
import com.inq.wishhair.wesharewishhair.user.application.utils.UserValidator;
import com.inq.wishhair.wesharewishhair.user.domain.AiConnector;
import com.inq.wishhair.wesharewishhair.user.domain.UserRepository;
import com.inq.wishhair.wesharewishhair.user.domain.entity.Email;
import com.inq.wishhair.wesharewishhair.user.domain.entity.FaceShape;
import com.inq.wishhair.wesharewishhair.user.domain.entity.Nickname;
import com.inq.wishhair.wesharewishhair.user.domain.entity.Password;
import com.inq.wishhair.wesharewishhair.user.domain.entity.User;
import com.inq.wishhair.wesharewishhair.user.domain.UserRepository;
import com.inq.wishhair.wesharewishhair.point.domain.PointLogRepository;
import com.inq.wishhair.wesharewishhair.user.application.utils.UserValidator;
import com.inq.wishhair.wesharewishhair.user.domain.AiConnector;
import com.inq.wishhair.wesharewishhair.user.presentation.dto.request.PasswordRefreshRequest;
import com.inq.wishhair.wesharewishhair.user.presentation.dto.request.PasswordUpdateRequest;
import com.inq.wishhair.wesharewishhair.user.presentation.dto.request.SignUpRequest;
import com.inq.wishhair.wesharewishhair.user.presentation.dto.request.UserUpdateRequest;

import lombok.RequiredArgsConstructor;

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ decorator:
#JWT key
jwt:
secret-key: abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc
access-token-validity: 1800000
access-token-validity: 180000000
refresh-token-validity: 259200000

# 네이버 클라우드 오브젝트 스토리지
Expand Down

0 comments on commit ac34a8b

Please sign in to comment.