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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.example.chalpu.common.response.ApiResponse;
import com.example.chalpu.feedback.dto.AppImprovementFeedbackDto;
import com.example.chalpu.feedback.dto.FeedbackRequestDto;
import com.example.chalpu.feedback.dto.FoodGuideFeedbackDto;
import com.example.chalpu.feedback.service.FeedbackService;
import com.example.chalpu.oauth.security.jwt.UserDetailsImpl;
Expand All @@ -24,7 +25,7 @@
public class FeedbackController {
private final FeedbackService feedbackService;

@PostMapping("/food-guide")
@PostMapping
@Operation(
summary = "음식 가이드 피드백 제출",
description = "특정 음식에 대한 가이드 요청 피드백을 제출합니다.",
Expand All @@ -46,34 +47,8 @@ public class FeedbackController {
)
public ApiResponse<String> submitFoodGuideFeedback(
@Parameter(hidden = true) @AuthenticationPrincipal UserDetailsImpl userDetails,
@RequestBody FoodGuideFeedbackDto feedbackDto) {
@RequestBody FeedbackRequestDto feedbackDto) {
feedbackService.submitFoodGuideFeedback(userDetails.getId(), feedbackDto);
return ApiResponse.success("제출이 성공하였습니다");
}

@PostMapping("/app-improvement")
@Operation(
summary = "앱 개선 피드백 제출",
description = "앱 기능 개선 및 버그 신고 등의 피드백을 제출합니다.",
security = @SecurityRequirement(name = "bearerAuth")
)
@io.swagger.v3.oas.annotations.parameters.RequestBody(
description = "앱 개선 피드백 데이터",
content = @Content(
mediaType = "application/json",
examples = @ExampleObject(
value = """
{
"content": "사진 업로드 속도가 느려요. 개선해주세요."
}
"""
)
)
)
public ApiResponse<String> submitAppImprovementFeedback(
@Parameter(hidden = true) @AuthenticationPrincipal UserDetailsImpl userDetails,
@RequestBody AppImprovementFeedbackDto feedbackDto) {
feedbackService.submitAppImprovementFeedback(userDetails.getId(), feedbackDto);
return ApiResponse.success("제출이 성공하였습니다");
}
}
24 changes: 1 addition & 23 deletions src/main/java/com/example/chalpu/feedback/domain/Feedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,16 @@ public class Feedback extends BaseTimeEntity {
@Column(name = "user_id", nullable = false)
private Long userId;

@Enumerated(EnumType.STRING)
@Column(name = "feedback_type", nullable = false, length = 30)
private FeedbackType feedbackType;

@Column(columnDefinition = "TEXT", nullable = false)
private String content;

@Column(name = "food_name", length = 100)
private String foodName;

public static Feedback createFoodGuideFeedback(Long userId, String content, String foodName) {
public static Feedback createFoodGuideFeedback(Long userId, String content) {
return Feedback.builder()
.userId(userId)
.feedbackType(FeedbackType.FOOD_GUIDE_REQUEST)
.content(content)
.foodName(foodName)
.build();
}

public static Feedback createAppImprovementFeedback(Long userId, String content) {
return Feedback.builder()
.userId(userId)
.feedbackType(FeedbackType.APP_IMPROVEMENT)
.content(content)
.build();
}

public boolean isFoodGuideFeedback() {
return this.feedbackType == FeedbackType.FOOD_GUIDE_REQUEST;
}

public boolean isAppImprovementFeedback() {
return this.feedbackType == FeedbackType.APP_IMPROVEMENT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@

@Repository
public interface FeedbackRepository extends JpaRepository<Feedback, Long> {

List<Feedback> findByUserIdOrderByCreatedAtDesc(Long userId);

List<Feedback> findByFeedbackTypeOrderByCreatedAtDesc(FeedbackType feedbackType);

@Query("SELECT f FROM Feedback f WHERE f.userId = :userId AND f.feedbackType = :feedbackType ORDER BY f.createdAt DESC")
List<Feedback> findByUserIdAndFeedbackType(@Param("userId") Long userId, @Param("feedbackType") FeedbackType feedbackType);
@Query("SELECT f FROM Feedback f WHERE f.userId = :userId ORDER BY f.createdAt DESC")
List<Feedback> findByUserIdAndFeedbackType(@Param("userId") Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.example.chalpu.feedback.dto.FeedbackRequestDto;

@Service
@RequiredArgsConstructor
Expand All @@ -17,24 +18,13 @@ public class FeedbackService {

private final FeedbackRepository feedbackRepository;

public void submitFoodGuideFeedback(Long userId, FoodGuideFeedbackDto feedbackDto) {
public void submitFoodGuideFeedback(Long userId, FeedbackRequestDto feedbackDto) {
Feedback feedback = Feedback.createFoodGuideFeedback(
userId,
feedbackDto.getContent(),
feedbackDto.getFoodName()
);

feedbackRepository.save(feedback);
log.info("event=food_fuide_feedback_post_success - ID: {}", feedback.getId());
}

public void submitAppImprovementFeedback(Long userId, AppImprovementFeedbackDto feedbackDto) {
Feedback feedback = Feedback.createAppImprovementFeedback(
userId,
feedbackDto.getContent()
);

feedbackRepository.save(feedback);
log.info("event=app_improvement_feedback_post_success - ID: {}", feedback.getId());
log.info("event=food_fuide_feedback_post_success - ID: {}", feedback.getId());
}
}