- 修改菜谱的几个bug
This commit is contained in:
@@ -169,22 +169,34 @@ func UpdateFoodRecipe(ctx *jxcontext.Context, recipeID int, mapData map[string]i
|
||||
return err
|
||||
}
|
||||
|
||||
func QueryFoodRecipes(ctx *jxcontext.Context, keyword, authorID string) (recipeList []*dao.FoodRecipeWithAction, err error) {
|
||||
func QueryFoodRecipes(ctx *jxcontext.Context, keyword, authorID string, offset, pageSize int) (recipeInfo *model.PagedInfo, err error) {
|
||||
_, userID := ctx.GetMobileAndUserID()
|
||||
recipeList, err = dao.QueryFoodRecipes(dao.GetDB(), keyword, 0, authorID, userID)
|
||||
return recipeList, err
|
||||
recipeList, totalCount, err := dao.QueryFoodRecipes(dao.GetDB(), keyword, 0, authorID, userID, offset, pageSize)
|
||||
if err == nil {
|
||||
recipeInfo = &model.PagedInfo{
|
||||
TotalCount: totalCount,
|
||||
Data: recipeList,
|
||||
}
|
||||
}
|
||||
return recipeInfo, err
|
||||
}
|
||||
|
||||
func GetRecommendFoodRecipes(ctx *jxcontext.Context, keyword string) (recipeList []*model.FoodRecipe, err error) {
|
||||
func GetRecommendFoodRecipes(ctx *jxcontext.Context, keyword string, offset, pageSize int) (recipeInfo *model.PagedInfo, err error) {
|
||||
_, userID := ctx.GetMobileAndUserID()
|
||||
recipeList, err = dao.GetRecommendFoodRecipes(dao.GetDB(), keyword, userID)
|
||||
return recipeList, err
|
||||
recipeList, totalCount, err := dao.GetRecommendFoodRecipes(dao.GetDB(), keyword, userID, offset, pageSize)
|
||||
if err == nil {
|
||||
recipeInfo = &model.PagedInfo{
|
||||
TotalCount: totalCount,
|
||||
Data: recipeList,
|
||||
}
|
||||
}
|
||||
return recipeInfo, err
|
||||
}
|
||||
|
||||
func GetRecipeDetail(ctx *jxcontext.Context, recipeID int) (recipeDetail *FoodRecipeDetail, err error) {
|
||||
_, userID := ctx.GetMobileAndUserID()
|
||||
db := dao.GetDB()
|
||||
recipeList, err := dao.QueryFoodRecipes(db, "", recipeID, "", userID)
|
||||
recipeList, _, err := dao.QueryFoodRecipes(db, "", recipeID, "", userID, 0, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -231,7 +243,7 @@ func VoteFoodRecipe(ctx *jxcontext.Context, recipeID, voteType int) (err error)
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
recipeList, err := dao.QueryFoodRecipes(db, "", recipeID, "", userID)
|
||||
recipeList, _, err := dao.QueryFoodRecipes(db, "", recipeID, "", userID, 0, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -274,7 +286,7 @@ func VoteFoodRecipe(ctx *jxcontext.Context, recipeID, voteType int) (err error)
|
||||
recipe.DownvoteCount--
|
||||
}
|
||||
|
||||
if recipeUser.ActionType&actionMask != 0 || recipeUser.ActionType&(model.RecipeActionUpvote|model.RecipeActionDownvote) == 0 {
|
||||
if recipeUser.ActionType&actionMask != 0 || (recipeUser.ActionType&(model.RecipeActionUpvote|model.RecipeActionDownvote) == 0 && voteType == 0) {
|
||||
return fmt.Errorf("已经做过此操作了")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user