LandingPageTemplateService.java
1.3 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
38
39
40
41
// landingpage/service/LandingPageTemplateService.java
package com.aigeo.landingpage.service;
import com.aigeo.landingpage.entity.LandingPageTemplate;
import com.aigeo.landingpage.repository.LandingPageTemplateRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class LandingPageTemplateService {
@Autowired
private LandingPageTemplateRepository landingPageTemplateRepository;
public List<LandingPageTemplate> getAllTemplates() {
return landingPageTemplateRepository.findAll();
}
public List<LandingPageTemplate> getActiveTemplates() {
return landingPageTemplateRepository.findByIsActiveTrue();
}
public Optional<LandingPageTemplate> getTemplateById(Integer id) {
return landingPageTemplateRepository.findById(id);
}
public Optional<LandingPageTemplate> getTemplateByCode(String code) {
return Optional.ofNullable(landingPageTemplateRepository.findByCode(code));
}
public LandingPageTemplate saveTemplate(LandingPageTemplate template) {
return landingPageTemplateRepository.save(template);
}
public void deleteTemplate(Integer id) {
landingPageTemplateRepository.deleteById(id);
}
}