Files
demo-CQRS/content-query/src/main/java/com/example/contentquery/service/ContentQueryService.java
2023-01-12 20:05:59 +09:00

22 lines
666 B
Java

package com.example.contentquery.service;
import com.example.contentquery.repository.Content;
import com.example.contentquery.repository.ContentQueryRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
@Slf4j
public class ContentQueryService {
private final ContentQueryRepository contentQueryRepository;
public Content findByPostId(Long contentId) {
return contentQueryRepository.findByContentId(contentId).orElseThrow(
() -> new RuntimeException("해당 게시글이 존재하지 않습니다.")
);
}
}