- 菜谱查询返回创建都名字
This commit is contained in:
@@ -7,7 +7,8 @@ import (
|
|||||||
|
|
||||||
type FoodRecipeWithAction struct {
|
type FoodRecipeWithAction struct {
|
||||||
model.FoodRecipe
|
model.FoodRecipe
|
||||||
ActionType int8 `json:"actionType"`
|
AuthorName string `json:"authorName"`
|
||||||
|
ActionType int8 `json:"actionType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FoodRecipeItemChoiceExt struct {
|
type FoodRecipeItemChoiceExt struct {
|
||||||
@@ -29,9 +30,11 @@ func QueryFoodRecipes(db *DaoDB, keyword string, recipeID int, authorID, userID
|
|||||||
var sqlParams []interface{}
|
var sqlParams []interface{}
|
||||||
if userID != "" {
|
if userID != "" {
|
||||||
sql = `
|
sql = `
|
||||||
SELECT SQL_CALC_FOUND_ROWS t1.*, t2.action_type
|
SELECT SQL_CALC_FOUND_ROWS
|
||||||
|
t1.*, t2.action_type, t3.name author_name
|
||||||
FROM food_recipe t1
|
FROM food_recipe t1
|
||||||
LEFT JOIN food_recipe_user t2 ON t2.recipe_id = t1.id AND t2.user_id = ? AND t2.deleted_at = ?
|
LEFT JOIN food_recipe_user t2 ON t2.recipe_id = t1.id AND t2.user_id = ? AND t2.deleted_at = ?
|
||||||
|
LEFT user t3 ON t3.user_id = t1.author_id
|
||||||
WHERE t1.deleted_at = ?`
|
WHERE t1.deleted_at = ?`
|
||||||
sqlParams = []interface{}{
|
sqlParams = []interface{}{
|
||||||
userID,
|
userID,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ type FoodRecipeItem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FoodRecipeDetail struct {
|
type FoodRecipeDetail struct {
|
||||||
model.FoodRecipe
|
dao.FoodRecipeWithAction
|
||||||
ItemList []*FoodRecipeItem `json:"itemList"`
|
ItemList []*FoodRecipeItem `json:"itemList"`
|
||||||
StepList []*model.FoodRecipeStep `json:"stepList"`
|
StepList []*model.FoodRecipeStep `json:"stepList"`
|
||||||
}
|
}
|
||||||
@@ -227,8 +227,8 @@ func GetRecipeDetail(ctx *jxcontext.Context, recipeID int) (recipeDetail *FoodRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
recipeDetail = &FoodRecipeDetail{
|
recipeDetail = &FoodRecipeDetail{
|
||||||
FoodRecipe: recipeList[0].FoodRecipe,
|
FoodRecipeWithAction: *recipeList[0],
|
||||||
StepList: stepList,
|
StepList: stepList,
|
||||||
}
|
}
|
||||||
for _, v := range itemList {
|
for _, v := range itemList {
|
||||||
recipeDetail.ItemList = append(recipeDetail.ItemList, &FoodRecipeItem{
|
recipeDetail.ItemList = append(recipeDetail.ItemList, &FoodRecipeItem{
|
||||||
|
|||||||
Reference in New Issue
Block a user