+ QueryFoodRecipes
This commit is contained in:
@@ -1,2 +1,27 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
|
import "git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
|
||||||
|
func QueryFoodRecipes(db *DaoDB, keyword, userID string) (recipeList []*model.FoodRecipe, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT t1.*
|
||||||
|
FROM food_recipe t1
|
||||||
|
WHERE 1 = 1`
|
||||||
|
sqlParams := []interface{}{}
|
||||||
|
if keyword != "" {
|
||||||
|
keywordLike := "%" + keyword + "%"
|
||||||
|
sql += " AND (t1.name LIKE ?"
|
||||||
|
sqlParams = append(sqlParams, keywordLike)
|
||||||
|
sql += ")"
|
||||||
|
}
|
||||||
|
if userID != "" {
|
||||||
|
sql += " AND t1.author_id = ?"
|
||||||
|
sqlParams = append(sqlParams, userID)
|
||||||
|
}
|
||||||
|
err = GetRows(db, &recipeList, sql, sqlParams...)
|
||||||
|
return recipeList, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRecommendFoodRecipes(db *DaoDB, keyword, userID string) (recipeList []*model.FoodRecipe, err error) {
|
||||||
|
return QueryFoodRecipes(db, keyword, userID)
|
||||||
|
}
|
||||||
|
|||||||
@@ -157,3 +157,8 @@ func UpdateFoodRecipe(ctx *jxcontext.Context, recipeID int, mapData map[string]i
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func QueryFoodRecipes(ctx *jxcontext.Context, keyword, userID string) (recipeList []*model.FoodRecipe, err error) {
|
||||||
|
recipeList, err = dao.QueryFoodRecipes(dao.GetDB(), keyword, userID)
|
||||||
|
return recipeList, err
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user