fixed some bug change get by id to get by product code
This commit is contained in:
parent
7450796a6b
commit
d5cfdf496f
5 changed files with 30 additions and 29 deletions
|
|
@ -80,12 +80,12 @@ func (rr *RecipeRouter) Route(r chi.Router) {
|
|||
recipe := rr.data.GetRecipe01()
|
||||
recipeMetaData := rr.sheetService.GetSheet(r.Context(), "1rSUKcc5POR1KeZFGoeAZIoVoI7LPGztBhPw5Z_ConDE")
|
||||
|
||||
recipeResult := models.Recipe01{}
|
||||
var recipeResult *models.Recipe01
|
||||
recipeMetaDataResult := map[string]string{}
|
||||
|
||||
for _, v := range recipe {
|
||||
if v.ProductCode == productCode {
|
||||
recipeResult = v
|
||||
recipeResult = &v
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -104,12 +104,15 @@ func (rr *RecipeRouter) Route(r chi.Router) {
|
|||
}
|
||||
}
|
||||
|
||||
if recipeResult == nil {
|
||||
http.Error(w, "Not Found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"recipe": recipeResult,
|
||||
"recipeMetaData": recipeMetaDataResult,
|
||||
})
|
||||
|
||||
http.Error(w, "Recipe not found", http.StatusNotFound)
|
||||
})
|
||||
|
||||
r.Get("/{version}/json", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue