Merge branch 'main' of github.com:Poomipat-Ch/taobin_recipe_manager

This commit is contained in:
Kenta420 2024-01-19 17:54:07 +07:00
commit 45851422f7
20 changed files with 1216 additions and 593 deletions

View file

@ -75,17 +75,7 @@ func (mr *MaterialRouter) GetFullMaterialDetail(w http.ResponseWriter, r *http.R
})
}
// for _, matCode := range matCodes {
// for index, matDetail := range materialDetails {
// if matCode.MaterialID == matDetail["materialId"] {
// materialDetails[index]["name"] = matCode.PackageDescription
// } else if matDetail["materialId"].(uint64) > 8110 && matDetail["materialId"].(uint64) <= 8130 {
// slotNum := matDetail["materialId"].(uint64) - 8110
// // mr.taoLogger.Log.Debug("GetFullMaterialDetail", zap.Any("slotNum", matDetail["materialId"]), zap.Any("slotNum", slotNum))
// materialDetails[index]["name"] = "Topping" + strconv.Itoa(int(slotNum))
// }
// }
// }
mr.taoLogger.Log.Debug("GetFullMaterialDetail", zap.Any("materialDetails", materialDetails[0]))
// send result
if err := json.NewEncoder(w).Encode(materialDetails); err != nil {
@ -141,7 +131,7 @@ func (mr *MaterialRouter) getMaterialSettingByMatID(w http.ResponseWriter, r *ht
countryID, err := mr.data.GetCountryIDByName(country)
if err != nil {
mr.taoLogger.Log.Error("MaterialRouter.GetMaterialSettingByMatID", zap.Error(err))
// mr.taoLogger.Log.Error("MaterialRouter.GetMaterialSettingByMatID", zap.Error(err))
http.Error(w, "Country not found", http.StatusNotFound)
return
}
@ -152,7 +142,7 @@ func (mr *MaterialRouter) getMaterialSettingByMatID(w http.ResponseWriter, r *ht
matIDuint, err := strconv.ParseUint(matID, 10, 64)
if err != nil {
mr.taoLogger.Log.Error("MaterialRouter.GetMaterialSettingByMatID", zap.Error(err))
// mr.taoLogger.Log.Error("MaterialRouter.GetMaterialSettingByMatID", zap.Error(err))
http.Error(w, "Invalid material id", http.StatusBadRequest)
return
}
@ -167,7 +157,7 @@ func (mr *MaterialRouter) getMaterialSettingByMatID(w http.ResponseWriter, r *ht
}
if err := json.NewEncoder(w).Encode(matSetting); err != nil {
mr.taoLogger.Log.Error("MaterialRouter.GetMaterialSettingByMatID", zap.Error(err))
// mr.taoLogger.Log.Error("MaterialRouter.GetMaterialSettingByMatID", zap.Error(err))
http.Error(w, "Internal Error", http.StatusInternalServerError)
return
}

View file

@ -173,6 +173,8 @@ func (rr *RecipeRouter) dashBoard(w http.ResponseWriter, r *http.Request) {
country := r.URL.Query().Get("country")
filename := r.URL.Query().Get("filename")
rr.taoLogger.Log.Debug("RecipeRouter.Dashboard", zap.Any("country", country), zap.Any("filename", filename))
result, err := rr.recipeService.GetRecipeDashboard(&contracts.RecipeDashboardRequest{
Country: country,
Filename: filename,
@ -205,6 +207,8 @@ func (rr *RecipeRouter) overview(w http.ResponseWriter, r *http.Request) {
filename := r.URL.Query().Get("filename")
materialIds := r.URL.Query().Get("materialIds")
rr.taoLogger.Log.Debug("RecipeRouter.Overview", zap.Any("take", take), zap.Any("offset", offset), zap.Any("country", country), zap.Any("filename", filename), zap.Any("materialIds", materialIds))
var materialIdsUint []int
for _, v := range strings.Split(materialIds, ",") {
materialIdUint, err := strconv.ParseUint(v, 10, 64)