TopicSourceService.java
1.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// keyword/service/TopicSourceService.java
package com.aigeo.keyword.service;
import com.aigeo.keyword.entity.TopicSource;
import com.aigeo.keyword.repository.TopicSourceRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class TopicSourceService {
@Autowired
private TopicSourceRepository topicSourceRepository;
public List<TopicSource> getAllTopicSources() {
return topicSourceRepository.findAll();
}
public List<TopicSource> getActiveTopicSources() {
return topicSourceRepository.findByIsActiveTrue();
}
public Optional<TopicSource> getTopicSourceById(Integer id) {
return topicSourceRepository.findById(id);
}
public TopicSource saveTopicSource(TopicSource topicSource) {
return topicSourceRepository.save(topicSource);
}
public void deleteTopicSource(Integer id) {
topicSourceRepository.deleteById(id);
}
}