|
@@ -504,6 +504,8 @@ func SetCentralKitchenForSchoolWithSpecByMealLabel(c *gin.Context) { |
|
|
now := time.Now() |
|
|
now := time.Now() |
|
|
mealLabelDb := db.MealLabelDb{} |
|
|
mealLabelDb := db.MealLabelDb{} |
|
|
mealLabelDb.Set(req.EnterpriseId) |
|
|
mealLabelDb.Set(req.EnterpriseId) |
|
|
|
|
|
|
|
|
|
|
|
var nowIds map[int]bool |
|
|
for _, v := range req.MealLabelList { |
|
|
for _, v := range req.MealLabelList { |
|
|
if v.Id != 0 { |
|
|
if v.Id != 0 { |
|
|
mealLabel, err := mealLabelDb.GetMealLabel(v.Id) |
|
|
mealLabel, err := mealLabelDb.GetMealLabel(v.Id) |
|
@@ -518,6 +520,7 @@ func SetCentralKitchenForSchoolWithSpecByMealLabel(c *gin.Context) { |
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
nowIds[v.Id] = true |
|
|
} else { |
|
|
} else { |
|
|
mealLabel := &model.MealLabel{ |
|
|
mealLabel := &model.MealLabel{ |
|
|
Name: v.Name, |
|
|
Name: v.Name, |
|
@@ -536,6 +539,25 @@ func SetCentralKitchenForSchoolWithSpecByMealLabel(c *gin.Context) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
labels, err := mealLabelDb.FindMealLabel(req.GradeId, req.Kind) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
var needDelIds []int |
|
|
|
|
|
for _, v := range *labels { |
|
|
|
|
|
if !nowIds[v.Id] { |
|
|
|
|
|
needDelIds = append(needDelIds, v.Id) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if len(needDelIds) > 0 { |
|
|
|
|
|
_, err = mealLabelDb.MealLabelDelete(needDelIds) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
e.OutSuc(c, "success", nil) |
|
|
e.OutSuc(c, "success", nil) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|