FEAT: Implemented Recipe of the Week #35
@ -209,7 +209,7 @@ func (s *RecipeService) GetUserMadeRecipes(userId, limit int) ([]domain.Recipe,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetRecipeOfTheWeek searches for the most recent recipe of the week. If there is not a value,
|
// GetRecipeOfTheWeek searches for the most recent recipe of the week. If there is not a value,
|
||||||
// the recipe will be nil. The
|
// the recipe will be nil. Any errors will be bubbled to the caller.
|
||||||
func (s *RecipeService) GetRecipeOfTheWeek(userId *int) (*domain.Recipe, error) {
|
func (s *RecipeService) GetRecipeOfTheWeek(userId *int) (*domain.Recipe, error) {
|
||||||
return s.recipeRepository.GetRecipeOfTheWeek(userId)
|
return s.recipeRepository.GetRecipeOfTheWeek(userId)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -676,6 +676,9 @@ func (r *RecipeRepository) GetUserRecipes(id int) ([]domain.Recipe, error) {
|
|||||||
return recipes, nil
|
return recipes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserRecipes gets a list of a users favorited recipes. This function does not ensure the user is
|
||||||
|
// authenticated or exists. If nothing is found, a blank slice will be returned. The resulting list
|
||||||
|
// is sorted by the created dates, newest first. Any errors will be bubbled to the caller.
|
||||||
func (r *RecipeRepository) GetUserFavoriteRecipes(id int) ([]domain.Recipe, error) {
|
func (r *RecipeRepository) GetUserFavoriteRecipes(id int) ([]domain.Recipe, error) {
|
||||||
tx, err := r.db.Begin()
|
tx, err := r.db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -766,8 +769,13 @@ func (r *RecipeRepository) GetUserFavoriteRecipes(id int) ([]domain.Recipe, erro
|
|||||||
|
|
||||||
// GetRecipeTags requires a recipe to be filled with at least an ID. This function will use the ID
|
// GetRecipeTags requires a recipe to be filled with at least an ID. This function will use the ID
|
||||||
// defined in the provided recipe to fill the Tags array with the recipe's tags from the database.
|
// defined in the provided recipe to fill the Tags array with the recipe's tags from the database.
|
||||||
// The recipe is modified in place and is not returned. Any errors will be bubbled to the caller.
|
// The recipe is modified in place and is not returned. If the recipe is nil, the function will
|
||||||
|
// return nothing (skipping). Any errors will be bubbled to the caller.
|
||||||
func (r *RecipeRepository) GetRecipeTags(recipe *domain.Recipe) error {
|
func (r *RecipeRepository) GetRecipeTags(recipe *domain.Recipe) error {
|
||||||
|
if recipe == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
tx, err := r.db.Begin()
|
tx, err := r.db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
@ -808,8 +816,13 @@ func (r *RecipeRepository) GetRecipeTags(recipe *domain.Recipe) error {
|
|||||||
|
|
||||||
// GetRecipeFavorite requires a recipe to be filled with at least an ID. This function will use the
|
// GetRecipeFavorite requires a recipe to be filled with at least an ID. This function will use the
|
||||||
// ID defined in the provided recipe to fill the favorite status of the recipe, based on the provided
|
// ID defined in the provided recipe to fill the favorite status of the recipe, based on the provided
|
||||||
// userId. The recipe is modified in place and is not returned. Any errors will be bubbled to the caller.
|
// userId. The recipe is modified in place and is not returned. If the recipe is nil, the function
|
||||||
|
// will return nothing (skipping). Any errors will be bubbled to the caller.
|
||||||
func (r *RecipeRepository) GetRecipeFavorite(recipe *domain.Recipe, userId int) error {
|
func (r *RecipeRepository) GetRecipeFavorite(recipe *domain.Recipe, userId int) error {
|
||||||
|
if recipe == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
tx, err := r.db.Begin()
|
tx, err := r.db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
@ -833,6 +846,9 @@ func (r *RecipeRepository) GetRecipeFavorite(recipe *domain.Recipe, userId int)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRecipeOfTheWeek searches for the most recent recipe of the week. If there is not a value,
|
||||||
|
// the recipe will be nil. This function simply collects the most recent entry in the recipeoftheweek
|
||||||
|
// table and return it. Any errors will be bubbled to the caller.
|
||||||
func (r *RecipeRepository) GetRecipeOfTheWeek(userId *int) (*domain.Recipe, error) {
|
func (r *RecipeRepository) GetRecipeOfTheWeek(userId *int) (*domain.Recipe, error) {
|
||||||
tx, err := r.db.Begin()
|
tx, err := r.db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user