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,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;
Expand Down Expand Up @@ -35,7 +33,6 @@
public class ContentController {

private final ContentService contentService;
private final AiSummaryService aiSummaryService;

@Operation(summary = "개인화 피드 조회", description = "사용자의 기술 태그와 레벨에 맞는 개인화된 콘텐츠 목록을 반환합니다.")
@ApiResponses({
Expand Down Expand Up @@ -80,21 +77,6 @@ public ApiResponse<ContentDetailResponse> 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 = "기록 성공"),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -156,14 +159,13 @@ public Optional<String> 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())
)
);
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/com/devpick/domain/report/entity/History.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading