- 菜谱配料列表中,返回sku的名字与图片
This commit is contained in:
@@ -10,6 +10,20 @@ type FoodRecipeWithAction struct {
|
|||||||
ActionType int8 `json:"actionType"`
|
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) {
|
func QueryFoodRecipes(db *DaoDB, keyword string, recipeID int, authorID, userID string, offset, pageSize int) (recipeList []*FoodRecipeWithAction, totalCount int, err error) {
|
||||||
var sql string
|
var sql string
|
||||||
var sqlParams []interface{}
|
var sqlParams []interface{}
|
||||||
@@ -91,10 +105,14 @@ func QueryFoodRecipesItems(db *DaoDB, recipeID int) (recipeItemList []*model.Foo
|
|||||||
return recipeItemList, err
|
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 := `
|
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
|
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 = ?`
|
WHERE t1.deleted_at = ? AND t1.recipe_id = ?`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package userstore
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"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/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
@@ -21,13 +23,13 @@ type FoodRecipeStepParam struct {
|
|||||||
|
|
||||||
type FoodRecipeItem struct {
|
type FoodRecipeItem struct {
|
||||||
model.FoodRecipeItem
|
model.FoodRecipeItem
|
||||||
ItemChoiceList []*model.FoodRecipeItemChoice
|
ItemChoiceList []*dao.FoodRecipeItemChoiceExt `json:"itemChoiceList"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FoodRecipeDetail struct {
|
type FoodRecipeDetail struct {
|
||||||
model.FoodRecipe
|
model.FoodRecipe
|
||||||
ItemList []*FoodRecipeItem
|
ItemList []*FoodRecipeItem `json:"itemList"`
|
||||||
StepList []*model.FoodRecipeStep
|
StepList []*model.FoodRecipeStep `json:"stepList"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateFoodRecipeItemAndStep(ctx *jxcontext.Context, db *dao.DaoDB, recipeID int, itemList []*FoodRecipeItemParam, stepList []*FoodRecipeStepParam) (err error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
choiceMap := make(map[int8][]*model.FoodRecipeItemChoice)
|
choiceMap := make(map[int8][]*dao.FoodRecipeItemChoiceExt)
|
||||||
for _, v := range itemChoiceList {
|
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)
|
choiceMap[v.Index] = append(choiceMap[v.Index], v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user