You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
package com.mousetech.gourmetj.persistence.service;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
|
|
import javax.enterprise.context.ApplicationScoped;
|
|
import javax.inject.Inject;
|
|
import javax.inject.Named;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import com.mousetech.gourmetj.persistence.dao.CategoryRepository;
|
|
import com.mousetech.gourmetj.persistence.dao.RecipeRepository;
|
|
import com.mousetech.gourmetj.persistence.model.Category;
|
|
import com.mousetech.gourmetj.persistence.model.Recipe;
|
|
|
|
@Named
|
|
@ApplicationScoped
|
|
@Transactional
|
|
public class RecipeService implements Serializable {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
@Inject
|
|
private RecipeRepository recipeRepository;
|
|
|
|
public List<Recipe> findAll() {
|
|
return recipeRepository.findAll();
|
|
}
|
|
|
|
public List<String> findCuisines() {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public List<Recipe> findByTitle(String searchText) {
|
|
return recipeRepository.findByTitleContaining(searchText);
|
|
}
|
|
|
|
public Recipe findByPrimaryKey(Long recipeId) {
|
|
return recipeRepository.findById(recipeId).orElse(null);
|
|
}
|
|
|
|
// /**
|
|
// *
|
|
// * @return All Category names that are not null/blank, sorted.
|
|
// */
|
|
// public List<String> findCategoryNames() {
|
|
// return categoryRepository.findDistinctCategoryNative();
|
|
// }
|
|
}
|
|
|