Skip to content
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
20 changes: 10 additions & 10 deletions .github/workflows/kkinikong-be-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,34 @@ jobs:
echo "🐳 최신 develop 이미지 pull"
docker pull chaeeunkim/kkini-kong-be:develop

echo "🧲 docker-compose pull 로 의존 이미지 최신화"
docker-compose pull
echo "🧲 docker compose pull 로 의존 이미지 최신화"
docker compose pull

if [ "$RUNNING" = "spring-blue" ]; then
echo "✅ 현재 blue가 운영 중 -> green 배포 시작"
docker-compose stop spring-green || true
docker-compose rm -f spring-green || true
docker-compose up -d spring-green
docker compose stop spring-green || true
docker compose rm -f spring-green || true
docker compose up -d spring-green

echo "🔧 nginx 설정을 green(8081)으로 변경"
sudo sed -i 's/proxy_pass http:\/\/localhost:8080;/proxy_pass http:\/\/localhost:8081;/g' /etc/nginx/sites-available/default
sudo nginx -s reload

echo "🧹 기존 blue 컨테이너 중지"
docker-compose stop spring-blue || true
docker compose stop spring-blue || true

else
echo "✅ 현재 green이 운영 중 -> blue 배포 시작"
docker-compose stop spring-blue || true
docker-compose rm -f spring-blue || true
docker-compose up -d spring-blue
docker compose stop spring-blue || true
docker compose rm -f spring-blue || true
docker compose up -d spring-blue

echo "🔧 nginx 설정을 blue(8080)으로 변경"
sudo sed -i 's/proxy_pass http:\/\/localhost:8081;/proxy_pass http:\/\/localhost:8080;/g' /etc/nginx/sites-available/default
sudo nginx -s reload

echo "🧹 기존 green 컨테이너 중지"
docker-compose stop spring-green || true
docker compose stop spring-green || true
fi

echo "🩺 Redis 상태 확인 중..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ public class FeedbackController {

private final FeedbackService feedbackService;

@Operation(summary = "의견 남기기")
@Operation(
summary = "의견 남기기",
description =
"type에 SEARCH_FOOD(\"음식결과없음\")"
+ " SEARCH_RESTAURANT(\"식당결과없음\"),"
+ " SEARCH_COMMUNITY(\"커뮤니티결과없음\") 중 하나로 의견을 남깁니다.")
@PostMapping("")
public ResponseEntity<ApiResponse<Object>> addFeedback(@RequestBody FeedbackRequest request) {
feedbackService.addFeedback(request);
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/kkinikong/be/feedback/domain/Feedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

import com.kkinikong.be.feedback.domain.type.FeedbackType;
import com.kkinikong.be.global.entity.BaseEntity;

@Table(name = "feedbacks")
Expand All @@ -24,9 +25,14 @@ public class Feedback extends BaseEntity {
@Column(name = "content", length = 6000)
private String content;

@Column(name = "type")
@Enumerated(EnumType.STRING)
private FeedbackType type;

@Builder
public Feedback(int rating, String content) {
public Feedback(int rating, String content, FeedbackType type) {
this.rating = rating;
this.content = content;
this.type = type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.kkinikong.be.feedback.domain.type;

import lombok.Getter;

@Getter
public enum FeedbackType {
SEARCH_FOOD("음식결과없음"),
SEARCH_RESTAURANT("식당결과없음"),
SEARCH_COMMUNITY("커뮤니티결과없음");

private final String label;

FeedbackType(String label) {
this.label = label;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.Size;

public record FeedbackRequest(@Min(1) @Max(5) int rating, @Size(max = 6000) String content) {}
import com.kkinikong.be.feedback.domain.type.FeedbackType;

public record FeedbackRequest(
@Min(1) @Max(5) int rating, @Size(max = 6000) String content, FeedbackType type) {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ public class FeedbackService {
@Transactional
public void addFeedback(FeedbackRequest request) {
Feedback feedback =
Feedback.builder().rating(request.rating()).content(request.content()).build();
Feedback.builder()
.rating(request.rating())
.content(request.content())
.type(request.type())
.build();

feedbackRepository.save(feedback);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.kkinikong.be.community.domain.CommunityPost;
import com.kkinikong.be.community.repository.communityPost.CommunityPostRepository;
import com.kkinikong.be.user.domain.User;
import com.kkinikong.be.user.repository.UserRepository;
Expand Down Expand Up @@ -50,33 +45,33 @@ void setUp() {
}
}

@Test
@DisplayName("서로 다른 유저들이 동시에 좋아요 누르는 경우")
void testConcurrentLikeToggleWithDifferentUsers() throws InterruptedException {
// given
final long postId = 24; // 테스트용 게시글 ID
ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT);
CountDownLatch countDownLatch = new CountDownLatch(THREAD_COUNT);

// when
for (int i = 0; i < THREAD_COUNT; i++) {
Long userId = userIds.get(i);
executorService.execute(
() -> {
try {
communityService.postCommunityPostLike(postId, userId);
} finally {
countDownLatch.countDown();
}
});
}

countDownLatch.await(); // 모든 스레드 작업 끝날 때까지 대기

// then
CommunityPost post = communityPostRepository.findById(postId).orElseThrow();
System.out.println("최종 좋아요 수: " + post.getLikeCount());

assertThat(post.getLikeCount()).isEqualTo(THREAD_COUNT); // 좋아요 100개가 되어야 함
}
// @Test
// @DisplayName("서로 다른 유저들이 동시에 좋아요 누르는 경우")
// void testConcurrentLikeToggleWithDifferentUsers() throws InterruptedException {
// // given
// final long postId = 24; // 테스트용 게시글 ID
// ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT);
// CountDownLatch countDownLatch = new CountDownLatch(THREAD_COUNT);
//
// // when
// for (int i = 0; i < THREAD_COUNT; i++) {
// Long userId = userIds.get(i);
// executorService.execute(
// () -> {
// try {
// communityService.postCommunityPostLike(postId, userId);
// } finally {
// countDownLatch.countDown();
// }
// });
// }
//
// countDownLatch.await(); // 모든 스레드 작업 끝날 때까지 대기
//
// // then
// CommunityPost post = communityPostRepository.findById(postId).orElseThrow();
// System.out.println("최종 좋아요 수: " + post.getLikeCount());
//
// assertThat(post.getLikeCount()).isEqualTo(THREAD_COUNT); // 좋아요 100개가 되어야 함
// }
}