From de6e1d98ada96132f78d8258c60b05e063b83639 Mon Sep 17 00:00:00 2001 From: nYeonG4001 <2371324@hansung.ac.kr> Date: Mon, 13 Apr 2026 16:35:31 +0900 Subject: [PATCH] =?UTF-8?q?DP-334:=20AI=20=EC=9A=94=EC=95=BD=20=ED=9E=88?= =?UTF-8?q?=EC=8A=A4=ED=86=A0=EB=A6=AC=20=EB=B6=84=EB=A6=AC(POST=20/summar?= =?UTF-8?q?y/viewed)=20=EB=A1=A4=EB=B0=B1=20=E2=80=94=20=EC=B6=94=ED=9B=84?= =?UTF-8?q?=20=EB=B3=84=EB=8F=84=20=EA=B5=AC=ED=98=84=20=EC=98=88=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../content/controller/ContentController.java | 18 ------------------ .../content/dto/SummaryViewedRequest.java | 3 --- .../content/service/AiSummaryService.java | 6 ++++-- .../devpick/domain/report/entity/History.java | 3 --- 4 files changed, 4 insertions(+), 26 deletions(-) delete mode 100644 src/main/java/com/devpick/domain/content/dto/SummaryViewedRequest.java diff --git a/src/main/java/com/devpick/domain/content/controller/ContentController.java b/src/main/java/com/devpick/domain/content/controller/ContentController.java index 7f7cf89..dafb247 100644 --- a/src/main/java/com/devpick/domain/content/controller/ContentController.java +++ b/src/main/java/com/devpick/domain/content/controller/ContentController.java @@ -2,8 +2,6 @@ import com.devpick.domain.content.dto.ContentDetailResponse; import com.devpick.domain.content.dto.ContentListResponse; -import com.devpick.domain.content.dto.SummaryViewedRequest; -import com.devpick.domain.content.service.AiSummaryService; import com.devpick.domain.content.service.ContentService; import com.devpick.global.common.response.ApiResponse; import io.swagger.v3.oas.annotations.Operation; @@ -35,7 +33,6 @@ public class ContentController { private final ContentService contentService; - private final AiSummaryService aiSummaryService; @Operation(summary = "개인화 피드 조회", description = "사용자의 기술 태그와 레벨에 맞는 개인화된 콘텐츠 목록을 반환합니다.") @ApiResponses({ @@ -80,21 +77,6 @@ public ApiResponse getDetail( return ApiResponse.ok(contentService.getDetail(userId, contentId)); } - @Operation(summary = "AI 요약 조회 히스토리 기록", description = "AI 요약 섹션 최초 진입 시 1회 호출합니다. 히스토리(ai_summary_viewed)가 기록됩니다.") - @ApiResponses({ - @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "204", description = "기록 성공"), - @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "401", description = "인증 필요"), - @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "콘텐츠를 찾을 수 없음") - }) - @PostMapping("/{contentId}/summary/viewed") - @ResponseStatus(HttpStatus.NO_CONTENT) - public void recordSummaryViewed( - @AuthenticationPrincipal UUID userId, - @Parameter(description = "콘텐츠 ID (UUID)", required = true) @PathVariable UUID contentId, - @RequestBody SummaryViewedRequest request) { - aiSummaryService.recordSummaryViewed(userId, contentId, request.level()); - } - @Operation(summary = "원문 확인(학습 기록)", description = "외부 원문 링크를 연 시점에 호출합니다. 학습 히스토리(content_opened)가 기록됩니다.") @ApiResponses({ @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "204", description = "기록 성공"), diff --git a/src/main/java/com/devpick/domain/content/dto/SummaryViewedRequest.java b/src/main/java/com/devpick/domain/content/dto/SummaryViewedRequest.java deleted file mode 100644 index 591faf2..0000000 --- a/src/main/java/com/devpick/domain/content/dto/SummaryViewedRequest.java +++ /dev/null @@ -1,3 +0,0 @@ -package com.devpick.domain.content.dto; - -public record SummaryViewedRequest(String level) {} diff --git a/src/main/java/com/devpick/domain/content/service/AiSummaryService.java b/src/main/java/com/devpick/domain/content/service/AiSummaryService.java index 12e03e8..e58a1a8 100644 --- a/src/main/java/com/devpick/domain/content/service/AiSummaryService.java +++ b/src/main/java/com/devpick/domain/content/service/AiSummaryService.java @@ -53,6 +53,7 @@ public AiSummaryResponse getSummary(UUID userId, UUID contentId, String level) { String redisKey = buildRedisKey(contentId, aiLevel); AiSummaryResponse cached = getFromRedis(redisKey); if (cached != null && cached.expiresAt() != null && cached.expiresAt().isAfter(Instant.now())) { + recordHistory(userId, contentId); return cached; } @@ -62,6 +63,7 @@ public AiSummaryResponse getSummary(UUID userId, UUID contentId, String level) { && docOpt.get().getExpiresAt().isAfter(LocalDateTime.now())) { AiSummaryResponse response = AiSummaryResponse.of(docOpt.get()); saveToRedis(redisKey, response); + recordHistory(userId, contentId); return response; } @@ -76,6 +78,7 @@ public AiSummaryResponse getSummary(UUID userId, UUID contentId, String level) { AiSummaryResponse response = AiSummaryResponse.of(doc); saveToRedis(redisKey, response); + recordHistory(userId, contentId); return response; } @@ -156,14 +159,13 @@ public Optional findCachedCoreSummary(UUID contentId, String level) { } } - public void recordSummaryViewed(UUID userId, UUID contentId, String level) { + private void recordHistory(UUID userId, UUID contentId) { userRepository.findByIdAndIsActiveTrue(userId).ifPresent(user -> contentRepository.findByIdAndIsAvailableTrue(contentId).ifPresent(content -> historyRepository.save(History.builder() .user(user) .actionType("ai_summary_viewed") .content(content) - .level(level) .build()) ) ); diff --git a/src/main/java/com/devpick/domain/report/entity/History.java b/src/main/java/com/devpick/domain/report/entity/History.java index c28c449..14222fc 100644 --- a/src/main/java/com/devpick/domain/report/entity/History.java +++ b/src/main/java/com/devpick/domain/report/entity/History.java @@ -43,7 +43,4 @@ public class History extends BaseCreatedEntity { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "comment_id") private Comment comment; - - @Column(name = "level", length = 20) - private String level; }