- 菜谱API基本OK
This commit is contained in:
@@ -11,8 +11,8 @@ type FoodRecipeController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title 创建活动
|
||||
// @Description 创建活动
|
||||
// @Title 创建菜谱
|
||||
// @Description 创建菜谱
|
||||
// @Param token header string true "认证token"
|
||||
// @Param name formData string true "菜谱名"
|
||||
// @Param description formData string true "菜谱描述"
|
||||
@@ -41,3 +41,87 @@ func (c *FoodRecipeController) CreateFoodRecipe() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 编辑菜谱
|
||||
// @Description 编辑菜谱
|
||||
// @Param token header string true "认证token"
|
||||
// @Param recipeID formData int true "菜谱ID"
|
||||
// @Param name formData string false "菜谱名"
|
||||
// @Param description formData string false "菜谱描述"
|
||||
// @Param img formData string false "图片""
|
||||
// @Param timeInMinute formData string false "大约需要时间(分钟)"
|
||||
// @Param recipeItems formData string false "菜谱配料"
|
||||
// @Param recipeSteps formData string false "菜谱步骤"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateFoodRecipe [put]
|
||||
func (c *FoodRecipeController) UpdateFoodRecipe() {
|
||||
c.callUpdateFoodRecipe(func(params *tFoodrecipeUpdateFoodRecipeParams) (retVal interface{}, errCode string, err error) {
|
||||
var (
|
||||
itemList []*userstore.FoodRecipeItemParam
|
||||
stepList []*userstore.FoodRecipeStepParam
|
||||
)
|
||||
if err = jxutils.Strings2Objs(params.RecipeItems, &itemList, params.RecipeSteps, &stepList); err == nil {
|
||||
err = userstore.UpdateFoodRecipe(params.Ctx, params.RecipeID, params.MapData, itemList, stepList)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 查询菜谱列表
|
||||
// @Description 查询菜谱列表
|
||||
// @Param token header string true "认证token"
|
||||
// @Param keyword query string false "关键字"
|
||||
// @Param userID query string false "厂商ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /QueryFoodRecipes [get]
|
||||
func (c *FoodRecipeController) QueryFoodRecipes() {
|
||||
c.callQueryFoodRecipes(func(params *tFoodrecipeQueryFoodRecipesParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = userstore.QueryFoodRecipes(params.Ctx, params.Keyword, params.UserID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 得到我的推荐菜谱列表
|
||||
// @Description 得到我的推荐菜谱列表
|
||||
// @Param token header string true "认证token"
|
||||
// @Param keyword query string false "关键字"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetRecommendFoodRecipes [get]
|
||||
func (c *FoodRecipeController) GetRecommendFoodRecipes() {
|
||||
c.callGetRecommendFoodRecipes(func(params *tFoodrecipeGetRecommendFoodRecipesParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = userstore.GetRecommendFoodRecipes(params.Ctx, params.Keyword)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 得到菜谱详情
|
||||
// @Description 得到菜谱详情
|
||||
// @Param token header string true "认证token"
|
||||
// @Param recipeID query int true "菜谱ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetRecipeDetail [get]
|
||||
func (c *FoodRecipeController) GetRecipeDetail() {
|
||||
c.callGetRecipeDetail(func(params *tFoodrecipeGetRecipeDetailParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = userstore.GetRecipeDetail(params.Ctx, params.RecipeID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 对菜谱投票
|
||||
// @Description 对菜谱投票
|
||||
// @Param token header string true "认证token"
|
||||
// @Param recipeID formData int true "菜谱ID"
|
||||
// @Param voteType formData int true "-1:踩,0:取消之前的投票,1:赞"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /VoteFoodRecipe [post]
|
||||
func (c *FoodRecipeController) VoteFoodRecipe() {
|
||||
c.callVoteFoodRecipe(func(params *tFoodrecipeVoteFoodRecipeParams) (retVal interface{}, errCode string, err error) {
|
||||
err = userstore.VoteFoodRecipe(params.Ctx, params.RecipeID, params.VoteType)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user