- 菜谱配料列表中,返回sku的名字与图片
This commit is contained in:
@@ -10,6 +10,20 @@ type FoodRecipeWithAction struct {
|
||||
ActionType int8 `json:"actionType"`
|
||||
}
|
||||
|
||||
type FoodRecipeItemChoiceExt struct {
|
||||
model.FoodRecipeItemChoice
|
||||
|
||||
Img string `orm:"size(255)" json:"img"`
|
||||
SkuName string `json:"skuName"`
|
||||
|
||||
Prefix string `json:"-"`
|
||||
SkuNameName string `orm:"column(sku_name_name)" json:"-"`
|
||||
Unit string `orm:"size(8)" json:"-"`
|
||||
SpecQuality float32 `json:"-"`
|
||||
SpecUnit string `json:"-"`
|
||||
Comment string `json:"-"`
|
||||
}
|
||||
|
||||
func QueryFoodRecipes(db *DaoDB, keyword string, recipeID int, authorID, userID string, offset, pageSize int) (recipeList []*FoodRecipeWithAction, totalCount int, err error) {
|
||||
var sql string
|
||||
var sqlParams []interface{}
|
||||
@@ -91,10 +105,14 @@ func QueryFoodRecipesItems(db *DaoDB, recipeID int) (recipeItemList []*model.Foo
|
||||
return recipeItemList, err
|
||||
}
|
||||
|
||||
func QueryFoodRecipesItemChoices(db *DaoDB, recipeID int) (recipeItemChoiceList []*model.FoodRecipeItemChoice, err error) {
|
||||
func QueryFoodRecipesItemChoices(db *DaoDB, recipeID int) (recipeItemChoiceList []*FoodRecipeItemChoiceExt, err error) {
|
||||
sql := `
|
||||
SELECT t1.*
|
||||
SELECT t1.*,
|
||||
t2.spec_quality, t2.spec_unit, t2.comment,
|
||||
t3.img, t3.prefix, t3.name sku_name_name, t3.unit
|
||||
FROM food_recipe_item_choice t1
|
||||
LEFT JOIN sku t2 ON t2.id = t1.sku_id
|
||||
LEFT JOIN sku_name t3 ON t3.id = t2.name_id
|
||||
WHERE t1.deleted_at = ? AND t1.recipe_id = ?`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
|
||||
@@ -3,6 +3,8 @@ package userstore
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
|
||||
"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"
|
||||
@@ -21,13 +23,13 @@ type FoodRecipeStepParam struct {
|
||||
|
||||
type FoodRecipeItem struct {
|
||||
model.FoodRecipeItem
|
||||
ItemChoiceList []*model.FoodRecipeItemChoice
|
||||
ItemChoiceList []*dao.FoodRecipeItemChoiceExt `json:"itemChoiceList"`
|
||||
}
|
||||
|
||||
type FoodRecipeDetail struct {
|
||||
model.FoodRecipe
|
||||
ItemList []*FoodRecipeItem
|
||||
StepList []*model.FoodRecipeStep
|
||||
ItemList []*FoodRecipeItem `json:"itemList"`
|
||||
StepList []*model.FoodRecipeStep `json:"stepList"`
|
||||
}
|
||||
|
||||
func updateFoodRecipeItemAndStep(ctx *jxcontext.Context, db *dao.DaoDB, recipeID int, itemList []*FoodRecipeItemParam, stepList []*FoodRecipeStepParam) (err error) {
|
||||
@@ -213,8 +215,9 @@ func GetRecipeDetail(ctx *jxcontext.Context, recipeID int) (recipeDetail *FoodRe
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
choiceMap := make(map[int8][]*model.FoodRecipeItemChoice)
|
||||
choiceMap := make(map[int8][]*dao.FoodRecipeItemChoiceExt)
|
||||
for _, v := range itemChoiceList {
|
||||
v.SkuName = jxutils.ComposeSkuName(v.Prefix, v.SkuNameName, v.Comment, v.Unit, v.SpecQuality, v.SpecUnit, 0)
|
||||
choiceMap[v.Index] = append(choiceMap[v.Index], v)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user