- 将skuName中的图片外移至dataResource
This commit is contained in:
@@ -3,8 +3,11 @@ package userstore
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/baseapi/utils/errlist"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/datares"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
@@ -112,8 +115,9 @@ func CreateFoodRecipe(ctx *jxcontext.Context, foodRecipe *model.FoodRecipe, item
|
||||
if err = updateFoodRecipeItemAndStep(ctx, db, foodRecipe.ID, itemList, stepList); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dao.Commit(db)
|
||||
|
||||
tryRegisterDataRes4Recipe(ctx, foodRecipe.Name, foodRecipe.Img, stepList)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -170,9 +174,28 @@ func UpdateFoodRecipe(ctx *jxcontext.Context, recipeID int, mapData map[string]i
|
||||
}
|
||||
dao.Commit(db)
|
||||
|
||||
tryRegisterDataRes4Recipe(ctx, localRecipe.Name, utils.Interface2String(valid["img"]), stepList)
|
||||
return err
|
||||
}
|
||||
|
||||
func tryRegisterDataRes4Recipe(ctx *jxcontext.Context, name, mainImg string, stepList []*FoodRecipeStepParam) (err error) {
|
||||
imgList := []string{}
|
||||
if mainImg != "" {
|
||||
imgList = append(imgList, mainImg)
|
||||
}
|
||||
for _, v := range stepList {
|
||||
if v.Img != "" {
|
||||
imgList = append(imgList, v.Img)
|
||||
}
|
||||
}
|
||||
errList := errlist.New()
|
||||
for _, v := range imgList {
|
||||
_, err := datares.TryRegisterDataResource(ctx, name, v, true, false, true)
|
||||
errList.AddErr(err)
|
||||
}
|
||||
return errList.GetErrListAsOne()
|
||||
}
|
||||
|
||||
func QueryFoodRecipes(ctx *jxcontext.Context, keyword, authorID string, offset, pageSize int) (recipeInfo *model.PagedInfo, err error) {
|
||||
_, userID := ctx.GetMobileAndUserID()
|
||||
recipeList, totalCount, err := dao.QueryFoodRecipes(dao.GetDB(), keyword, 0, authorID, userID, offset, pageSize)
|
||||
|
||||
Reference in New Issue
Block a user